|
| 1 | +/* eslint-disable no-console */ |
| 2 | + |
| 3 | +module.exports = { |
| 4 | + plugins: ['@typescript-eslint', 'jest', 'import', 'eslint-comments'], |
| 5 | + env: { |
| 6 | + browser: true, |
| 7 | + node: true, |
| 8 | + }, |
| 9 | + extends: [ |
| 10 | + 'eslint:recommended', |
| 11 | + 'plugin:@typescript-eslint/eslint-recommended', |
| 12 | + 'plugin:@typescript-eslint/recommended', |
| 13 | + 'plugin:@typescript-eslint/recommended-requiring-type-checking', |
| 14 | + 'prettier/@typescript-eslint', |
| 15 | + ], |
| 16 | + parser: '@typescript-eslint/parser', |
| 17 | + parserOptions: { |
| 18 | + project: './tsconfig.eslint.json', |
| 19 | + tsconfigRootDir: __dirname, |
| 20 | + ecmaVersion: 2019, |
| 21 | + ecmaFeatures: { |
| 22 | + jsx: false, |
| 23 | + }, |
| 24 | + }, |
| 25 | + overrides: [ |
| 26 | + { |
| 27 | + files: ['**/*.test.ts'], |
| 28 | + extends: ['plugin:jest/recommended'], |
| 29 | + env: { |
| 30 | + 'jest/globals': true, |
| 31 | + }, |
| 32 | + rules: { |
| 33 | + 'jest/no-disabled-tests': 'warn', |
| 34 | + 'jest/no-focused-tests': 'error', |
| 35 | + 'jest/no-alias-methods': 'error', |
| 36 | + 'jest/no-identical-title': 'error', |
| 37 | + 'jest/no-jasmine-globals': 'error', |
| 38 | + 'jest/no-jest-import': 'error', |
| 39 | + 'jest/no-test-prefixes': 'error', |
| 40 | + 'jest/no-test-return-statement': 'error', |
| 41 | + 'jest/prefer-to-have-length': 'warn', |
| 42 | + 'jest/prefer-spy-on': 'error', |
| 43 | + 'jest/valid-expect': 'error', |
| 44 | + '@typescript-eslint/ban-ts-ignore': 'off', |
| 45 | + }, |
| 46 | + }, |
| 47 | + ], |
| 48 | + rules: { |
| 49 | + 'no-var': 'error', |
| 50 | + 'prefer-const': 'error', |
| 51 | + 'no-trailing-spaces': 'error', |
| 52 | + radix: 'error', |
| 53 | + 'no-multiple-empty-lines': 'error', |
| 54 | + |
| 55 | + '@typescript-eslint/no-unused-vars': [ |
| 56 | + 'error', |
| 57 | + {vars: 'all', args: 'none', varsIgnorePattern: '[iI]gnored'}, |
| 58 | + ], |
| 59 | + '@typescript-eslint/consistent-type-definitions': ['warn', 'interface'], |
| 60 | + '@typescript-eslint/prefer-optional-chain': 'error', |
| 61 | + '@typescript-eslint/prefer-nullish-coalescing': 'warn', |
| 62 | + |
| 63 | + '@typescript-eslint/unbound-method': [ |
| 64 | + 'error', |
| 65 | + { |
| 66 | + ignoreStatic: true, |
| 67 | + }, |
| 68 | + ], |
| 69 | + |
| 70 | + '@typescript-eslint/no-explicit-any': 'error', |
| 71 | + '@typescript-eslint/no-non-null-assertion': 'error', |
| 72 | + // '@typescript-eslint/no-var-requires': 'off', |
| 73 | + '@typescript-eslint/no-use-before-define': 'off', |
| 74 | + '@typescript-eslint/unbound-method': 'off', |
| 75 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 76 | + '@typescript-eslint/no-parameter-properties': 'off', |
| 77 | + |
| 78 | + // some of these don't work as expected: |
| 79 | + '@typescript-eslint/explicit-module-boundary-types': 'off', |
| 80 | + '@typescript-eslint/no-unsafe-return': 'off', |
| 81 | + '@typescript-eslint/no-unsafe-call': 'off', |
| 82 | + '@typescript-eslint/ban-ts-comment': 'off', |
| 83 | + '@typescript-eslint/restrict-template-expressions': 'off', |
| 84 | + '@typescript-eslint/no-unsafe-assignment': 'off', |
| 85 | + '@typescript-eslint/no-unsafe-member-access': 'off', |
| 86 | + // '@typescript-eslint/triple-slash-reference': 'off', |
| 87 | + |
| 88 | + // eslint base |
| 89 | + // |
| 90 | + |
| 91 | + 'comma-dangle': ['error', 'always-multiline'], |
| 92 | + curly: ['error', 'multi-line'], |
| 93 | + 'no-mixed-operators': 'off', |
| 94 | + 'no-console': 'error', |
| 95 | + 'no-process-exit': 'error', |
| 96 | + |
| 97 | + // |
| 98 | + // eslint-plugin-eslint-comment |
| 99 | + // |
| 100 | + |
| 101 | + // require a eslint-enable comment for every eslint-disable comment |
| 102 | + 'eslint-comments/disable-enable-pair': [ |
| 103 | + 'error', |
| 104 | + { |
| 105 | + allowWholeFile: true, |
| 106 | + }, |
| 107 | + ], |
| 108 | + // disallow a eslint-enable comment for multiple eslint-disable comments |
| 109 | + 'eslint-comments/no-aggregating-enable': 'error', |
| 110 | + // disallow duplicate eslint-disable comments |
| 111 | + 'eslint-comments/no-duplicate-disable': 'error', |
| 112 | + // disallow eslint-disable comments without rule names |
| 113 | + 'eslint-comments/no-unlimited-disable': 'error', |
| 114 | + // disallow unused eslint-disable comments |
| 115 | + 'eslint-comments/no-unused-disable': 'error', |
| 116 | + // disallow unused eslint-enable comments |
| 117 | + 'eslint-comments/no-unused-enable': 'error', |
| 118 | + // disallow ESLint directive-comments |
| 119 | + 'eslint-comments/no-use': [ |
| 120 | + 'error', |
| 121 | + { |
| 122 | + allow: [ |
| 123 | + 'eslint-disable', |
| 124 | + 'eslint-disable-line', |
| 125 | + 'eslint-disable-next-line', |
| 126 | + 'eslint-enable', |
| 127 | + ], |
| 128 | + }, |
| 129 | + ], |
| 130 | + |
| 131 | + // |
| 132 | + // eslint-plugin-import |
| 133 | + // |
| 134 | + |
| 135 | + // disallow non-import statements appearing before import statements |
| 136 | + 'import/first': 'error', |
| 137 | + // Require a newline after the last import/require in a group |
| 138 | + 'import/newline-after-import': 'error', |
| 139 | + // Forbid import of modules using absolute paths |
| 140 | + 'import/no-absolute-path': 'error', |
| 141 | + // disallow AMD require/define |
| 142 | + 'import/no-amd': 'error', |
| 143 | + // forbid default exports |
| 144 | + 'import/no-default-export': 'off', |
| 145 | + // Forbid the use of extraneous packages |
| 146 | + 'import/no-extraneous-dependencies': [ |
| 147 | + 'error', |
| 148 | + { |
| 149 | + devDependencies: true, |
| 150 | + peerDependencies: true, |
| 151 | + optionalDependencies: false, |
| 152 | + }, |
| 153 | + ], |
| 154 | + // Forbid mutable exports |
| 155 | + 'import/no-mutable-exports': 'error', |
| 156 | + // Prevent importing the default as if it were named |
| 157 | + 'import/no-named-default': 'error', |
| 158 | + // Prohibit named exports |
| 159 | + 'import/no-named-export': 'off', // we want everything to be a named export |
| 160 | + // Forbid a module from importing itself |
| 161 | + 'import/no-self-import': 'error', |
| 162 | + // Require modules with a single export to use a default export |
| 163 | + 'import/prefer-default-export': 'off', // we want everything to be named |
| 164 | + }, |
| 165 | +} |
0 commit comments