我的VS代码问题窗格中有一堆“问题”来自eslint抱怨我的各种JSON问题.eslintrc
。Linting VS Code以外的目录不会向我显示.eslintrc
问题。我.eslintrc
和.eslintignore
文件位于我的工作区目录中(与我的.vscode
目录位置相同)。
我尝试将以下条目添加到我的.eslintignore
文件中:
**/.*
**/.eslintrc
.eslintrc
./.eslintrc
但是它们都没有让VS Code在文件编辑器和问题窗格中都显示错误。
我已在VS Code中添加了排除文件设置,然后在PROBLEMS窗格中激活了排除文件过滤器,但我不想在EXPLORER窗格中隐藏该文件。
我如何强制VS Code / ESLint / vscode-eslint /忽略.eslintrc
在VS代码中的linting ?
.eslintrc
{
extends: 'airbnb',
parser: 'babel-eslint',
plugins: [
'react',
'jest',
],
env: {
browser: true,
node: true,
es6: true,
jest/globals: true,
},
globals: {
LOGGING_ENDPOINT: false,
$: false,
beautify: false,
testContext: false,
page: false,
},
settings: {
react: {
pragma: 'h',
},
},
rules: {
import/no-extraneous-dependencies: 'off',
import/no-unresolved: ['error', { ignore: ['^react$', '^react-dom$'] }],
import/extensions: 'off',
react/react-in-jsx-scope: 'off',
no-underscore-dangle: 'off',
react/no-danger: 'off',
no-unused-vars: ['error', { varsIgnorePattern: 'React' }],
react/require-default-props: 'off',
function-paren-newline: 'off',
import/no-named-as-default: 'off',
object-curly-newline: 'off',
jest/no-focused-tests: 'error',
},
}
问题在于.eslintrc
的格式是奇怪的JSON格式,虽然ESLint读得很好,但VS Code告诉我所有问题。一旦我将其正确格式化为JSON,VS Code就可以了
发布于 2019-03-15 15:06:14
我认为你的问题与VS Code而不是ESLint最相关。
.eslintrc
文件用于设置ESLint的规则和配置。
您可以打开VS代码用户设置或工作区设置(Ctrl+ Shift+ P>首选项:打开用户设置),并添加一些规则,以便VS代码可以忽略某些文件,例如
"eslint.options": {
"extensions": [".js", ".jsx"]
},
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
查看有关vscode-eslint扩展的更多详细信息。
此外,如果要在保存文件时添加自动修复,可以将以下内容添加到用户/工作区设置中:
"files.autoSave": "off",
"editor.formatOnSave": true,
"eslint.autoFixOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
},
https://stackoverflow.com/questions/-100006455
复制相似问题