|
| 1 | +import i18N from 'eslint-plugin-i18n'; |
| 2 | +import babelParser from '@babel/eslint-parser'; |
| 3 | +import tsParser from '@typescript-eslint/parser'; |
| 4 | +import path from 'node:path'; |
| 5 | +import { fileURLToPath } from 'node:url'; |
| 6 | +import js from '@eslint/js'; |
| 7 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 8 | +import stylistic from '@stylistic/eslint-plugin'; |
| 9 | +import importPlugin from 'eslint-plugin-import'; |
| 10 | +import { changeRulesToStylistic } from 'eslint-migration-utils'; |
| 11 | + |
| 12 | +const __filename = fileURLToPath(import.meta.url); |
| 13 | +const __dirname = path.dirname(__filename); |
| 14 | +const compat = new FlatCompat({ |
| 15 | + baseDirectory: __dirname, |
| 16 | + recommendedConfig: js.configs.recommended, |
| 17 | + allConfig: js.configs.all |
| 18 | +}); |
| 19 | + |
| 20 | +export default [ |
| 21 | + { |
| 22 | + ignores: [ |
| 23 | + 'node_modules/**', |
| 24 | + '**/__tests__/**', |
| 25 | + ], |
| 26 | + }, |
| 27 | + ...compat.extends('devextreme/spell-check').map(config => { |
| 28 | + |
| 29 | + const newConfig = { |
| 30 | + ...config |
| 31 | + } |
| 32 | + |
| 33 | + if (config.rules) { |
| 34 | + newConfig.rules = { |
| 35 | + ...changeRulesToStylistic(config.rules), |
| 36 | + "spellcheck/spell-checker": [1, { |
| 37 | + "skipWords": [ |
| 38 | + "unschedule", |
| 39 | + "subscribable", |
| 40 | + "renderer", |
| 41 | + "rerender", |
| 42 | + "dx", |
| 43 | + "descr", |
| 44 | + "params", |
| 45 | + "typings", |
| 46 | + "wildcard", |
| 47 | + "metadata", |
| 48 | + "namespace", |
| 49 | + "namespaces" |
| 50 | + ] |
| 51 | + }] |
| 52 | + }; |
| 53 | + } |
| 54 | + |
| 55 | + return newConfig |
| 56 | + }), |
| 57 | + { |
| 58 | + plugins: { |
| 59 | + i18n: i18N, |
| 60 | + }, |
| 61 | + settings: { |
| 62 | + 'import/resolver': { |
| 63 | + node: { |
| 64 | + extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts'], |
| 65 | + }, |
| 66 | + }, |
| 67 | + }, |
| 68 | + }, |
| 69 | + ...compat.extends('eslint:recommended', 'plugin:import/recommended').map(config => ({ |
| 70 | + ...config, |
| 71 | + files: ['**/*.js'] |
| 72 | + })), |
| 73 | + { |
| 74 | + files: ['**/*.js'], |
| 75 | + languageOptions: { |
| 76 | + globals: { |
| 77 | + setInterval: true, |
| 78 | + setTimeout: true, |
| 79 | + clearInterval: true, |
| 80 | + clearTimeout: true, |
| 81 | + require: true, |
| 82 | + module: true, |
| 83 | + exports: true, |
| 84 | + }, |
| 85 | + parser: babelParser, |
| 86 | + parserOptions: { |
| 87 | + requireConfigFile: false, |
| 88 | + }, |
| 89 | + }, |
| 90 | + plugins: { |
| 91 | + '@stylistic': stylistic, |
| 92 | + }, |
| 93 | + rules: { |
| 94 | + 'i18n/no-russian-character': ['error', { |
| 95 | + includeIdentifier: true, |
| 96 | + }], |
| 97 | + 'block-spacing': 'error', |
| 98 | + 'comma-spacing': 'error', |
| 99 | + 'computed-property-spacing': 'error', |
| 100 | + 'comma-style': ['error', 'last'], |
| 101 | + 'eqeqeq': ['error', 'allow-null'], |
| 102 | + 'strict': 'error', |
| 103 | + 'func-call-spacing': 'error', |
| 104 | + 'key-spacing': 'error', |
| 105 | + 'keyword-spacing': ['error', { |
| 106 | + overrides: { |
| 107 | + catch: { |
| 108 | + after: false, |
| 109 | + }, |
| 110 | + |
| 111 | + for: { |
| 112 | + after: false, |
| 113 | + }, |
| 114 | + |
| 115 | + if: { |
| 116 | + after: false, |
| 117 | + }, |
| 118 | + |
| 119 | + switch: { |
| 120 | + after: false, |
| 121 | + }, |
| 122 | + |
| 123 | + while: { |
| 124 | + after: false, |
| 125 | + }, |
| 126 | + }, |
| 127 | + }], |
| 128 | + 'no-multiple-empty-lines': ['error', { |
| 129 | + max: 2, |
| 130 | + }], |
| 131 | + 'no-multi-spaces': 'error', |
| 132 | + 'no-trailing-spaces': 'error', |
| 133 | + 'no-empty': ['error', { |
| 134 | + allowEmptyCatch: true, |
| 135 | + }], |
| 136 | + 'no-new-func': 'error', |
| 137 | + 'no-eval': 'error', |
| 138 | + 'no-undef-init': 'error', |
| 139 | + 'no-unused-vars': ['error', { |
| 140 | + args: 'none', |
| 141 | + caughtErrors: 'none', |
| 142 | + ignoreRestSiblings: true, |
| 143 | + }], |
| 144 | + 'no-extend-native': 'error', |
| 145 | + 'no-alert': 'error', |
| 146 | + 'no-console': 'error', |
| 147 | + 'no-restricted-syntax': ['error', 'ForOfStatement'], |
| 148 | + 'no-var': 'error', |
| 149 | + 'no-whitespace-before-property': 'error', |
| 150 | + 'object-curly-spacing': ['error', 'always'], |
| 151 | + 'one-var': ['error', 'never'], |
| 152 | + 'prefer-const': 'error', |
| 153 | + 'semi-spacing': 'error', |
| 154 | + 'semi': 'error', |
| 155 | + 'space-before-blocks': 'error', |
| 156 | + 'space-before-function-paren': ['error', 'never'], |
| 157 | + 'space-in-parens': 'error', |
| 158 | + 'space-infix-ops': 'error', |
| 159 | + 'space-unary-ops': 'error', |
| 160 | + '@stylistic/space-infix-ops': 'error', |
| 161 | + 'space-unary-ops': 'error', |
| 162 | + 'spaced-comment': ['error', 'always', { |
| 163 | + exceptions: ['#DEBUG', '#ENDDEBUG'], |
| 164 | + markers: ['/'], |
| 165 | + }], |
| 166 | + '@stylistic/brace-style': ['error', '1tbs', { |
| 167 | + allowSingleLine: true, |
| 168 | + }], |
| 169 | + 'curly': ['error', 'multi-line', 'consistent'], |
| 170 | + 'unicode-bom': ['error', 'never'], |
| 171 | + 'eol-last': ['error', 'always'], |
| 172 | + '@stylistic/indent': ['error', 4, { |
| 173 | + SwitchCase: 1, |
| 174 | + MemberExpression: 1, |
| 175 | + |
| 176 | + CallExpression: { |
| 177 | + arguments: 1, |
| 178 | + }, |
| 179 | + }], |
| 180 | + 'quotes': ['error', 'single'], |
| 181 | + 'import/named': 2, |
| 182 | + 'import/default': 2, |
| 183 | + 'import/no-duplicates': 2, |
| 184 | + "import/extensions": "warn", |
| 185 | + "max-len": ["error", { "code": 150 }], |
| 186 | + }, |
| 187 | + |
| 188 | + }, |
| 189 | + ...compat.extends('devextreme/typescript').map(config => { |
| 190 | + const newConfig = { |
| 191 | + ...config, |
| 192 | + files: ['**/*.ts?(x)'], |
| 193 | + ignores: ['**/*.d.ts'], |
| 194 | + } |
| 195 | + |
| 196 | + if (config.rules) { |
| 197 | + newConfig.rules = changeRulesToStylistic(config.rules); |
| 198 | + } |
| 199 | + |
| 200 | + return newConfig; |
| 201 | + }), |
| 202 | + { |
| 203 | + files: ['**/*.ts?(x)'], |
| 204 | + ignores: ['**/*.d.ts'], |
| 205 | + plugins: { |
| 206 | + '@stylistic': stylistic, |
| 207 | + }, |
| 208 | + languageOptions: { |
| 209 | + parser: tsParser, |
| 210 | + ecmaVersion: 6, |
| 211 | + sourceType: 'module', |
| 212 | + parserOptions: { |
| 213 | + project: './tsconfig.json', |
| 214 | + tsconfigRootDir: __dirname, |
| 215 | + }, |
| 216 | + }, |
| 217 | + rules: { |
| 218 | + 'prefer-regex-literals': 'off', |
| 219 | + 'i18n/no-russian-character': ['error', { |
| 220 | + includeIdentifier: true, |
| 221 | + }], |
| 222 | + '@typescript-eslint/no-unused-vars': ['error', { |
| 223 | + "ignoreRestSiblings": true, |
| 224 | + "caughtErrors": 'none', |
| 225 | + }], |
| 226 | + '@typescript-eslint/switch-exhaustiveness-check': ['error', { |
| 227 | + considerDefaultExhaustiveForUnions: true, |
| 228 | + }], |
| 229 | + '@typescript-eslint/no-unsafe-function-type': 'off', |
| 230 | + '@typescript-eslint/ban-types': 'off', |
| 231 | + '@typescript-eslint/no-empty-object-type': 'off', |
| 232 | + '@typescript-eslint/no-throw-literal': 'off', |
| 233 | + '@typescript-eslint/no-explicit-any': 'off', |
| 234 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 235 | + '@typescript-eslint/no-unsafe-return': 'off', |
| 236 | + 'import/extensions': 'off', |
| 237 | + '@typescript-eslint/prefer-nullish-coalescing': 'off', |
| 238 | + 'no-underscore-dangle': 'off', |
| 239 | + '@typescript-eslint/naming-convention': 'off', |
| 240 | + }, |
| 241 | + }, |
| 242 | + ...compat.extends('devextreme/typescript').map(config => { |
| 243 | + const newConfig = { |
| 244 | + ...config, |
| 245 | + files: ['**/*.d.ts'], |
| 246 | + }; |
| 247 | + |
| 248 | + if (config.rules) { |
| 249 | + newConfig.rules = changeRulesToStylistic(config.rules); |
| 250 | + } |
| 251 | + |
| 252 | + return newConfig; |
| 253 | + }), |
| 254 | + { |
| 255 | + files: ['**/*.d.ts'], |
| 256 | + plugins: { |
| 257 | + '@stylistic': stylistic, |
| 258 | + }, |
| 259 | + languageOptions: { |
| 260 | + parser: tsParser, |
| 261 | + ecmaVersion: 6, |
| 262 | + sourceType: 'module', |
| 263 | + parserOptions: { |
| 264 | + project: './tsconfig.json', |
| 265 | + tsconfigRootDir: __dirname, |
| 266 | + ecmaFeatures: { |
| 267 | + globalReturn: true, |
| 268 | + jsx: true, |
| 269 | + }, |
| 270 | + }, |
| 271 | + }, |
| 272 | + rules: { |
| 273 | + 'i18n/no-russian-character': ['error', { |
| 274 | + includeIdentifier: true, |
| 275 | + }], |
| 276 | + '@typescript-eslint/no-unsafe-function-type': 'off', |
| 277 | + '@typescript-eslint/no-wrapper-object-types': 'off', |
| 278 | + '@typescript-eslint/no-empty-object-type': 'off', |
| 279 | + } |
| 280 | + }, |
| 281 | +]; |
0 commit comments