-
-
Notifications
You must be signed in to change notification settings - Fork 173
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
🐛 ESLint edge case: flatCompat.extends
in FlatConfig files
#818
Comments
My assumption was indeed that Knip didn't need extra work here. But I've already started in #806 to actually load When I try that version of Knip in this CSB I'm getting this:
This happens because... it's complicated. But here's the gist. The reason is an ESLint config/plugin loads some rushstack stuff (which throws the error): Work-around in Knip: knip/packages/knip/src/util/jiti.ts Lines 9 to 10 in c6d5c10
This fix works fine so far. Apparently we're having a new scenario here in which the rushstack alias isn't active and I don't fancy jumping into this rabbit hole again. Maybe the fix is easy, idk. This also just made me reconsider the work in #806 for now. |
Ah yeah rushstack. It’s causing problems in other tools, at least in ESLint config expector: |
Thanks for sharing that! Will follow those issues for sure. |
Workaround needed until webpro-nl/knip#818 is fixed.
Prerequisites
Reproduction url
https://codesandbox.io/p/devbox/yjgd5f
Reproduction access
Description of the issue
With a recent end-of-life for ESLint v8, more people are migrating to FlatConfig. New
eslint.config.js
file is pretty standard, so most imports can be tracked without any special tricks. However, if this file refers to a config that is still relying on an old config system, Knip fails to detect that a project dependency is used.Here is an example for
eslint-config-next
:.eslintrc.json
before conversionKnip is smart enough to know that
next/core-web-vitals
comes fromeslint-config-next
, so does not mark this dependency as unused.eslint.config.js
after conversion↓
Knip does not know about
compat.extends("next/core-web-vitals")
, so markseslint-config-next
as unused inpackage.json
.Note that in the real world scenario the call may also look like this:
In the long term most popular community plugins and configs will be converted to FlatConfig so will be imported natively using ESM. But it would be great if Knip could handle
compat.extends
in the meantime to help folks with migration.The text was updated successfully, but these errors were encountered: