`eslint-plugin-import` rule `import/no-unused-modules` does not work with vscode-eslint.
See original GitHub issueThe plugin eslint-plugin-import
has a rule import/no-unused-modules
that checks (among other things) for exports that are not used in other files.
"import/no-unused-modules": [2, {"unusedExports": true}]
This does not work well with vscode-eslint: files that have not been opened in the editor yet are not taken into account. As a consequence exports are being reported as unused even though they are used.
For example, if I just open a new VSCode Window:
The serialize()
exported function is reported, even after saving the file.
Now if I open that other file which imports the serialize()
function:
Then go back to the first file and save it, the reporting is now gone:
It seems like only files that are open within VSCode are considered for the import/no-unused-modules
rule.
This behavior only seems to happen with VSCode. If I run eslint
on the command line, everything works fine.
I’ve initially opened an issue with eslint-plugin-import
but got redirected here by its author.
VSCode: 1.36.1
vscode-eslint: 1.9.0
OS: Ubuntu 19.04
ESLint: 6.0.1
eslint-plugin-import: 2.18.0
Node: 12.6.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:9 (4 by maintainers)
Top GitHub Comments
@ehmicky thanks for the additional information. The problem is that we can’t do that on typing since it would not scale parsing all files in a workspace.
What would work is that we auto trigger the lint task on save so that there is not need for a user interaction.
I get the same error would love to see a PR!