Моя кодовая база полна .js
файлов, и я запускаю eslint
для определенного файла. Я получаю ниже ошибки:
1:8 error 'React' is defined but never used
no-unused-vars
1:27 error Trailing spaces not allowed
no-trailing-spaces
2:1 error 'prop-types' should be listed in the project's dependencies. Run
'npm i -S prop-types' to add it import/no-extraneous-dependencies
7:13 error Arrow function used ambiguously with a conditional expression
no-confusing-arrow
11:3 error Prop type `array` is forbidden
react/forbid-prop-types
Мой .eslintrc.js
module.exports = {
env: {
browser: true,
commonjs: true,
es6: true,
},
extends: [
'airbnb',
"plugin:react/recommended"
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
},
plugins: [
'react'
],
rules: {
"react/jsx-uses-react": 1,
},
};
Мой Package.json
"devDependencies": {
"@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^8.1.0",
"babel-cli": "6.18.0",
"babel-plugin-dynamic-import-node": "1.0.0",
"babel-plugin-react-intl": "2.2.0",
"babel-plugin-react-transform": "2.0.2",
"babel-plugin-transform-es2015-modules-commonjs": "6.18.0",
"babel-plugin-transform-react-constant-elements": "6.9.1",
"babel-plugin-transform-react-inline-elements": "6.8.0",
"babel-plugin-transform-react-remove-prop-types": "0.2.11",
"babel-preset-latest": "6.16.0",
"babel-preset-react-hmre": "1.1.1",
"circular-dependency-plugin": "2.0.0",
"coveralls": "2.11.15",
"css-loader": "^0.23.1",
"enzyme": "^2.7.0",
"eslint": "3.11.1",
"eslint-config-airbnb": "13.0.0",
"eslint-config-airbnb-base": "10.0.1",
"eslint-import-resolver-webpack": "0.8.0",
"eslint-plugin-import": "2.2.0",
"eslint-plugin-jsx-a11y": "2.2.3",
"eslint-plugin-react": "6.7.1",
"eslint-plugin-redux-saga": "0.1.5",
"eventsource-polyfill": "0.9.6",
"exports-loader": "0.6.3",
"file-loader": "^0.9.0",
"html-loader": "0.4.4",
"html-webpack-plugin": "2.24.1",
"husky": "^3.0.5",
"lint-staged": "^3.2.1",
"ngrok": "2.2.4",
"npm-run-all": "^4.1.5",
"prettier": "^1.18.2",
"standard-version": "^7.0.0",
"webpack-dev-middleware": "^1.11.0",
"webpack-hot-middleware": "^2.18.0"
}
Я пробовал с различными решениями ниже:
/*eslint-disable no-unused-vars*/
var React = require('react');
/*eslint-enable no-unused-vars*/
И:
var React = require('react'); // eslint-disable-line no-unused-vars
, но не может сделать это для почти 300-500 файлов.
Ожидание - устранить все ошибки, выданные в .js
файлах.
Заранее спасибо.