|
| 1 | +/* eslint-disable spellcheck/spell-checker */ |
| 2 | +import path from 'node:path'; |
| 3 | +import { fileURLToPath } from 'node:url'; |
| 4 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 5 | +import babelParser from '@babel/eslint-parser'; |
| 6 | +import tsParser from '@typescript-eslint/parser'; |
| 7 | +import stylistic from '@stylistic/eslint-plugin'; |
| 8 | +import importPlugin from 'eslint-plugin-import'; |
| 9 | +import { changeRulesToStylistic } from 'eslint-migration-utils'; |
| 10 | + |
| 11 | +const filename = fileURLToPath(import.meta.url); |
| 12 | +const dirname = path.dirname(filename); |
| 13 | +const compat = new FlatCompat({ |
| 14 | + baseDirectory: dirname, |
| 15 | +}); |
| 16 | + |
| 17 | +export default [ |
| 18 | + { |
| 19 | + ignores: [ |
| 20 | + 'src/index.ts', |
| 21 | + 'src/common', |
| 22 | + 'src/ui', |
| 23 | + 'tests/src/server/component-names.ts', |
| 24 | + '**/node_modules', |
| 25 | + '**/dist'], |
| 26 | + }, |
| 27 | + { |
| 28 | + plugins: { |
| 29 | + '@stylistic': stylistic, |
| 30 | + import: importPlugin, |
| 31 | + }, |
| 32 | + }, |
| 33 | + { |
| 34 | + languageOptions: { |
| 35 | + parser: tsParser, |
| 36 | + parserOptions: { |
| 37 | + project: './tsconfig.json', |
| 38 | + tsconfigRootDir: dirname, |
| 39 | + requireConfigFile: false, |
| 40 | + ecmaVersion: 6, |
| 41 | + sourceType: 'module', |
| 42 | + }, |
| 43 | + }, |
| 44 | + }, |
| 45 | + ...compat.extends('devextreme/spell-check'), |
| 46 | + ...compat.extends('devextreme/javascript').map((config) => ({ |
| 47 | + ...config, |
| 48 | + files: ['**/*.js', '**/*.mjs'], |
| 49 | + languageOptions: { |
| 50 | + parser: babelParser, |
| 51 | + }, |
| 52 | + })), |
| 53 | + ...compat.extends('devextreme/typescript').map((config) => ({ |
| 54 | + ...config, |
| 55 | + rules: config.rules |
| 56 | + ? changeRulesToStylistic(config.rules) |
| 57 | + : {}, |
| 58 | + files: ['**/*.ts'], |
| 59 | + })), |
| 60 | + { |
| 61 | + rules: { |
| 62 | + 'import/no-cycle': 'warn', |
| 63 | + 'no-param-reassign': 'warn', |
| 64 | + 'no-underscore-dangle': 'warn', |
| 65 | + 'spellcheck/spell-checker': [1, { |
| 66 | + lang: 'en_US', |
| 67 | + comments: false, |
| 68 | + strings: false, |
| 69 | + identifiers: true, |
| 70 | + templates: false, |
| 71 | + skipIfMatch: ['^\\$?..$'], |
| 72 | + skipWords: [ |
| 73 | + 'unschedule', |
| 74 | + 'subscribable', |
| 75 | + 'renderer', |
| 76 | + 'rerender', |
| 77 | + 'dx', |
| 78 | + 'descr', |
| 79 | + 'params', |
| 80 | + 'typings', |
| 81 | + 'wildcard', |
| 82 | + 'metadata', |
| 83 | + 'namespace', |
| 84 | + 'namespaces', |
| 85 | + ], |
| 86 | + }], |
| 87 | + }, |
| 88 | + }, |
| 89 | + { |
| 90 | + files: ['**/*.js', '**/*.mjs'], |
| 91 | + languageOptions: { |
| 92 | + parser: babelParser, |
| 93 | + }, |
| 94 | + rules: { |
| 95 | + 'global-require': 'off', |
| 96 | + 'import/no-unresolved': 'off', |
| 97 | + 'import/no-extraneous-dependencies': 'off', |
| 98 | + 'import/no-dynamic-require': 'warn', |
| 99 | + 'new-cap': 'off', |
| 100 | + 'no-undef': 'off', |
| 101 | + 'no-unused-expressions': 'warn', |
| 102 | + 'no-useless-escape': 'warn', |
| 103 | + }, |
| 104 | + }, |
| 105 | + { |
| 106 | + files: ['**/*.ts'], |
| 107 | + rules: { |
| 108 | + '@stylistic/max-len': ['error', { |
| 109 | + code: 150, |
| 110 | + }], |
| 111 | + '@typescript-eslint/no-explicit-any': 'warn', |
| 112 | + '@typescript-eslint/no-extraneous-class': 'warn', |
| 113 | + '@typescript-eslint/explicit-module-boundary-types': 'warn', |
| 114 | + '@typescript-eslint/prefer-for-of': 'warn', |
| 115 | + '@typescript-eslint/explicit-function-return-type': 'warn', |
| 116 | + '@typescript-eslint/no-unsafe-return': 'warn', |
| 117 | + '@typescript-eslint/restrict-plus-operands': 'warn', |
| 118 | + '@typescript-eslint/no-this-alias': 'warn', |
| 119 | + '@typescript-eslint/prefer-optional-chain': 'warn', |
| 120 | + '@typescript-eslint/init-declarations': 'warn', |
| 121 | + '@typescript-eslint/prefer-nullish-coalescing': 'warn', |
| 122 | + '@typescript-eslint/no-use-before-define': 'warn', |
| 123 | + '@typescript-eslint/member-ordering': 'warn', |
| 124 | + '@typescript-eslint/no-dynamic-delete': 'warn', |
| 125 | + '@typescript-eslint/naming-convention': 'warn', |
| 126 | + '@typescript-eslint/no-invalid-this': 'warn', |
| 127 | + '@typescript-eslint/no-unsafe-function-type': 'warn', |
| 128 | + '@typescript-eslint/no-wrapper-object-types': 'warn', |
| 129 | + // NOTE: this rule requires "strictNullChecks": true in tsconfig |
| 130 | + '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off', |
| 131 | + 'class-methods-use-this': 'warn', |
| 132 | + 'consistent-return': 'warn', |
| 133 | + 'guard-for-in': 'warn', |
| 134 | + 'import/extensions': 'warn', |
| 135 | + 'import/no-extraneous-dependencies': 'warn', |
| 136 | + 'max-classes-per-file': 'warn', |
| 137 | + 'no-plusplus': 'warn', |
| 138 | + 'no-restricted-syntax': 'warn', |
| 139 | + 'prefer-spread': 'warn', |
| 140 | + 'no-empty-pattern': 'warn', |
| 141 | + 'no-empty': 'warn', |
| 142 | + 'no-prototype-builtins': 'warn', |
| 143 | + }, |
| 144 | + }, |
| 145 | + { |
| 146 | + files: ['**/*.spec.ts'], |
| 147 | + rules: { |
| 148 | + '@typescript-eslint/ban-ts-comment': 'warn', |
| 149 | + '@typescript-eslint/no-shadow': 'warn', |
| 150 | + '@typescript-eslint/no-unused-expressions': 'warn', |
| 151 | + '@typescript-eslint/class-literal-property-style': 'warn', |
| 152 | + '@typescript-eslint/no-useless-constructor': 'warn', |
| 153 | + '@typescript-eslint/no-empty-function': 'warn', |
| 154 | + '@typescript-eslint/require-await': 'warn', |
| 155 | + '@typescript-eslint/no-floating-promises': 'warn', |
| 156 | + 'import/order': 'warn', |
| 157 | + 'no-restricted-globals': 'warn', |
| 158 | + 'no-self-assign': 'warn', |
| 159 | + 'no-new': 'warn', |
| 160 | + 'no-return-assign': 'warn', |
| 161 | + }, |
| 162 | + }, |
| 163 | +]; |
0 commit comments