eslint / rewrite

Monorepo for the new version of ESLint
Apache License 2.0
65 stars 4 forks source link

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

Closed ChurroC closed 1 month ago

ChurroC commented 1 month ago

Which packages are affected?

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

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

nzakas commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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

nzakas commented 1 month ago

Going with #25 as it has more detail.