Problem
I have a bunch of "Problems" in my VS Code PROBLEMS pane from eslint complaining about various JSON issues with my .eslintrc. Linting the directory outside of VS Code does not show me .eslintrc issues. My .eslintrc and .eslintignore files are in my workspace directory (same location as my .vscode directory.
Things I have tried
I tried adding the following entries to my .eslintignore file:
**/.***/.eslintrc.eslintrc./.eslintrc
But none of them keep VS Code from showing errors both in the file editor as well as the PROBLEMS pane.
I have added the .eslintrc to the exclude files setting in VS Code and then activated the excluded files filter in the PROBLEMS pane but I don't want to hide the file from the EXPLORER pane.
Question
How can I force VS Code/ESLint/vscode-eslint/the culprit to ignore my .eslintrc while linting inside VS Code?
.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',
},
}
Thanks!
Solution
The issue was that my .eslintrc was in a weird JSON-esque format and, while ESLint was reading it fine, VS Code was telling me about all of the issues. Once I properly formatted it as JSON, VS Code stopped complaining.
I think your problem is most related to VS Code rather than ESLint.
You may open your VS Code User Settings or Workspace Settings (Ctrl+Shift+P > Preferences: Open User Settings), and add some rules so that VS Code can ignore some files, e.g.
See more details about vscode-eslint extension.
Also, if you want to add autofix when saving files, you can add the following to your user/workspace settings: