|
| 1 | +const [OFF, WARN, ERROR] = [0, 1, 2] |
| 2 | +const [ALWAYS, NEVER] = [`always`, `never`] |
| 3 | + |
| 4 | +/** |
| 5 | + * @typedef ESLintAdvancedLinterOptions |
| 6 | + * @property {'@typescript-eslint-parser'} parser |
| 7 | + * @property {import('@typescript-eslint/parser').ParserOptions} parserOptions |
| 8 | + * |
| 9 | + * @typedef {import('eslint/lib/shared/types').ConfigData} ESLintBaseLinterOptions |
| 10 | + * @typedef {ESLintBaseLinterOptions & ESLintAdvancedLinterOptions} ESLintOptions |
| 11 | + */ |
| 12 | + |
| 13 | +/** @type {ESLintOptions} */ |
| 14 | +module.exports = { |
| 15 | + env: { |
| 16 | + es6: true, |
| 17 | + node: true |
| 18 | + }, |
| 19 | + extends: [ |
| 20 | + 'eslint:recommended', |
| 21 | + 'plugin:node/recommended', |
| 22 | + 'plugin:import/typescript', |
| 23 | + 'plugin:eslint-comments/recommended', |
| 24 | + 'plugin:@typescript-eslint/recommended', |
| 25 | + 'plugin:prettier/recommended' |
| 26 | + ], |
| 27 | + overrides: [ |
| 28 | + { |
| 29 | + files: [`*.?({m,c})ts`], |
| 30 | + rules: { |
| 31 | + '@typescript-eslint/explicit-function-return-type': [ |
| 32 | + ERROR, |
| 33 | + { |
| 34 | + allowExpressions: true, |
| 35 | + allowHigherOrderFunctions: false |
| 36 | + } |
| 37 | + ], |
| 38 | + '@typescript-eslint/explicit-member-accessibility': [ERROR], |
| 39 | + '@typescript-eslint/explicit-module-boundary-types': [ |
| 40 | + ERROR, |
| 41 | + { |
| 42 | + allowArgumentsExplicitlyTypedAsAny: true |
| 43 | + } |
| 44 | + ] |
| 45 | + } |
| 46 | + } |
| 47 | + ], |
| 48 | + parser: `@typescript-eslint/parser`, |
| 49 | + parserOptions: { |
| 50 | + ecmaFeatures: { |
| 51 | + experimentalObjectRestSpread: true |
| 52 | + }, |
| 53 | + ecmaVersion: 2022, |
| 54 | + project: `tsconfig.eslint.json`, |
| 55 | + sourceType: `module`, |
| 56 | + tsconfigRootDir: __dirname |
| 57 | + }, |
| 58 | + plugins: [ |
| 59 | + `@typescript-eslint`, |
| 60 | + `node`, |
| 61 | + `simple-import-sort`, |
| 62 | + `sort-keys-fix`, |
| 63 | + `import`, |
| 64 | + `prettier` |
| 65 | + ], |
| 66 | + root: true, |
| 67 | + rules: { |
| 68 | + '@typescript-eslint/array-type': [ |
| 69 | + ERROR, |
| 70 | + { |
| 71 | + default: `array-simple`, |
| 72 | + readonly: `generic` |
| 73 | + } |
| 74 | + ], |
| 75 | + '@typescript-eslint/class-literal-property-style': [ERROR, `fields`], |
| 76 | + '@typescript-eslint/consistent-type-assertions': [ERROR], |
| 77 | + '@typescript-eslint/consistent-type-definitions': [ERROR, `interface`], |
| 78 | + '@typescript-eslint/consistent-type-imports': [ |
| 79 | + ERROR, |
| 80 | + { |
| 81 | + disallowTypeAnnotations: false |
| 82 | + } |
| 83 | + ], |
| 84 | + '@typescript-eslint/explicit-function-return-type': [OFF], |
| 85 | + '@typescript-eslint/explicit-member-accessibility': [OFF], |
| 86 | + '@typescript-eslint/explicit-module-boundary-types': [OFF], |
| 87 | + '@typescript-eslint/member-delimiter-style': [ |
| 88 | + ERROR, |
| 89 | + { |
| 90 | + multiline: { |
| 91 | + delimiter: `none`, |
| 92 | + requireLast: false |
| 93 | + } |
| 94 | + } |
| 95 | + ], |
| 96 | + '@typescript-eslint/member-ordering': [ERROR], |
| 97 | + /** {@link https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md Docs} */ |
| 98 | + '@typescript-eslint/naming-convention': [ |
| 99 | + ERROR, |
| 100 | + { |
| 101 | + format: [`camelCase`], |
| 102 | + selector: `default` |
| 103 | + }, |
| 104 | + { |
| 105 | + format: [`camelCase`, `PascalCase`, `UPPER_CASE`], |
| 106 | + selector: `variable` |
| 107 | + }, |
| 108 | + { |
| 109 | + format: [`camelCase`, `PascalCase`], |
| 110 | + selector: `enumMember` |
| 111 | + }, |
| 112 | + { |
| 113 | + format: [`PascalCase`], |
| 114 | + prefix: [`is`, `should`, `has`, `can`, `did`, `will`], |
| 115 | + selector: `variable`, |
| 116 | + types: [`boolean`] |
| 117 | + }, |
| 118 | + { |
| 119 | + format: [`camelCase`], |
| 120 | + leadingUnderscore: `allow`, |
| 121 | + selector: `parameter` |
| 122 | + }, |
| 123 | + { |
| 124 | + format: [`camelCase`, `PascalCase`, `UPPER_CASE`], |
| 125 | + selector: `classProperty` |
| 126 | + }, |
| 127 | + { |
| 128 | + format: [`camelCase`, `PascalCase`, `UPPER_CASE`], |
| 129 | + selector: `objectLiteralProperty` |
| 130 | + }, |
| 131 | + { |
| 132 | + format: [`StrictPascalCase`], |
| 133 | + selector: `typeLike` |
| 134 | + } |
| 135 | + ], |
| 136 | + |
| 137 | + '@typescript-eslint/no-base-to-string': [ERROR], |
| 138 | + '@typescript-eslint/no-confusing-non-null-assertion': [ERROR], |
| 139 | + '@typescript-eslint/no-confusing-void-expression': [ |
| 140 | + ERROR, |
| 141 | + { |
| 142 | + ignoreArrowShorthand: true, |
| 143 | + ignoreVoidOperator: true |
| 144 | + } |
| 145 | + ], |
| 146 | + '@typescript-eslint/no-dynamic-delete': [WARN], |
| 147 | + '@typescript-eslint/no-explicit-any': [WARN], |
| 148 | + '@typescript-eslint/no-extraneous-class': [ |
| 149 | + ERROR, |
| 150 | + { |
| 151 | + allowStaticOnly: true |
| 152 | + } |
| 153 | + ], |
| 154 | + '@typescript-eslint/no-inferrable-types': [ |
| 155 | + ERROR, |
| 156 | + { |
| 157 | + ignoreParameters: true |
| 158 | + } |
| 159 | + ], |
| 160 | + '@typescript-eslint/no-invalid-void-type': [ERROR], |
| 161 | + '@typescript-eslint/no-meaningless-void-operator': [ERROR], |
| 162 | + '@typescript-eslint/no-namespace': [OFF], |
| 163 | + '@typescript-eslint/no-non-null-assertion': [OFF], |
| 164 | + // '@typescript-eslint/no-non-null-asserted-nullish-coalescing': [ERROR], |
| 165 | + '@typescript-eslint/no-require-imports': [ERROR], |
| 166 | + // '@typescript-eslint/no-type-alias': [ |
| 167 | + // ERROR, |
| 168 | + // { |
| 169 | + // allowAliases: 'in-unions-and-intersections', |
| 170 | + // allowCallbacks: 'always', |
| 171 | + // allowConditionalTypes: 'always', |
| 172 | + // allowLiterals: 'in-unions-and-intersections', |
| 173 | + // allowMappedTypes: 'in-unions-and-intersections', |
| 174 | + // allowTupleTypes: 'in-unions', |
| 175 | + // allowGenerics: 'always' |
| 176 | + // } |
| 177 | + // ], |
| 178 | + '@typescript-eslint/no-unnecessary-boolean-literal-compare': [ |
| 179 | + ERROR, |
| 180 | + { |
| 181 | + allowComparingNullableBooleansToFalse: false, |
| 182 | + allowComparingNullableBooleansToTrue: false |
| 183 | + } |
| 184 | + ], |
| 185 | + '@typescript-eslint/no-unnecessary-condition': [ERROR], |
| 186 | + '@typescript-eslint/prefer-readonly': [ERROR], |
| 187 | + 'eslint-comments/no-use': [ |
| 188 | + ERROR, |
| 189 | + { |
| 190 | + allow: [ |
| 191 | + `eslint-disable`, |
| 192 | + `eslint-disable-line`, |
| 193 | + `eslint-disable-next-line`, |
| 194 | + `eslint-enable` |
| 195 | + ] |
| 196 | + } |
| 197 | + ], |
| 198 | + 'eslint-comments/disable-enable-pair': [OFF], |
| 199 | + 'import/first': [ERROR], |
| 200 | + 'import/newline-after-import': [ERROR], |
| 201 | + 'import/no-absolute-path': [ERROR], |
| 202 | + 'import/no-amd': [ERROR], |
| 203 | + 'import/no-commonjs': [ERROR], |
| 204 | + // 'import/no-default-export': [ERROR], |
| 205 | + 'import/no-deprecated': [ERROR], |
| 206 | + 'import/no-duplicates': [ERROR], |
| 207 | + // 'import/no-anonymous-default-export': [ |
| 208 | + // ERROR, |
| 209 | + // { |
| 210 | + // allowArray: true, |
| 211 | + // allowArrayFunction: true, |
| 212 | + // allowAnonymousFunction: true |
| 213 | + // } |
| 214 | + // ], |
| 215 | + 'import/no-extraneous-dependencies': [ |
| 216 | + ERROR, |
| 217 | + { |
| 218 | + devDependencies: [`**/*.test.?([mc])ts`] |
| 219 | + } |
| 220 | + ], |
| 221 | + 'import/no-mutable-exports': [ERROR], |
| 222 | + // 'import/no-namespace': [WARN], |
| 223 | + // 'import/order': [ERROR, { 'newlines-between': 'always' }], |
| 224 | + 'no-tabs': [ERROR, { allowIndentationTabs: false }], |
| 225 | + 'node/no-missing-import': [OFF], |
| 226 | + 'node/no-unpublished-import': [OFF], |
| 227 | + 'node/no-unsupported-features/es-syntax': [OFF], |
| 228 | + 'node/prefer-promises/dns': [ERROR], |
| 229 | + 'node/prefer-promises/fs': [ERROR], |
| 230 | + 'simple-import-sort/exports': [ERROR], |
| 231 | + 'simple-import-sort/imports': [ERROR], |
| 232 | + 'sort-keys-fix/sort-keys-fix': [ERROR, `asc`, { natural: true }] |
| 233 | + } |
| 234 | +} |
0 commit comments