Launch global ESLint with eslint-plugin-jsx-a11y plugin

I am trying to run a global ESLint installation for a single file using the specified path to the configuration file:

eslint FileToCheck.jsx --config "../path/to/config/.eslintrc.js"

but i get an error

ESLint could not find the plugin "eslint-plugin-jsx-a11y". This can happen for several reasons:

  • If ESLint is installed globally, ensure that eslint-plugin-jsx-a11y is also installed globally. A globally installed ESLint cannot find a locally installed plugin.

  • If ESLint is installed locally, it is possible that the plugin is not installed correctly. Try reinstalling by doing the following:

    npm i eslint-plugin-jsx-a11y @latest --save-dev

So it looks like # 1 is applicable, and I need to install eslint-plugin-jsx-a11y globally. I am trying to do this with

yarn global add eslint-plugin-jsx-a11y

ESLint, . yarn global add ,

"eslint-plugin-jsx-a11y@6.0.2"

, ~/AppData/Local/Yarn/bin, ( ESLint).

ESLint ? , - ESLint .

, :

  • eslint
  • -
  • -eslint
  • eslint--
  • eslint-
  • eslint--JSX-a11y
  • eslint--Airbnb

.eslintrc.js, :

module.exports = {
  'extends': 'airbnb',
  'plugins': [
    'react',
    'jsx-a11y',
    'import'
  ],

  'env': {
    'browser': true
  },

  'parser': 'babel-eslint',

  'rules': {
    'prefer-template': 'error',
    'comma-dangle': ['error', 'always-multiline'],
    'import/no-extraneous-dependencies': 'off',
    'react/prop-types': 'off',
    'react/jsx-no-bind': 'off',
    'jsx-a11y/no-static-element-interactions': 'off',
    'jsx-a11y/no-noninteractive-element-interactions': 'off',
    'jsx-a11y/alt-text': 'off',
    'jsx-a11y/no-autofocus': 'off',
    'eqeqeq': ['error', 'always', { 'null': 'ignore' }],
    'no-use-before-define': ['error', { 'functions': false }],
    'func-style': ['error', 'declaration', { 'allowArrowFunctions': true }],
    'no-console': 'off',
    'no-alert': 'off',
    'no-continue': 'off',
    'no-param-reassign': ['error', { 'props': false }],
    'no-plusplus': ['error', { 'allowForLoopAfterthoughts': true }],
    'one-var-declaration-per-line': ['error', 'initializations'],
    'one-var': 'off', // Not needed because of one-var-declaration-per-line
    'indent': ['error', 2, {
      'FunctionDeclaration': { 'parameters': 'first' },
      'SwitchCase': 1
    }],
    'no-restricted-syntax': [
      'error',
      {
        selector: 'ForInStatement',
        message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
      },
      {
        selector: 'LabeledStatement',
        message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
      },
      {
        selector: 'WithStatement',
        message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
      },
    ],
  }
};

if (process.env.FEATURE_FLAGS) {
  const flags = Object.keys(JSON.parse(process.env.FEATURE_FLAGS));

  module.exports.globals = flags.reduce(function (flagConfig, flag) {
    flagConfig[flag] = false;
    return flagConfig;
  }, {});
}
+4

Source: https://habr.com/ru/post/1687599/


All Articles