Open regseb opened 1 year ago
This seems like an issue with eslint itself, and not with eslint-plugin-import - this plugin doesn't do anything with eslint config.
(typically you'd only ever have one eslint config file in any repo, at the root, and you'd use overrides
to configure subdirectories, but either way it's specific to eslint)
@ljharb I created an issue at ESLint and eslint-plugin-import use indirectly ESLint config:
https://github.com/eslint/eslint/issues/16787
The
import/no-unused-modules
rule indirectly loads eslint configs by using eslint's internal moduleFileEnumerator
. This module isn't intended to be used outside eslint package. When used by eslint,FileEnumerator
receives full execution context that includes processed CLI options. The error you're getting is caused by the rule not providing the context to theFileEnumerator
instance it's using, so it works as if-c my_eslint.json
is not specified and therefore looks for.eslintrc.*
config files. We can discuss in https://github.com/eslint/eslint/issues/13481 how this rule could work with the new config system, but until then it seems incompatible with the-c
usage.
Yes, everything uses it indirectly - the bug is only with something that uses it directly.
Reopening per the comment on the linked issue.
This also seems to be an issue with the new eslint flat config file. When I enable this rule, I get the message:
Oops! Something went wrong! :(
ESLint: 8.38.0
ESLint couldn't find a configuration file. To set up a configuration file for this project, please run:
npm init @eslint/config
ESLint looked for configuration files in [<rootDir>]/[<childDir>] and its ancestors. If it found none, it then looked in your home directory.
If you think you already have a configuration file or if you need more help, please stop by the ESLint Discord server: https://eslint.org/chat
Flat config is in the root directory of the project, with no -c
flag provided in the eslint command. Without this rule, everything runs fine, but as soon as I enable it, the above error flags up.
The
import/no-unused-modules
rule doesn't work when the ESLint configuration file doesn't have a standard name. In my projects, I group the configuration files in a directory to avoid having too many files in the root (example with Cast Kodi).index.js
my_eslint.json
package.json
npm install
npx eslint -c my_eslint.js index.js