Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Type errors with @types/eslint__eslintrc after upgrading to 9.20.0 #177

Closed
1 task
benedictleejh opened this issue Feb 10, 2025 · 6 comments
Closed
1 task
Assignees
Labels
accepted bug Something isn't working repro:yes Issues with a reproducible example

Comments

@benedictleejh
Copy link

benedictleejh commented Feb 10, 2025

Environment

Node version: v18.20.3
pnpm version: v8.15.6
Local ESLint version: v9.20.0 (Currently used)
Global ESLint version: Not found
Operating System: linux 5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36

This the environment in the Stackblitz reproduction.

What parser are you using?

Default (Espree)

What did you do?

After upgrading to ESLint 9.20.0, eslintrc's FlatCompat.extends() fails typechecking against Linter.Config[]

Type 'FlatConfig[]' does not satisfy the expected type 'Config<RulesRecord>[]'.
  Type 'FlatConfig' is not assignable to type 'Config<RulesRecord>'.
    Types of property 'languageOptions' are incompatible.
      Type 'import("/home/projects/vitejs-vite-pwrystkr/node_modules/.pnpm/@[email protected]/node_modules/@types/eslint/index").Linter.LanguageOptions' is not assignable to type 'import("/home/projects/vitejs-vite-pwrystkr/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/types/index").Linter.LanguageOptions'.
        Index signature for type 'string' is missing in type 'LanguageOptions'.

What did you expect to happen?

Typechecking would pass, like when using 9.19.0

What actually happened?

Typechecking failed

Link to Minimal Reproducible Example

https://stackblitz.com/edit/vitejs-vite-pwrystkr

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

This seems to be related to eslint/eslint#19414 and eslint/eslint#19418, where the types broke after ESLint synced its types with @eslint/core in eslint/eslint#19157. I had to use pnpm to replicate this issue, npm seems to hide this issue somehow.

@benedictleejh benedictleejh added bug Something isn't working repro:needed This issue should include a reproducible example labels Feb 10, 2025
@fasttime
Copy link
Member

Thanks for the report @benedictleejh, I can reproduce the error when I install packages with pnpm. The problem is that @types/eslint__eslintrc is using types from @types/eslint which is no longer in sync with ESLint.

The error does not occur with npm because of the different directory structure created under node_modules, which doesn't use symlinks. If I add a .npmrc file to the repo with the setting node-linker=hoisted, then pnpm installs packages in a way that resembles more closely what npm does, and the error no longer occurs:

Repro

Since this is a problem in @types/eslint__eslintrc, the fix will have be done in DefinitelyTyped, I'm just not 100% sure what it would be exactly at this time. We can leave this issue open for tracking until the problem is fixed.

@fasttime fasttime added repro:yes Issues with a reproducible example and removed repro:needed This issue should include a reproducible example labels Feb 10, 2025
@nzakas
Copy link
Member

nzakas commented Feb 10, 2025

@fasttime can we update @eslint/eslintrc to use the new types instead?

@fasttime
Copy link
Member

@nzakas We could add our type definitions to @eslint/eslintrc, AFAIK there are none.

@nzakas
Copy link
Member

nzakas commented Feb 10, 2025

I think that seems like the easiest path forward given how difficult it is to get changes in DefinitelyTyped.

@nzakas
Copy link
Member

nzakas commented Feb 10, 2025

Actually, let me look into this. We were trying for backwards compatibility with existing types with all of these changes, which was the point of adding all the integration tests. Maybe there's an easy fix here.

@nzakas nzakas self-assigned this Feb 10, 2025
@nzakas
Copy link
Member

nzakas commented Feb 10, 2025

Okay, I'm convinced the only thing that is in our control to fix this is to provide types in the @eslint/eslintrc package.

Moving this over to that repo.

@nzakas nzakas transferred this issue from eslint/eslint Feb 10, 2025
nzakas added a commit that referenced this issue Feb 12, 2025
nzakas added a commit that referenced this issue Feb 19, 2025
@github-project-automation github-project-automation bot moved this from Evaluating to Complete in Triage Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted bug Something isn't working repro:yes Issues with a reproducible example
Projects
Archived in project
Development

No branches or pull requests

3 participants