gpt4 book ai didi

javascript - 加载规则时出错 '@typescript-eslint/dot-notation'

转载 作者:行者123 更新时间:2023-12-03 17:44:15 34 4
gpt4 key购买 nike

今天我运行 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"]
...
},
}

关于javascript - 加载规则时出错 '@typescript-eslint/dot-notation',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64116378/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com