|
| 1 | +const tsParser = require('@typescript-eslint/parser'); |
| 2 | +const js = require('@eslint/js'); |
| 3 | +const globals = require('globals'); |
| 4 | +const ts = require('@typescript-eslint/eslint-plugin'); |
| 5 | +const eslintConfigPrettier = require('eslint-config-prettier'); |
| 6 | +const prettier = require('eslint-plugin-prettier'); |
| 7 | +const stylisticJs = require('@stylistic/eslint-plugin-js'); |
| 8 | +const stylisticTs = require('@stylistic/eslint-plugin-ts'); |
| 9 | +const stylisticPlus = require('@stylistic/eslint-plugin-plus') |
| 10 | + |
| 11 | +module.exports = [ |
| 12 | +{ |
| 13 | + files: [ |
| 14 | + '**/*.ts', |
| 15 | + './src/**/*.ts', |
| 16 | + './test/**/*.ts' |
| 17 | + ], |
| 18 | + plugins: { |
| 19 | + '@typescript-eslint': ts, |
| 20 | + 'prettier': prettier, |
| 21 | + '@stylistic/js': stylisticJs, |
| 22 | + '@stylistic/ts': stylisticTs, |
| 23 | + '@stylistic/plus': stylisticPlus |
| 24 | + }, |
| 25 | + languageOptions: { |
| 26 | + parser: tsParser, |
| 27 | + globals: { |
| 28 | + ...globals.browser, |
| 29 | + }, |
| 30 | + parserOptions: { |
| 31 | + project: ['tsconfig.json'], |
| 32 | + }, |
| 33 | + }, |
| 34 | + rules: { |
| 35 | + ...js.configs.recommended.rules, |
| 36 | + ...ts.configs['stylistic-type-checked'].rules, |
| 37 | + // eslint/js rules |
| 38 | + 'indent': [1, 4], |
| 39 | + 'space-before-function-paren': 0, |
| 40 | + 'prefer-const': 1, |
| 41 | + 'comma-dangle': 0, |
| 42 | + 'keyword-spacing': ['error', { before: true, after: true }], |
| 43 | + 'comma-spacing': ['error', { before: false, after: true }], |
| 44 | + 'indent': 0, |
| 45 | + 'prefer-spread': 1, |
| 46 | + 'eqeqeq': ['error', 'smart'], |
| 47 | + 'no-unexpected-multiline': 0, |
| 48 | + 'no-prototype-builtins': 0, |
| 49 | + 'no-useless-escape': 1, |
| 50 | + 'no-mixed-operators': 1, |
| 51 | + 'no-control-regex': 0, |
| 52 | + 'no-console': 2, |
| 53 | + 'no-var': 2, |
| 54 | + 'no-undef': 0, |
| 55 | + 'no-redeclare': 'error', |
| 56 | + 'no-unused-vars': [ |
| 57 | + 'error', |
| 58 | + { |
| 59 | + 'argsIgnorePattern': '^_', |
| 60 | + 'varsIgnorePattern': '^_', |
| 61 | + 'ignoreRestSiblings': true |
| 62 | + } |
| 63 | + ], |
| 64 | + |
| 65 | + '@stylistic/js/no-multi-spaces': [ 0, { ignoreEOLComments: true } ], |
| 66 | + '@stylistic/js/arrow-spacing': [ 'error', { before: true, after: true } ], |
| 67 | + '@stylistic/js/arrow-parens': [ 'error', 'always' ], |
| 68 | + |
| 69 | + '@stylistic/js/block-spacing': [ 'error', 'always' ], |
| 70 | + '@stylistic/ts/block-spacing': [ 'error', 'always' ], |
| 71 | + |
| 72 | + '@stylistic/js/brace-style': [ 'error', 'allman', { allowSingleLine: true } ], |
| 73 | + '@stylistic/ts/brace-style': [ 'error', 'allman', { allowSingleLine: true } ], |
| 74 | + |
| 75 | + '@stylistic/js/comma-dangle': [ 'error', 'never' ], |
| 76 | + '@stylistic/ts/comma-dangle': [ 'error', 'never' ], |
| 77 | + |
| 78 | + '@stylistic/js/comma-spacing': [ 'error', { before: false, after: true }], |
| 79 | + '@stylistic/ts/comma-spacing': [ 'error', { before: false, after: true }], |
| 80 | + |
| 81 | + '@stylistic/js/keyword-spacing': [ 'error', { |
| 82 | + before: true, |
| 83 | + after: true, |
| 84 | + 'overrides': |
| 85 | + { |
| 86 | + return: { before: true, after: true }, |
| 87 | + throw: { before: true, after: true }, |
| 88 | + case: { before: true, after: true }, |
| 89 | + as: { before: true, after: true }, |
| 90 | + if: { before: true, after: true }, |
| 91 | + for: { before: true, after: true }, |
| 92 | + while: { before: true, after: true }, |
| 93 | + static: { before: true, after: true } |
| 94 | + }, |
| 95 | + }], |
| 96 | + |
| 97 | + '@stylistic/ts/keyword-spacing': ['error', { |
| 98 | + before: true, |
| 99 | + after: true, |
| 100 | + 'overrides': |
| 101 | + { |
| 102 | + return: { before: true, after: true }, |
| 103 | + throw: { before: true, after: true }, |
| 104 | + case: { before: true, after: true }, |
| 105 | + as: { before: true, after: true }, |
| 106 | + if: { before: true, after: true }, |
| 107 | + for: { before: true, after: true }, |
| 108 | + while: { before: true, after: true }, |
| 109 | + static: { before: true, after: true } |
| 110 | + }, |
| 111 | + }], |
| 112 | + |
| 113 | + '@stylistic/js/computed-property-spacing': ['error', 'always'], |
| 114 | + '@stylistic/js/eol-last': ['error', 'always'], |
| 115 | + '@stylistic/js/jsx-quotes': ['error', 'prefer-single'], |
| 116 | + '@stylistic/js/linebreak-style': ['error', 'unix'], |
| 117 | + '@stylistic/js/no-mixed-spaces-and-tabs': ['error'], |
| 118 | + '@stylistic/js/no-tabs': ['error'], |
| 119 | + '@stylistic/js/no-trailing-spaces': ['error', { 'skipBlankLines': true, 'ignoreComments': true }], |
| 120 | + '@stylistic/js/no-whitespace-before-property': ['error'], |
| 121 | + |
| 122 | + '@stylistic/js/object-curly-spacing': ['error', 'always'], |
| 123 | + '@stylistic/ts/object-curly-spacing': ['error', 'always'], |
| 124 | + |
| 125 | + '@stylistic/js/quote-props': ['error', 'as-needed'], |
| 126 | + '@stylistic/ts/quote-props': ['error', 'as-needed'], |
| 127 | + |
| 128 | + '@stylistic/js/quotes': ['error', 'single', { 'allowTemplateLiterals': true }], |
| 129 | + '@stylistic/ts/quotes': ['error', 'single', { 'allowTemplateLiterals': true }], |
| 130 | + |
| 131 | + '@stylistic/js/semi': ['error', 'never'], |
| 132 | + '@stylistic/ts/semi': ['error', 'never'], |
| 133 | + |
| 134 | + '@stylistic/js/space-in-parens': ['error', 'always'], |
| 135 | + |
| 136 | + '@stylistic/js/space-infix-ops': ['error'], |
| 137 | + '@stylistic/ts/space-infix-ops': ['error'], |
| 138 | + |
| 139 | + '@stylistic/js/spaced-comment': ['error', 'always'], |
| 140 | + '@stylistic/js/template-curly-spacing': ['error', 'always'], |
| 141 | + '@stylistic/js/template-tag-spacing': ['error', 'always'], |
| 142 | + '@stylistic/js/wrap-iife': [2, "inside", { functionPrototypeMethods: true }], |
| 143 | + |
| 144 | + '@stylistic/plus/type-named-tuple-spacing': ["error"], |
| 145 | + '@stylistic/plus/type-generic-spacing': ["error"], |
| 146 | + |
| 147 | + // 'prettier/prettier': ['error'], |
| 148 | + // @typescript-eslint rules |
| 149 | + '@typescript-eslint/prefer-nullish-coalescing': 'off' // require `strictNullChecks` |
| 150 | + }, |
| 151 | +}]; |
0 commit comments