import-js / import-js/eslint-plugin-import
[import/no-unused-modules] - "No files matching the pattern" error
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.9k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
I'm using both eslint-plugin-import and eslint-plugin-json. When there are only *.json files in my project, I get "No files matching the pattern" error from the import/no-unused-modules rule, and ESLint crashes.
Steps to reproduce:
- Clone this minimal reproducible case: https://github.com/EvgenyOrekhov/eslint-config-hardcore/tree/no-files-matching-the-pattern-bug
npm installnpm test
Actual result:
> no-files-matching-the-pattern-bug@0.0.0 test C:\eslint-config-hardcore
> eslint --ext .js,.json .
Oops! Something went wrong! :(
ESLint: 6.8.0.
No files matching the pattern "C:\eslint-config-hardcore" were found.
Please check for typing mistakes in the pattern.
npm ERR! Test failed. See above for more details.
Expected result: there should be no "No files matching the pattern" error, there should be only one warning from eslint-plugin-json
> no-files-matching-the-pattern-bug@0.0.0 test C:\eslint-config-hardcore
> eslint --ext .js,.json .
C:\eslint-config-hardcore\invalid.json
1:2 error Expected a JSON object, array or literal json/*
✖ 1 problem (1 error, 0 warnings)
npm ERR! Test failed. See above for more details.
When I remove the import/no-unused-modules rule from .eslintrc.json, the problem goes away.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal reproduction branch and its .eslintrc.json, then run npm install and npm test to observe how import/no-unused-modules behaves with only JSON files. Trace the rule's handling of the project path and compare the result with the expected single eslint-plugin-json error, without the no-files-matching crash.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100