Reputation: 5306
a.js:
export const something = "something";
b:.js:
import { somethingElse } from './a';
If we try to import a non-existent variable like the code above, is there a way to get warned about this? (through linters, webpack, IDE etc)
Upvotes: 0
Views: 334
Reputation: 135742
It seems you are looking for the eslint-plugin-import
and its import/named
rule:
import/named
Verifies that all named imports are part of the set of named exports in the referenced module.
Given:
// ./foo.js export const foo = "I'm so foo"
The following is considered valid:
// ./bar.js import { foo } from './foo'
...and the following are reported:
// ./baz.js import { notFoo } from './foo'
Details/docs: https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md and the project's readme.
Upvotes: 2