Im using EsLint with VsCode.
How can I have an error appear when trying to import a module that doesn't exist ?
for example
import foo from './this-path-doesnt-exist'
Should underline in red. Does this require an eslint plugin ?
If you are using eslint as your linter, you can use eslint-plugin-import .
This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import names
In addition to the eslint plugin suggested, you can enable semantic checking for a JS file in VS Code by adding // @ts-check
at the top of the file:
// @ts-check
import foo from './this-path-doesnt-exist'
This will enable a number of other checks in the file as well, including type checking, so it may not be appropriate for every code base but it can help catch many common programming mistakes.
More info about ts-check
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With