Thi*_*ddi 6 javascript node.js typescript eslint eslintignore
我正在尝试在 Next.js 项目中实现 eslint,但我不想next.config.js被 lint。我尝试添加ignorePatterns到.eslintrc.json,添加.eslintignore文件并添加eslintIgnore属性到我的package.json,它们似乎都有相同的错误行为。
当只留下目录路径时,它会按预期工作:
// .eslintrc.json
{
"env": {
"browser": true
},
"extends": ["airbnb", "plugin:@typescript-eslint/recommended"],
"plugins": ["react", "react-hooks", "@typescript-eslint", "prettier"],
"parser": "@typescript-eslint/parser",
"ignorePatterns": ["graphql/generated/", "third-party/"],
"rules": { /* ... */ },
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"typescript": {}
},
"polyfills": ["fetch"]
}
}
Run Code Online (Sandbox Code Playgroud)
输出是:
/Users/mac-user/development/my-project/next.config.js
1:18 error Require statement not part of import statement @typescript-eslint/no-var-requires
2:17 error Require statement not part of import statement @typescript-eslint/no-var-requires
? 2 problems (2 errors, 0 warnings)
Run Code Online (Sandbox Code Playgroud)
要删除这些2个错误我尝试添加next.config.js到ignorePatterns这样的:
"ignorePatterns": ["graphql/generated/", "third-party/", "next.config.js"],
Run Code Online (Sandbox Code Playgroud)
但这是我得到的输出:
Oops! Something went wrong! :(
ESLint: 6.7.2.
You are linting ".", but all of the files matching the glob pattern "." are ignored.
If you don't want to lint these files, remove the pattern "." from the list of arguments passed to ESLint.
If you do want to lint these files, try the following solutions:
* Check your .eslintignore file, or the eslintIgnore property in package.json, to ensure that the files are not configured to be ignored.
* Explicitly list the files from this glob that you'd like to lint on the command-line, rather than providing a glob as an argument.
Run Code Online (Sandbox Code Playgroud)
这是没有意义的,因为我没有模式.。我可以添加内联注释以next.congif.js显式忽略抛出错误的行,但最好完全忽略该文件。顺便说一下,除了那些我想忽略的文件之外,我的项目中确实有很多其他文件。
我错过了什么吗?有没有其他方法可以忽略项目中的特定文件?
| 归档时间: |
|
| 查看次数: |
4645 次 |
| 最近记录: |