我想将 eslint 配置为 precommit 钩子,我的项目是使用 create-react-app 制作的。我目前有以下配置。但是在提交之前没有运行以下上演的 Lint。此外,我无法安装任何其他版本的 ESLint,因为 react-scripts 需要 5.6.0 版本的 eslint,如果我尝试手动安装它的其他版本,它会引发错误。这里可能是什么问题?
{
"name": "poc",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.18.0",
"babel": "^6.23.0",
"babel-core": "^6.9.1",
"babel-env": "^2.4.1",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.9.0",
"file-saver": "^2.0.2",
"identity-obj-proxy": "^3.0.0",
"jest-css-modules": "^2.0.0",
"joi": "^14.3.1",
"js-cookie": "^2.2.1",
"jwt-decode": "^2.2.0",
"material-ui": "0.20.1",
"node-sass": "^4.14.1",
"randomstring": "^1.1.5",
"react": "^16.5.2",
"react-appinsights": "^2.0.2",
"react-dom": "^16.5.2",
"react-drag-listview": "^0.1.4",
"react-loader-spinner": "^2.3.0",
"react-minimal-pie-chart": "^8.0.1",
"react-picky": "^4.4.5",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"react-scripts": "2.1.1",
"react-select": "^3.0.4",
"xlsx": "^0.15.1"
},
"scripts": {
"start": "./node_modules/react-app-rewired/bin/index.js start",
"dev": "./node_modules/react-app-rewired/bin/index.js start",
"sbx": "./node_modules/react-app-rewired/bin/index.js start",
"stage": "./node_modules/react-app-rewired/bin/index.js start",
"prod": "./node_modules/react-app-rewired/bin/index.js start",
"build": "./node_modules/react-app-rewired/bin/index.js build",
"test": "jest",
"eject": "react-scripts eject",
"lint-staged": "lint-staged",
"lint": "react-scripts run lint"
},
"eslintConfig": {
"extends": [
"react-app",
"airbnb",
"prettier"
],
"rules": {
"semi": [
"error",
"always"
],
"indent": 2,
"no-console": "error",
"no-var": "error",
"import/prefer-default-export": "off"
},
"overrides": [
{
"files": [
"**/*.test.js",
"**/*.test.jsx"
],
"env": {
"jest": true
}
}
]
},
"husky": {
"hooks": {
"pre-commit": "echo aayushi && lint-staged"
}
},
"lint-staged": {
"*.{js,ts,tsx}": [
"prettier --write",
"lint"
],
"*.{json,md,html}": [
"prettier --write"
]
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.4",
"@babel/plugin-transform-block-scoped-functions": "^7.2.0",
"@babel/plugin-transform-block-scoping": "^7.4.4",
"@babel/plugin-transform-classes": "^7.4.4",
"@babel/plugin-transform-computed-properties": "^7.2.0",
"@babel/plugin-transform-destructuring": "^7.4.4",
"@babel/plugin-transform-duplicate-keys": "^7.2.0",
"@babel/plugin-transform-for-of": "^7.4.4",
"@babel/plugin-transform-function-name": "^7.4.4",
"@babel/plugin-transform-instanceof": "^7.2.0",
"@babel/plugin-transform-literals": "^7.2.0",
"@babel/plugin-transform-new-target": "^7.4.4",
"@babel/plugin-transform-object-super": "^7.2.0",
"@babel/plugin-transform-parameters": "^7.4.4",
"@babel/plugin-transform-react-jsx-self": "^7.10.1",
"@babel/plugin-transform-react-jsx-source": "^7.10.1",
"@babel/plugin-transform-shorthand-properties": "^7.2.0",
"@babel/plugin-transform-spread": "^7.2.2",
"@babel/plugin-transform-sticky-regex": "^7.2.0",
"@babel/plugin-transform-template-literals": "^7.4.4",
"@babel/plugin-transform-typeof-symbol": "^7.2.0",
"@babel/plugin-transform-unicode-regex": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"applicationinsights": "^1.0.8",
"babel-plugin-transform-es2015-arrow-functions": "^6.22.0",
"cookie-parser": "^1.4.3",
"ejs": "^2.6.1",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.13.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"express-session": "^1.15.6",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^3.2.0",
"husky": "^4.3.0",
"jest": "^23.6.0",
"jest-transform-css": "^2.0.0",
"lint-staged": "^10.5.1",
"passport": "^0.4.0",
"passport-saml": "^1.0.0",
"powerbi-report-component": "^1.1.3",
"prettier": "^2.2.0",
"react-app-rewired": "^2.1.3",
"workerize-loader": "^1.1.0"
},
"jest": {
"verbose": true,
"setupTestFrameworkScriptFile": "./src/test-setup.js",
"transform": {
"^.+\\.(js|jsx)?$": "babel-jest",
".+\\.(css|styl|less|sass|scss|svg)$": "jest-transform-css"
},
"transformIgnorePatterns": [
"node_modules/(?!(react-native|my-project|react-native-button)/)"
],
"moduleNameMapper": {
"my-module.js": "<rootDir>/path/to/my-module.js",
"\\.(css|less|sass|scss|svg)$": "identity-obj-proxy"
},
"collectCoverage": true,
"coverageReporters": [
"html",
"lcov",
"text"
]
}
}