Загрузка данных


module.exports = {
  env: {
    browser: true,
    es2021: true,
    'jest/globals': true,
  },
  extends: [
    'plugin:react/recommended',
    'plugin:react-hooks/recommended',
    'plugin:jest/recommended',
    'airbnb',
    'plugin:@typescript-eslint/recommended',
    // Удаление конфликтующих с prettier правил
    'prettier',
    'plugin:eslint-comments/recommended',
  ],
  parser: '@typescript-eslint/parser',
  ignorePatterns: ['**/*.module.css', '**/*.scss', '**/*.md', '**/*.mdx', '**/*worker.ts', '**/*Worker.ts'],
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    project: './tsconfig.json',
    ecmaVersion: 'latest',
    sourceType: 'module',
    warnOnUnsupportedTypeScriptVersion: false,
  },
  reportUnusedDisableDirectives: true,
  plugins: ['react', 'jest', '@typescript-eslint', 'prettier', 'react-hooks'],
  settings: {
    'import/resolver': {
      typescript: {},
      node: {
        extensions: ['.js', '.jsx', '.ts', '.tsx'],
      },
      webpack: {
        config: 'webpack.lib.config.cjs',
        env: { NODE_ENV: 'local', production: true, development: true },
      },
    },
  },
  rules: {
    'react/require-default-props': 'off',
    'jsx-a11y/click-events-have-key-events': 'off',
    'jsx-a11y/no-noninteractive-element-interactions': 'off',
    'jsx-a11y/no-static-element-interactions': 'off',
    'jsx-a11y/control-has-associated-label': 'off',
    'import/no-extraneous-dependencies': [
      'error',
      { devDependencies: ['**/*.test.js', '**/*.spec.js', '**/*.config.js'] },
    ],
    // 'prettier/prettier': 'warn',
    'react/jsx-filename-extension': [2, { extensions: ['.js', '.jsx', '.ts', '.tsx'] }],
    'no-continue': 'off',
    'default-param-last': 'error',
    '@typescript-eslint/default-param-last': 'error',
    'no-undef': 'off',
    'no-underscore-dangle': 'off',
    'no-nested-ternary': 'off',
    'class-methods-use-this': 'off',
    'import/prefer-default-export': 'off',
    'func-names': ['error', 'as-needed'],
    'import/extensions': [
      'error',
      'ignorePackages',
      {
        js: 'never',
        jsx: 'never',
        ts: 'never',
        tsx: 'never',
      },
    ],
    'react/jsx-props-no-spreading': 'off',
    'arrow-body-style': 'off',
    'max-classes-per-file': ['error', 3],
    'no-plusplus': 'off',
    'no-shadow': 'off',
    '@typescript-eslint/no-empty-function': 'off',
    '@typescript-eslint/no-shadow': 'error',
    // Не обращаем внимания на символы конца строки
    'linebreak-style': 'off',
    // Отступы пока не проверяем
    indent: 'off',
    // Пустая строка в конце файла
    'eol-last': 'off',
    curly: ['error', 'multi-line'],
    'object-curly-spacing': ['warn', 'always'],
    'no-use-before-define': 'off',
    '@typescript-eslint/no-use-before-define': 'off',
    // Максимальная длина строки 120
    'max-len': [1, { code: 120 }],
    // Двойные кавычки в jsx
    'jsx-quotes': [1, 'prefer-double'],
    // Все остальные кавычки одинарные
    quotes: [1, 'single'],
    // Не включать пока не разберёмся в тонкостях правила
    'react/function-component-definition': [
      'off',
      {
        namedComponents: 'arrow-function',
      },
    ],
    'import/order': [
      'warn',
      {
        groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
        alphabetize: {
          order: 'asc',
          caseInsensitive: true,
        },
        named: true,
        'newlines-between': 'always-and-inside-groups',
      },
    ],
    // Отключаем пока не определились с prop-types
    'react/prop-types': 'off',
    // '@typescript-eslint/ban-ts-comments': ['error', {
    //   'ts-check': false,
    //   'ts-expect-error': 'allow-with-description',
    //   'ts-ignore': true,
    //   'ts-nocheck': true,
    // }],
    '@typescript-eslint/array-type': ['error', { deafult: 'array', readonly: 'array' }],
    // '@typescript-eslint/no-magic-number': 'error',
    // '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
    '@typescript-eslint/no-unused-vars': 'warn',
    'react/no-unused-prop-types': 'off',
    // Использование деструктуризации
    'react/destructuring-assignment': 'off',
    // Стрелочная функция может возвращать undefined
    'consistent-return': 'off',
    // Не обязательно использовать все зависимости в useEffect
    'react-hooks/exhaustive-deps': 'warn',
    // Проверка на наличие ключей в jsx,
    'react/jsx-key': 'error',
    // Использование any
    '@typescript-eslint/no-explicit-any': 'warn',
    'eslint-comments/require-description': 'off',
    'no-param-reassign': 'off',
    'no-useless-constructor': 'off',
    'react/react-in-jsx-scope': 'off',
    'no-restricted-syntax': 'off',
    'lines-between-class-members': [
      'error',
      'always',
      {
        exceptAfterSingleLine: true,
      },
    ],
    'eslint-comments/disable-enable-pair': 'off',
    'no-console': 'off',
  },
  overrides: [
    {
      // Особые правила для сторибука
      files: ['*.stories.tsx'],
      rules: {
        // В сторях можно писать any
        '@typescript-eslint/no-explicit-any': 'off',
      },
    },
  ],
};