[bug] no-unused-modules falls over when no src is provided #1334
Closed
Description
If no src
option is passed to import/no-unused-modules
it falls over with the following error:
TypeError: Error while loading rule 'import/no-unused-modules': Cannot read property 'src' of undefined
Occurred while linting /root/static/js/apps/account/components/account-header/account-header-loadable.jsx
at Object.create (/root/node_modules/eslint-plugin-import/lib/rules/no-unused-modules.js:289:35)
at createRuleListeners (/root/node_modules/eslint/lib/linter.js:578:21)
at Object.keys.forEach.ruleId (/root/node_modules/eslint/lib/linter.js:732:31)
at Array.forEach (<anonymous>)
at runRules (/root/node_modules/eslint/lib/linter.js:690:34)
at Linter._verifyWithoutProcessors (/root/node_modules/eslint/lib/linter.js:899:31)
at preprocess.map.textBlock (/root/node_modules/eslint/lib/linter.js:955:35)
at Array.map (<anonymous>)
at Linter.verify (/root/node_modules/eslint/lib/linter.js:954:42)
at Linter.verifyAndFix (/root/node_modules/eslint/lib/linter.js:1047:29)
error Command failed with exit code 2.
The documentation claims it defaults to process.cwd()
which would be fine, but it still seems to provide that error, implying that it's maybe not being set correctly? Seems to originate from around here in the source.
Here are my versions:
eslint@5.16.0
eslint-plugin-import@2.17.1
$ node -v
> v10.15.3
I wish this rule would just use whatever dir
/glob is being used from the command being run. So for us it's something like this:
eslint static/js/ --ext .jsx,.js
...where I would expect this rule to just pick up static/js/
instead of me manually having to set that in the rule config.
I am happy to help fix this and would just need to be pointed in the right direction! 👍
Metadata
Assignees
Labels
No labels