Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bug: ESLint parser and plugin have wrong types for programatic use in ESLint flat config #7494

Closed as not planned
Labels
bugSomething isn't workingworking as intendedIssues that are closed as they are working as intended
@jaydenseric

Description

@jaydenseric

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I havesearched for related issues and found none that matched my issue.
  • I haveread the FAQ and my problem is not listed.

Relevant Package

  • parser
  • eslint-plugin

Playground Link

No response

Repro Code

ESLint has a new “flat” config system:

Unfortunately, when attempting to import and use the TypeScript ESLint plugin and parser within the ESLint config of typeimport("eslint").Linter.FlatConfig they result in TypeScript errors.

Ineslint.config.js:

//@ts-checkimporteslintPluginTypescriptfrom"@typescript-eslint/eslint-plugin";importeslintParserTypescriptfrom"@typescript-eslint/parser";/** * ESLint config. *@satisfies {Array<import("eslint").Linter.FlatConfig>} */consteslintConfig=[{languageOptions:{parser:eslintParserTypescript,},plugins:{"@typescript-eslint":eslintPluginTypescript,},},];exportdefaulteslintConfig;

ESLint Config

No response

tsconfig

No response

Expected Result

The TypeScript ESLint plugin and parser should be usable within ESLint “flat” config of typeimport("eslint").Linter.FlatConfig without causing TypeScript errors.

Actual Result

ThelanguageOptions.parser has this TypeScript error:

Type 'typeof import("[redacted]/node_modules/@typescript-eslint/parser/dist/index")' is not assignable to type 'ParserModule | undefined'.  Type 'typeof import("[redacted]/node_modules/@typescript-eslint/parser/dist/index")' is not assignable to type 'ObjectMetaProperties & { parseForESLint(text: string, options?: any): ESLintParseResult; }'.    Type 'typeof import("[redacted]/node_modules/@typescript-eslint/parser/dist/index")' is not assignable to type '{ parseForESLint(text: string, options?: any): ESLintParseResult; }'.      The types of 'parseForESLint(...).ast.comments' are incompatible between these types.        Type 'Comment[] | undefined' is not assignable to type 'Comment[]'.          Type 'undefined' is not assignable to type 'Comment[]'.

Theplugins["@typescript-eslint"] has this TypeScript error:

Type '{ configs: Record<string, Config>; rules: TypeScriptESLintRules; }' is not assignable to type 'Plugin'.  Types of property 'rules' are incompatible.    Type 'TypeScriptESLintRules' is not assignable to type 'Record<string, RuleModule | ((context: RuleContext) => RuleListener)>'.      'string' index signatures are incompatible.        Type 'RuleModule<string, unknown[], RuleListener>' is not assignable to type 'RuleModule | ((context: RuleContext) => RuleListener)'.          Type 'RuleModule<string, unknown[], RuleListener>' is not assignable to type 'RuleModule'.            Types of property 'create' are incompatible.              Type '(context: Readonly<RuleContext<string, unknown[]>>) => RuleListener' is not assignable to type '(context: RuleContext) => RuleListener'.                Types of parameters 'context' and 'context' are incompatible.                  Type 'RuleContext' is not assignable to type 'Readonly<RuleContext<string, unknown[]>>'.                    The types of 'parserOptions.ecmaVersion' are incompatible between these types.                      Type '3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | "latest" | undefined' is not assignable to type '"latest" | EcmaVersion | undefined'.                        Type '14' is not assignable to type '"latest" | EcmaVersion | undefined'.
Screenshot 2023-08-17 at 2 32 12 pm

Additional Info

The TypeScript ESLint project should be using the same ESLint types from@types/eslint like the rest of the ecosystem is using, instead of internally maintaining separate types. Where there are problems with the@types/eslint types they should be fixed in contributions so the entire ecosystem benefits.

This attitude is upsetting:

/*
We intentionally do not include @types/eslint.
This is to ensure that nobody accidentally uses those incorrect types
instead of the ones declared within this package
*/

I have run into frustrations before because Microsoft have not been participating in contributing to the main ESLint types the community is using, and as a consequence they are of poor quality.

Versions

packageversion
@typescript-eslint/eslint-plugin6.4.0
@typescript-eslint/parser6.4.0
TypeScript5.1.6
ESLint8.47.0
node20.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingworking as intendedIssues that are closed as they are working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp