|
| 1 | +/* eslint-disable import/no-unresolved */ |
| 2 | +/* eslint-disable @typescript-eslint/no-var-requires */ |
| 3 | +const { fixupConfigRules, fixupPluginRules } = require('@eslint/compat'); |
| 4 | + |
| 5 | +const typescriptEslint = require('@typescript-eslint/eslint-plugin'); |
| 6 | +const path = require('eslint-plugin-path'); |
| 7 | +const prettier = require('eslint-plugin-prettier'); |
| 8 | +const sortKeysFix = require('eslint-plugin-sort-keys-fix'); |
| 9 | +const pluginImport = require('eslint-plugin-import'); |
| 10 | +const simpleImportSort = require('eslint-plugin-simple-import-sort'); |
| 11 | +const unusedImports = require('eslint-plugin-unused-imports'); |
| 12 | +const globals = require('globals'); |
| 13 | +const tsParser = require('@typescript-eslint/parser'); |
| 14 | +const js = require('@eslint/js'); |
| 15 | + |
| 16 | +const { FlatCompat } = require('@eslint/eslintrc'); |
| 17 | + |
| 18 | +const compat = new FlatCompat({ |
| 19 | + allConfig: js.configs.all, |
| 20 | + baseDirectory: __dirname, |
| 21 | + recommendedConfig: js.configs.recommended, |
| 22 | +}); |
| 23 | + |
| 24 | +module.exports = [ |
| 25 | + { |
| 26 | + ignores: [ |
| 27 | + 'node_modules/*', |
| 28 | + '**/package.json', |
| 29 | + '**/package-lock.json', |
| 30 | + '**/yarn.lock', |
| 31 | + '**/yarn-error.log', |
| 32 | + ], |
| 33 | + }, |
| 34 | + ...fixupConfigRules( |
| 35 | + compat.extends( |
| 36 | + 'airbnb', |
| 37 | + 'airbnb-typescript', |
| 38 | + 'airbnb/hooks', |
| 39 | + 'plugin:react/recommended', |
| 40 | + 'plugin:prettier/recommended', |
| 41 | + 'plugin:import/typescript', |
| 42 | + 'plugin:@typescript-eslint/recommended', |
| 43 | + 'plugin:@typescript-eslint/recommended-requiring-type-checking', |
| 44 | + ), |
| 45 | + ), |
| 46 | + { |
| 47 | + languageOptions: { |
| 48 | + ecmaVersion: 5, |
| 49 | + |
| 50 | + globals: { |
| 51 | + ...globals.browser, |
| 52 | + ...globals.node, |
| 53 | + ...globals.jest, |
| 54 | + }, |
| 55 | + parser: tsParser, |
| 56 | + parserOptions: { |
| 57 | + ecmaFeatures: { |
| 58 | + experimentalObjectRestSpread: true, |
| 59 | + jsx: true, |
| 60 | + legacyDecorators: true, |
| 61 | + }, |
| 62 | + |
| 63 | + project: './tsconfig.json', |
| 64 | + |
| 65 | + useJSXTextNode: true, |
| 66 | + }, |
| 67 | + |
| 68 | + sourceType: 'module', |
| 69 | + }, |
| 70 | + plugins: { |
| 71 | + '@typescript-eslint': fixupPluginRules(typescriptEslint), |
| 72 | + import: fixupPluginRules(pluginImport), |
| 73 | + path, |
| 74 | + prettier: fixupPluginRules(prettier), |
| 75 | + 'simple-import-sort': simpleImportSort, |
| 76 | + 'sort-keys-fix': sortKeysFix, |
| 77 | + 'unused-imports': unusedImports, |
| 78 | + }, |
| 79 | + rules: { |
| 80 | + '@typescript-eslint/array-type': 'off', |
| 81 | + |
| 82 | + '@typescript-eslint/member-delimiter-style': 'error', |
| 83 | + '@typescript-eslint/no-explicit-any': 'warn', |
| 84 | + '@typescript-eslint/no-floating-promises': 'off', |
| 85 | + '@typescript-eslint/no-namespace': 'off', |
| 86 | + '@typescript-eslint/no-unnecessary-type-constraint': 'off', |
| 87 | + '@typescript-eslint/no-unsafe-assignment': 'off', |
| 88 | + '@typescript-eslint/no-unsafe-call': 'off', |
| 89 | + '@typescript-eslint/no-unsafe-member-access': 'off', |
| 90 | + '@typescript-eslint/no-unused-vars': 'off', |
| 91 | + '@typescript-eslint/unbound-method': 'off', |
| 92 | + 'class-methods-use-this': 'off', |
| 93 | + 'consistent-return': 'off', |
| 94 | + curly: 'error', |
| 95 | + 'guard-for-in': 'off', |
| 96 | + 'import/extensions': 'off', |
| 97 | + 'import/no-cycle': 'off', |
| 98 | + 'import/no-extraneous-dependencies': 'off', |
| 99 | + 'import/no-unresolved': 'error', |
| 100 | + 'import/no-useless-path-segments': 'off', |
| 101 | + 'import/order': 'off', |
| 102 | + 'import/prefer-default-export': 'off', |
| 103 | + 'jsx-a11y/control-has-associated-label': 'off', |
| 104 | + |
| 105 | + 'linebreak-style': 'off', |
| 106 | + |
| 107 | + 'lines-between-class-members': 'error', |
| 108 | + 'newline-before-return': 'error', |
| 109 | + 'no-bitwise': 'off', |
| 110 | + |
| 111 | + 'no-console': 'error', |
| 112 | + |
| 113 | + 'no-multiple-empty-lines': [ |
| 114 | + 'error', |
| 115 | + { |
| 116 | + max: 1, |
| 117 | + maxEOF: 1, |
| 118 | + }, |
| 119 | + ], |
| 120 | + 'no-param-reassign': 'off', |
| 121 | + 'no-plusplus': 'off', |
| 122 | + 'no-prototype-builtins': 'off', |
| 123 | + 'no-restricted-syntax': 'off', |
| 124 | + 'no-sequences': 'off', |
| 125 | + 'no-shadow': 'off', |
| 126 | + 'no-underscore-dangle': 'off', |
| 127 | + 'no-unused-expressions': 'off', |
| 128 | + 'no-unused-vars': 'off', |
| 129 | + 'no-useless-constructor': 'off', |
| 130 | + 'object-curly-newline': 'off', |
| 131 | + 'object-curly-spacing': 'off', |
| 132 | + 'object-property-newline': 'off', |
| 133 | + 'one-var': 'off', |
| 134 | + 'one-var-declaration-per-line': 'error', |
| 135 | + 'path/no-relative-imports': [ |
| 136 | + 'error', |
| 137 | + { |
| 138 | + maxDepth: 2, |
| 139 | + suggested: false, |
| 140 | + }, |
| 141 | + ], |
| 142 | + 'prefer-const': 'error', |
| 143 | + 'prettier/prettier': 'error', |
| 144 | + 'quote-props': ['error', 'as-needed'], |
| 145 | + 'react-hooks/exhaustive-deps': 'warn', |
| 146 | + 'react-hooks/rules-of-hooks': 'error', |
| 147 | + 'react/destructuring-assignment': 'off', |
| 148 | + |
| 149 | + 'react/forbid-prop-types': 'off', |
| 150 | + |
| 151 | + 'react/function-component-definition': 'off', |
| 152 | + 'react/jsx-props-no-spreading': 'off', |
| 153 | + 'react/no-unused-prop-types': 'warn', |
| 154 | + 'react/prefer-stateless-function': 'off', |
| 155 | + 'react/prop-types': 'warn', |
| 156 | + 'react/require-default-props': 'off', |
| 157 | + 'require-await': 'error', |
| 158 | + 'simple-import-sort/imports': [ |
| 159 | + 'error', |
| 160 | + { |
| 161 | + groups: [ |
| 162 | + ['^\\u0000', '^react$', '^react', '^@?\\w', '^__mocks__(/.*|$)'], |
| 163 | + ['^(containers|core|data|domain|presentation|types)(/.*|$)'], |
| 164 | + ['^\\.\\.(?!/?$)', '^\\.\\./?$', '^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'], |
| 165 | + ], |
| 166 | + }, |
| 167 | + ], |
| 168 | + 'sort-keys-fix/sort-keys-fix': 'error', |
| 169 | + 'unused-imports/no-unused-imports': 'error', |
| 170 | + 'unused-imports/no-unused-vars': [ |
| 171 | + 'warn', |
| 172 | + { |
| 173 | + args: 'after-used', |
| 174 | + argsIgnorePattern: '^_', |
| 175 | + vars: 'all', |
| 176 | + varsIgnorePattern: '^_', |
| 177 | + }, |
| 178 | + ], |
| 179 | + }, |
| 180 | + |
| 181 | + settings: { |
| 182 | + 'import/resolver': { |
| 183 | + node: { |
| 184 | + extensions: ['.js', '.jsx', '.ts', '.tsx'], |
| 185 | + moduleDirectory: ['node_modules', 'src/', './'], |
| 186 | + }, |
| 187 | + }, |
| 188 | + |
| 189 | + react: { |
| 190 | + version: 'detect', |
| 191 | + }, |
| 192 | + }, |
| 193 | + }, |
| 194 | +]; |
0 commit comments