今天我运行eslint,两个脚本
"lint-staged": "lint-staged",
"eslint": "eslint --ext .tsx,.ts --fix ./src -c .eslintrc.js",
当我运行npm run eslint
//我运行npm run lint-staged
//它是正常的//它是错误的
lint-staged的结果;
> lint-staged
❯ Running tasks for src/**/*.tsx
✖ eslint --fix [FAILED]
◼ git add
✖ eslint --fix :
Oops! Something went wrong! :(
ESLint: 7.10.0
Error: Error while loading rule '@typescript-eslint/dot-notation': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
Occurred while linting /Users/***/components/BrowserInfo/Index.tsx
at Object.getParserServices (/Users/fugang/workspace/xinao/channel-desk/node_modules/_@typescript-eslint_experimental-utils@4.3.0@@typescript-eslint/experimental-utils/dist/eslint-utils/getParserServices.js:26:15)
包装中的线条-staged
发生了什么?
"lint-staged": {
"src/**/*.tsx": [
"eslint --fix -c .eslintrc.js",
"git add"
]
},
发布于 2020-11-03 21:50:38
您必须将以下配置添加到.eslint.json文件中
{
"parserOptions": {
...
"project": ["path/to/your/tsconfig/file"]
...
},
}
发布于 2021-11-06 07:33:40
如果使用.eslintrc.yml
的任何人都可以使用下面的代码来修复上述问题
extends:
- airbnb-typescript
parserOptions:
project:
- tsconfig.json
PS:tsconfig.json
在根文件夹中,更改它以匹配您的位置,以防它不在根文件夹中。
https://stackoverflow.com/questions/64116378
复制相似问题