I just installed eslint-plugin-unused-imports
. When I commit, it does all its linting work and removed a bunch of imports even though many of those imports are being used in the file.
May or may not be worth noting, this project has a bunch of legacy Backbone and newer React components, with some Backbone views rendering React components. Also, this is a JS not TS project.
eslint-plugin-unused-imports issues states:
If the issue is with something being marked wrongly as a unused import and therefore being removed. It is an issue with the imported package (
@typescript-eslint/eslint-plugin
for TS oreslint
for JS) and itsno-unused-vars
rule. I cannot do anything about this except updating if a fix is made upstream.If new rules are added
no-unused-vars
upstream which should be autofixed, mark your issue rule addition.
But I'm not sure how to address this.
Below is my linting setup:
"devDependencies": {
...
"eslint": "^6.8.0",
"eslint-config-airbnb": "^10.0.1",
"eslint-config-prettier": "^6.15.0",
"eslint-import-resolver-webpack": "^0.13.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-promise": "^4.3.1",
"eslint-plugin-react": "^6.10.3",
"eslint-plugin-standard": "^4.1.0",
"eslint-plugin-unused-imports": "^1.1.0",
...
"prettier": "^2.2.1",
"prettier-eslint": "^9.0.0",
"prettier-eslint-cli": "^5.0.0",
"prettier-stylelint": "^0.4.2",
...
"stylelint": "^9.8.0",
"stylelint-config-prettier": "^4.0.0",
"stylelint-config-standard": "^18.0.0",
"stylelint-prettier": "^1.1.2",
...
},
"peerDependencies": {
"eslint": ">=6.0.1",
"eslint-plugin-import": ">=2.18.0",
"eslint-plugin-node": ">=9.1.0",
"eslint-plugin-promise": ">=4.2.1",
"eslint-plugin-standard": ">=4.0.0"
},
"lint-staged": {
"src/**/*.{js,json,jsx,scss}": [
"node ./scripts/lint-prettier.js"
],
"*.{js,jsx,json,md}": [
"prettier --list-different"
]
},
...
"husky": {
"hooks": {
"pre-commit": "lint-staged && npm test"
}
}
}