|
| 1 | +import path from 'node:path'; |
| 2 | +import {fileURLToPath} from 'node:url'; |
| 3 | +import {fixupPluginRules} from '@eslint/compat'; |
| 4 | +import {FlatCompat} from '@eslint/eslintrc'; |
| 5 | +import js from '@eslint/js'; |
| 6 | +import stylistic from '@stylistic/eslint-plugin'; |
| 7 | +import tsParser from '@typescript-eslint/parser'; |
| 8 | +import _import from 'eslint-plugin-import'; |
| 9 | +import globals from 'globals'; |
| 10 | + |
| 11 | +const __filename = fileURLToPath(import.meta.url); |
| 12 | +const __dirname = path.dirname(__filename); |
| 13 | + |
| 14 | +const compat = new FlatCompat({ |
| 15 | + baseDirectory: __dirname, |
| 16 | + recommendedConfig: js.configs.recommended, |
| 17 | + allConfig: js.configs.all |
| 18 | +}); |
| 19 | + |
| 20 | +export default [{ |
| 21 | + ignores: [ |
| 22 | + '**/*.d.ts', |
| 23 | + '**/node_modules/*', |
| 24 | + '**/dist/*', |
| 25 | + '**/*.js' |
| 26 | + ], |
| 27 | +}, ...compat.extends( |
| 28 | + 'eslint:recommended', |
| 29 | + 'plugin:jsdoc/recommended-typescript', |
| 30 | + 'plugin:@typescript-eslint/eslint-recommended', |
| 31 | + 'plugin:@typescript-eslint/recommended' |
| 32 | +), { |
| 33 | + plugins: { |
| 34 | + ts: stylistic, |
| 35 | + import: fixupPluginRules(_import), |
| 36 | + }, |
| 37 | + languageOptions: { |
| 38 | + globals: { |
| 39 | + ...Object.fromEntries(Object.entries(globals.browser).map(([key]) => [key, 'off'])), |
| 40 | + }, |
| 41 | + parser: tsParser |
| 42 | + }, |
| 43 | + rules: { |
| 44 | + '@typescript-eslint/adjacent-overload-signatures': 'error', |
| 45 | + '@typescript-eslint/array-type': 'error', |
| 46 | + '@typescript-eslint/ban-ts-ignore': 'off', |
| 47 | + '@typescript-eslint/ban-ts-comment': 'warn', |
| 48 | + '@typescript-eslint/ban-types': 'off', |
| 49 | + '@typescript-eslint/consistent-type-assertions': 'error', |
| 50 | + '@typescript-eslint/consistent-type-definitions': 'off', |
| 51 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 52 | + '@typescript-eslint/explicit-member-accessibility': ['error', { |
| 53 | + accessibility: 'explicit', |
| 54 | + }], |
| 55 | + '@typescript-eslint/indent': ['off', 4, { |
| 56 | + FunctionDeclaration: { |
| 57 | + parameters: 'first', |
| 58 | + }, |
| 59 | + |
| 60 | + FunctionExpression: { |
| 61 | + parameters: 'first', |
| 62 | + }, |
| 63 | + }], |
| 64 | + '@typescript-eslint/await-thenable': 'off', |
| 65 | + '@typescript-eslint/member-ordering': 'error', |
| 66 | + '@typescript-eslint/no-empty-function': 'error', |
| 67 | + '@typescript-eslint/no-empty-interface': 'error', |
| 68 | + '@typescript-eslint/no-explicit-any': 'off', |
| 69 | + '@typescript-eslint/no-floating-promises': 'off', |
| 70 | + '@typescript-eslint/no-misused-new': 'error', |
| 71 | + '@typescript-eslint/no-namespace': 'off', |
| 72 | + '@typescript-eslint/no-parameter-properties': 'off', |
| 73 | + '@typescript-eslint/no-use-before-define': 'error', |
| 74 | + '@typescript-eslint/no-var-requires': 'off', |
| 75 | + '@typescript-eslint/prefer-for-of': 'error', |
| 76 | + '@typescript-eslint/prefer-function-type': 'error', |
| 77 | + '@typescript-eslint/prefer-namespace-keyword': 'error', |
| 78 | + '@typescript-eslint/prefer-regexp-exec': 'off', |
| 79 | + '@typescript-eslint/restrict-template-expressions': 'off', |
| 80 | + '@typescript-eslint/triple-slash-reference': 'error', |
| 81 | + '@typescript-eslint/unified-signatures': 'error', |
| 82 | + 'arrow-body-style': 'error', |
| 83 | + 'arrow-parens': ['error', 'always'], |
| 84 | + 'camelcase': 'error', |
| 85 | + 'comma-dangle': 'off', |
| 86 | + 'complexity': 'off', |
| 87 | + 'constructor-super': 'error', |
| 88 | + 'curly': 'error', |
| 89 | + 'default-case': 'error', |
| 90 | + 'eol-last': 'error', |
| 91 | + 'eqeqeq': ['error', 'smart'], |
| 92 | + 'guard-for-in': 'error', |
| 93 | + 'id-blacklist': [ |
| 94 | + 'error', |
| 95 | + 'any', |
| 96 | + 'Number', |
| 97 | + 'number', |
| 98 | + 'String', |
| 99 | + 'string', |
| 100 | + 'Boolean', |
| 101 | + 'boolean', |
| 102 | + 'Undefined', |
| 103 | + 'undefined', |
| 104 | + ], |
| 105 | + 'id-match': 'error', |
| 106 | + 'import/order': ['error', { |
| 107 | + alphabetize: { |
| 108 | + order: 'asc', |
| 109 | + caseInsensitive: true, |
| 110 | + }, |
| 111 | + }], |
| 112 | + 'jsdoc/require-description': 'error', |
| 113 | + 'jsdoc/no-undefined-types': 'off', |
| 114 | + 'max-classes-per-file': ['error', 1], |
| 115 | + 'max-len': ['error', { |
| 116 | + code: 140, |
| 117 | + }], |
| 118 | + 'ts/member-delimiter-style': ['error', { |
| 119 | + multiline: { |
| 120 | + delimiter: 'semi', |
| 121 | + requireLast: true, |
| 122 | + }, |
| 123 | + singleline: { |
| 124 | + delimiter: 'semi', |
| 125 | + requireLast: false, |
| 126 | + }, |
| 127 | + }], |
| 128 | + 'new-parens': 'error', |
| 129 | + 'no-bitwise': 'error', |
| 130 | + 'no-caller': 'error', |
| 131 | + 'no-cond-assign': 'error', |
| 132 | + 'no-console': ['error', { |
| 133 | + allow: [ |
| 134 | + 'info', |
| 135 | + 'warn', |
| 136 | + 'error', |
| 137 | + 'debug', |
| 138 | + 'dir', |
| 139 | + 'timeLog', |
| 140 | + 'assert', |
| 141 | + 'clear', |
| 142 | + 'count', |
| 143 | + 'countReset', |
| 144 | + 'group', |
| 145 | + 'groupEnd', |
| 146 | + 'table', |
| 147 | + 'dirxml', |
| 148 | + 'groupCollapsed', |
| 149 | + 'Console', |
| 150 | + 'profile', |
| 151 | + 'profileEnd', |
| 152 | + 'timeStamp', |
| 153 | + 'context', |
| 154 | + ], |
| 155 | + }], |
| 156 | + 'no-debugger': 'error', |
| 157 | + 'no-empty': 'error', |
| 158 | + 'no-eval': 'error', |
| 159 | + 'no-fallthrough': 'error', |
| 160 | + 'no-invalid-this': 'off', |
| 161 | + 'no-multiple-empty-lines': 'error', |
| 162 | + 'no-new-wrappers': 'error', |
| 163 | + 'no-throw-literal': 'error', |
| 164 | + 'no-trailing-spaces': 'off', |
| 165 | + 'no-undef-init': 'error', |
| 166 | + 'no-underscore-dangle': 'off', |
| 167 | + 'no-unsafe-finally': 'error', |
| 168 | + 'no-unused-expressions': 'error', |
| 169 | + 'no-unused-labels': 'error', |
| 170 | + 'no-var': 'error', |
| 171 | + 'object-shorthand': 'error', |
| 172 | + 'one-var': ['error', 'never'], |
| 173 | + 'prefer-const': 'error', |
| 174 | + 'quotes': ['error', 'single'], |
| 175 | + 'quote-props': ['error', 'consistent-as-needed'], |
| 176 | + 'radix': 'error', |
| 177 | + 'semi': ['error', 'always'], |
| 178 | + 'space-before-function-paren': ['error', { |
| 179 | + anonymous: 'never', |
| 180 | + asyncArrow: 'always', |
| 181 | + named: 'never', |
| 182 | + }], |
| 183 | + 'spaced-comment': 'error', |
| 184 | + 'ts/type-annotation-spacing': 'error', |
| 185 | + 'use-isnan': 'error', |
| 186 | + 'valid-typeof': 'off', |
| 187 | + } |
| 188 | +}]; |
0 commit comments