question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`eslint-plugin-import` rule `import/no-unused-modules` does not work with vscode-eslint.

See original GitHub issue

The 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:

Screenshot from 2019-07-18 12-43-27

The serialize() exported function is reported, even after saving the file.

Now if I open that other file which imports the serialize() function:

Screenshot from 2019-07-18 12-44-04

Then go back to the first file and save it, the reporting is now gone:

Screenshot from 2019-07-18 12-44-11

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:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
dbaeumercommented, Aug 8, 2019

@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.

1reaction
Axedysoncommented, Sep 24, 2021

I get the same error would love to see a PR!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ESLint not working in VS Code? - Stack Overflow
In my case, I had not installed he ESLint extension in VSCode, which was causing issue. Did it and it started working again....
Read more >
How to quickly configure ESLint for import sorting
How to quickly configure ESlint for import sorting using sort-imports and eslint-plugin-import with the import/orders rule.
Read more >
Import eslint plugin (My eslint config part 4) - YouTube
The airbnb-typescript eslint config already includes eslint - import plugin, and it includes a set of rules already.
Read more >
Custom ESLint Rules For Faster Refactoring - Medium
We need to add our plugin as a dependency in our project package.json and then install it. Without doing this, ESLint won't know...
Read more >
Efficient workflow with ESLint and Prettier - Dhanraj Padmashali
"eslint-config-prettier" : Turns off all rules that are ... ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found