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: (Eslint Flat and Compat Types are Different) #24

Closed
2 of 4 tasks
ChurroC opened this issue May 14, 2024 · 4 comments
Closed
2 of 4 tasks

Bug: (Eslint Flat and Compat Types are Different) #24

ChurroC opened this issue May 14, 2024 · 4 comments
Labels
accepted bug Something isn't working

Comments

@ChurroC
Copy link

ChurroC commented May 14, 2024

Which packages are affected?

  • @eslint/compat
  • @eslint/config-array
  • @eslint/object-schema

Environment

Node version:
npm version: 10.5.1
ESLint version: 9.2.0
Operating System: WSL

What did you do?

I was trying to use both flatCompat and fixupConfigRules to solve TypeError: context.getAncestors . Using the last portion of this article Introducing ESLint Compatibility Utilities.
The code from the article worked fine but started started going crazy with typescript errors.
First fixupConfigRules wouldn't accept params of the function flatCompat.
Then the eslint FlatConfig type wouldn't accept the return type of the fixupConfigRules.
I ended up jsdoc type casting it all to make it work.
image

What did you expect to happen?

Since these are for eslint I expected all the types to be right. Especially the return type because even if I didn't use flatCompat this whole plugin wouldn't work at all for eslint's flatConfig.

What actually happened?

Types didn't work

Link to Minimal Reproducible Example

https://codesandbox.io/p/github/ChurroC/next-server-theme/main?import=true

Participation

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

Additional comments

Just try to use the plug in with an array of type /** @type {import("eslint").Linter.FlatConfig[]} */.
If you decide to use the sandbox go to packages/eslint-config/eslint.next.config,js

@ChurroC ChurroC added the bug Something isn't working label May 14, 2024
@nzakas
Copy link
Member

nzakas commented May 15, 2024

Thanks for the report. We are just starting to roll out type definitions for these packages, so not surprising that there are issues.

We don't publish any type definitions for the eslint package, so are you using @types/eslint?

First fixupConfigRules wouldn't accept params of the function flatCompat.

I'm not sure what this means. Can you provide an example?

@nzakas
Copy link
Member

nzakas commented May 15, 2024

Also the repro URL you shared doesn't appear to show the issue you're describing. Can you please create a repro I can look at?

@karlhorky
Copy link

A similar issue with types being incompatible can be seen here (contains reproduction):

@nzakas
Copy link
Member

nzakas commented May 20, 2024

Going with #25 as it has more detail.

@nzakas nzakas closed this as not planned Won't fix, can't repro, duplicate, stale May 20, 2024
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
Projects
Status: Complete
Development

No branches or pull requests

3 participants