如何解决加载规则'@ typescript-eslint / dot-notation'时出错
今天我运行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)
在lint-staged软件包中
发生了什么事?
"lint-staged": {
"src/**/*.tsx": [
"eslint --fix -c .eslintrc.js","git add"
]
},
解决方法
您必须将以下配置添加到您的.eslint.json文件
{
"parserOptions": {
...
"project": ["path/to/your/tsconfig/file"]
...
},}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。