-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
🐛 Cascaded ESLint configuration flags eslintrc files as unused #957
Comments
Please provide an actual and minimal reproduction. Without, I can't see if there are workspaces or how the files are referencing each other, etc. |
Here's a zip of a git repository: repro-knip-cascading-eslint-config.zip I used the node:20 docker image for these commands: after
After that, add:
before |
Thanks for the reproduction, that's clear. The issue here is that Knip does not implement all the logic that ESLint itself has. So indeed the other Here are the defaults for the ESLint plugin: https://knip.dev/reference/plugins/eslint This an example of how it can be overridden (as you were already doing): {
"$schema": "https://unpkg.com/knip@5/schema-jsonc.json",
"entry": [
"gulpfile.js", "test/**/*Spec.js"
],
"eslint": [".eslintrc.js", "buildprocess/.eslintrc.js", "test/.eslintrc.js"] // or ["**/.eslintrc.js"]
} |
As far as I can tell, the cascading configuration "logic" in ESLint is that any configuration file in a subdirectory to the directory of the root ESLint configuration file is used, as described in the paragraph directly under the first code block here: https://eslint.org/docs/v8.x/use/configure/configuration-files#cascading-and-hierarchy
I don't see how the If you don't want to add |
You do have a point. My initial reluctance came from the fact that none of the Knip plugins have this "expensive" glob pattern for However, ESLint v9 does not seem to have this feature. Adding a note to the docs. Thanks, glad we got this cleared up. |
🚀 This issue has been resolved in v5.45.0. See Release 5.45.0 for release notes. Using Knip in a commercial project? Please consider becoming a sponsor. |
Prerequisites
Reproduction url
https://knip.dev/reference/plugins/eslint#default-configuration
Reproduction access
Description of the issue
The ESLint plugin default configuration at https://knip.dev/reference/plugins/eslint#default-configuration lists the config files as
".eslintrc", ".eslintrc.{js,json,cjs}", "eslintrc.{yml,yaml}", "package.json"
, but the old non-flat ESLint config format can have.eslintrc
files appear in subdirectories (https://eslint.org/docs/v8.x/use/configure/configuration-files#cascading-and-hierarchy), so with this (minimized)knip.jsonc
:I get
buildprocess/.eslintrc.js
andtest/.eslintrc.js
flagged as unused, but not.eslintrc.js
. If I changeknip.jsonc
to:I do not get the
.eslintrc.js
files in subdirectories flagged either.The text was updated successfully, but these errors were encountered: