Reputation: 8460
I have this code:
const notUsed = 1;
export const notUsedExported = 1;
I'm not using those const, but when I run Eslint on that file I only get the error for the not exported const:
/Users/XXX/myproject/src/myFile.js
38:7 error 'notUsed' is assigned a value but never used no-unused-vars
✖ 1 problem (1 error, 0 warnings)
Why is that? I want to get an error on the exported not used const also.
In my config of Eslint I have:
{
"extends": [
"eslint:recommended",
"semistandard",
"plugin:jest/recommended"
],
"env": {
"es2019": true,
"jest": true,
"mocha": true,
"node": true
},
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"rules": {
"array-callback-return": "warn",
"camelcase": "warn",
"guard-for-in": "off",
"jest/no-conditional-expect": "warn",
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/no-mocks-import": "warn",
"n/no-path-concat": "off",
"no-await-in-loop": "off",
"no-case-declarations": "off",
"no-console": "warn",
"no-continue": "off",
"no-control-regex": "warn",
"no-empty-pattern": "off",
"no-mixed-operators": "warn",
"no-param-reassign": "off",
"no-restricted-syntax": "off",
"no-throw-literal": "warn",
"no-underscore-dangle": "off",
"no-unsafe-optional-chaining": "warn",
"no-useless-escape": "warn",
"prefer-regex-literals": "off",
"promise/param-names": "off",
"no-unused-vars": "error"
}
Upvotes: 3
Views: 1540
Reputation: 7787
The export
is a usage of that variable, so it's not going to get picked up by no-unused-vars
. To detect dead exports, you'll need either a third-party tool, or a plugin: eslint-plugin-import
has exactly the rule you need.
Upvotes: 2