Eslint plugin import rule to detect missing properties in module.exports

59 Views Asked by At

I have the following files:

// abc.js
module.exports = {
  def: 7,
  ghi: 8,
}

// export const def = 7
// export const ghi = 8

and

// importing.js
import { xyz } from './abc.js'

My IDE (Webstorm) correctly warns that xyz is not on the module.exports through own code analysis. But eslint with the eslint-plugin-import does not report an error. It does though if I change abc.js to use named es6 exports (as in the commented code)

Which rule do I have to add to make it work? Tried a few combinations but didn't find the appropiate one. My current rules field in my eslintrc is

{
  'import/no-unresolved': [2, {commonjs: true, amd: true}],
  'import/named': 2,
  'import/no-named-as-default': 2,
  'import/no-named-default': 2,
}
0

There are 0 best solutions below