S
S
Slav4ka2020-06-29 14:42:58
webstorm
Slav4ka, 2020-06-29 14:42:58

How to connect ESLint to a project?

I'm trying to connect ESLint to a React project. Created a config (eslintrc.js):

module.exports = {
  env: {
    browser: true,
    es2020: true,
    node: true,
    jest: true,
  },
  extends: [
    'plugin:react/recommended',
    'airbnb',
  ],
  settings: {
    'import/resolver': {
      node: {
        paths: ['src'],
      },
    },
  },
  parser: '@typescript-eslint/parser',
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    ecmaVersion: 11,
    sourceType: 'module',
  },
  plugins: [
    'react',
    '@typescript-eslint',
  ],
  rules: {
    'react/prop-types': 'off',
    indent: [2, 'tab'],
    'react/jsx-indent': [2, 'tab'],
    'react/jsx-indent-props': [2, 'tab'],
    'no-tabs': 'off',
    'import/no-unresolved': 'warn',
    'object-curly-spacing': 'off',
    'react/jsx-filename-extension': [1, {extensions: ['.js', '.jsx']}],
  },
};

But an error occurs
Error: Plugin "react" was conflicted between ".eslintrc.js" and "../.eslintrc".

Full log:
Error: Plugin "react" was conflicted between ".eslintrc.js" and "../.eslintrc".
    at mergePlugins (/Users/account/Documents/web-km-client/node_modules/eslint/lib/cli-engine/config-array/config-array.js:202:19)
    at createConfig (/Users/account/Documents/web-km-client/node_modules/eslint/lib/cli-engine/config-array/config-array.js:305:9)
    at ConfigArray.extractConfig (/Users/account/Documents/web-km-client/node_modules/eslint/lib/cli-engine/config-array/config-array.js:481:33)
    at CLIEngine.isPathIgnored (/Users/account/Documents/web-km-client/node_modules/eslint/lib/cli-engine/cli-engine.js:954:18)
    at ESLintPlugin.invokeESLint (/Applications/WebStorm.app/Contents/plugins/JavaScriptLanguage/languageService/eslint/bin/eslint-plugin.js:100:23)
    at ESLintPlugin.getErrors (/Applications/WebStorm.app/Contents/plugins/JavaScriptLanguage/languageService/eslint/bin/eslint-plugin.js:78:21)
    at ESLintPlugin.onMessage (/Applications/WebStorm.app/Contents/plugins/JavaScriptLanguage/languageService/eslint/bin/eslint-plugin.js:52:64)
    at Interface.<anonymous> (/Applications/WebStorm.app/Contents/plugins/JavaScriptLanguage/jsLanguageServicesImpl/js-language-service.js:105:39)
    at Interface.emit (events.js:315:20)
    at Interface._onLine (readline.js:329:10)

Interestingly, everything works in VSCode, but not in WebStorm

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2020-07-06
@Aetae

Should be obvious from the error message, no? Above in the root of the project you have another file .eslintrcthat somehow conflicts with yours.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question