|
| 1 | +const js = require('@eslint/js'); |
| 2 | +const globals = require('globals'); |
| 3 | +const tsParser = require('@typescript-eslint/parser'); |
| 4 | +const tsPlugin = require('@typescript-eslint/eslint-plugin'); |
| 5 | +const importPlugin = require('eslint-plugin-import'); |
| 6 | +const prettierPlugin = require('eslint-plugin-prettier'); |
| 7 | +const prettierConfig = require('eslint-config-prettier'); |
| 8 | + |
| 9 | +module.exports = [ |
| 10 | + { |
| 11 | + ignores: [ |
| 12 | + 'node_modules/**', |
| 13 | + 'dist/**', |
| 14 | + '.github/**', |
| 15 | + 'docs/**', |
| 16 | + 'coverage/**', |
| 17 | + '**/*.d.ts' |
| 18 | + ], |
| 19 | + }, |
| 20 | + js.configs.recommended, |
| 21 | + { |
| 22 | + files: ['**/*.ts'], |
| 23 | + languageOptions: { |
| 24 | + parser: tsParser, |
| 25 | + parserOptions: { |
| 26 | + project: './tsconfig.json', |
| 27 | + sourceType: 'module', |
| 28 | + ecmaVersion: 2020, |
| 29 | + }, |
| 30 | + globals: { |
| 31 | + ...globals.node, |
| 32 | + ...globals.es2020, |
| 33 | + ...globals.jest, |
| 34 | + }, |
| 35 | + }, |
| 36 | + plugins: { |
| 37 | + '@typescript-eslint': tsPlugin, |
| 38 | + import: importPlugin, |
| 39 | + prettier: prettierPlugin, |
| 40 | + }, |
| 41 | + rules: { |
| 42 | + 'max-len': 'off', |
| 43 | + 'no-unused-vars': 'off', |
| 44 | + 'no-restricted-globals': ['error', 'Buffer'], |
| 45 | + 'array-callback-return': 'warn', |
| 46 | + 'default-case': ['warn', { commentPattern: '^no default$' }], |
| 47 | + 'dot-location': ['warn', 'property'], |
| 48 | + 'eqeqeq': ['warn', 'smart'], |
| 49 | + 'new-parens': 'warn', |
| 50 | + 'no-caller': 'warn', |
| 51 | + 'no-eval': 'error', |
| 52 | + 'no-extend-native': 'warn', |
| 53 | + 'no-extra-bind': 'warn', |
| 54 | + 'no-extra-label': 'warn', |
| 55 | + 'no-implied-eval': 'error', |
| 56 | + 'no-iterator': 'warn', |
| 57 | + 'no-label-var': 'warn', |
| 58 | + 'no-labels': ['warn', { allowLoop: true, allowSwitch: false }], |
| 59 | + 'no-lone-blocks': 'warn', |
| 60 | + 'no-loop-func': 'warn', |
| 61 | + 'no-multi-str': 'warn', |
| 62 | + 'no-new-func': 'error', |
| 63 | + 'no-new-object': 'warn', |
| 64 | + 'no-new-wrappers': 'warn', |
| 65 | + 'no-obj-calls': 'warn', |
| 66 | + 'no-octal-escape': 'warn', |
| 67 | + 'no-restricted-syntax': ['warn', 'WithStatement'], |
| 68 | + 'no-script-url': 'warn', |
| 69 | + 'no-self-assign': 'warn', |
| 70 | + 'no-self-compare': 'warn', |
| 71 | + 'no-sequences': 'warn', |
| 72 | + 'no-template-curly-in-string': 'warn', |
| 73 | + 'no-throw-literal': 'error', |
| 74 | + 'no-unused-expressions': ['warn', { |
| 75 | + allowShortCircuit: true, |
| 76 | + allowTernary: true, |
| 77 | + allowTaggedTemplates: true, |
| 78 | + }], |
| 79 | + 'no-useless-computed-key': 'warn', |
| 80 | + 'no-useless-concat': 'warn', |
| 81 | + 'no-useless-escape': 'warn', |
| 82 | + 'no-useless-rename': ['warn', { |
| 83 | + ignoreDestructuring: false, |
| 84 | + ignoreImport: false, |
| 85 | + ignoreExport: false, |
| 86 | + }], |
| 87 | + 'no-with': 'warn', |
| 88 | + 'no-whitespace-before-property': 'warn', |
| 89 | + 'padding-line-between-statements': ['warn', |
| 90 | + { blankLine: 'always', prev: '*', next: 'return' }, |
| 91 | + { blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' }, |
| 92 | + { blankLine: 'any', prev: ['const', 'let', 'var'], next: ['const', 'let', 'var'] } |
| 93 | + ], |
| 94 | + 'radix': ['warn'], |
| 95 | + 'require-await': 'off', |
| 96 | + 'require-yield': 'warn', |
| 97 | + 'rest-spread-spacing': ['warn', 'never'], |
| 98 | + 'strict': ['warn', 'never'], |
| 99 | + 'unicode-bom': ['warn', 'never'], |
| 100 | + 'use-isnan': 'warn', |
| 101 | + 'valid-typeof': 'warn', |
| 102 | + 'import/first': 'warn', |
| 103 | + 'import/newline-after-import': 'warn', |
| 104 | + 'import/no-absolute-path': 'warn', |
| 105 | + 'import/no-amd': 'warn', |
| 106 | + 'import/no-default-export': 'warn', |
| 107 | + 'import/no-extraneous-dependencies': ['warn', { |
| 108 | + devDependencies: [ |
| 109 | + '**/*.test.ts', |
| 110 | + '**/*.spec.ts', |
| 111 | + 'test/**/*', |
| 112 | + 'scripts/**/*' |
| 113 | + ], |
| 114 | + peerDependencies: true, |
| 115 | + optionalDependencies: false, |
| 116 | + }], |
| 117 | + 'import/no-mutable-exports': 'warn', |
| 118 | + 'import/no-named-default': 'warn', |
| 119 | + 'import/no-self-import': 'warn', |
| 120 | + 'import/order': ['warn', { |
| 121 | + 'groups': ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'], |
| 122 | + 'newlines-between': 'always' |
| 123 | + }], |
| 124 | + '@typescript-eslint/await-thenable': 'error', |
| 125 | + '@typescript-eslint/consistent-type-definitions': ['warn', 'type'], |
| 126 | + '@typescript-eslint/explicit-function-return-type': ['warn', { |
| 127 | + allowExpressions: true, |
| 128 | + allowTypedFunctionExpressions: true, |
| 129 | + }], |
| 130 | + '@typescript-eslint/member-ordering': 'warn', |
| 131 | + '@typescript-eslint/no-array-constructor': 'warn', |
| 132 | + '@typescript-eslint/no-empty-function': 'warn', |
| 133 | + '@typescript-eslint/no-empty-object-type': ['warn', { allowInterfaces: 'with-single-extends' }], |
| 134 | + '@typescript-eslint/no-explicit-any': 'warn', |
| 135 | + '@typescript-eslint/no-floating-promises': 'error', |
| 136 | + '@typescript-eslint/no-for-in-array': 'warn', |
| 137 | + '@typescript-eslint/no-misused-new': 'warn', |
| 138 | + '@typescript-eslint/no-non-null-assertion': 'warn', |
| 139 | + '@typescript-eslint/no-this-alias': 'warn', |
| 140 | + '@typescript-eslint/no-unused-vars': ['warn', { |
| 141 | + argsIgnorePattern: '^_', |
| 142 | + varsIgnorePattern: '^_' |
| 143 | + }], |
| 144 | + '@typescript-eslint/no-use-before-define': 'warn', |
| 145 | + '@typescript-eslint/no-useless-constructor': 'warn', |
| 146 | + '@typescript-eslint/prefer-for-of': 'warn', |
| 147 | + '@typescript-eslint/prefer-includes': 'warn', |
| 148 | + '@typescript-eslint/prefer-readonly': 'warn', |
| 149 | + '@typescript-eslint/prefer-regexp-exec': 'warn', |
| 150 | + '@typescript-eslint/prefer-string-starts-ends-with': 'warn', |
| 151 | + '@typescript-eslint/promise-function-async': 'warn', |
| 152 | + '@typescript-eslint/require-array-sort-compare': 'warn', |
| 153 | + '@typescript-eslint/require-await': 'error', |
| 154 | + }, |
| 155 | + }, |
| 156 | + { |
| 157 | + files: ['**/*.test.ts', '**/*.spec.ts'], |
| 158 | + rules: { |
| 159 | + '@typescript-eslint/no-explicit-any': 'off', |
| 160 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 161 | + 'import/no-extraneous-dependencies': 'off', |
| 162 | + '@typescript-eslint/require-await': 'off', |
| 163 | + }, |
| 164 | + }, |
| 165 | + prettierConfig, |
| 166 | +]; |
0 commit comments