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 ?
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.
If you are already not using linter follow below steps:
npm install eslint --save-dev
npm install eslint-plugin-import --save-dev
then you need to configure
extends:
- eslint:recommended
- plugin:import/errors
- plugin:import/warnings
into your .eslintrc.(yml|json|js) file manually.
If you are already using linter. Skip step one to install eslint.
And dont forget install extention ESLint, i spent tonn of time on config but problem was in extention.