|
| 1 | +module.exports = { |
| 2 | + extends: [ |
| 3 | + require.resolve('./index'), |
| 4 | + 'plugin:@typescript-eslint/recommended-type-checked' |
| 5 | + ], |
| 6 | + |
| 7 | + // the ts-eslint recommended ruleset sets the parser so we need to set it back |
| 8 | + parser: require.resolve('vue-eslint-parser'), |
| 9 | + |
| 10 | + parserOptions: { |
| 11 | + parser: require('typescript-eslint-parser-for-extra-files') |
| 12 | + }, |
| 13 | + |
| 14 | + rules: { |
| 15 | + // this rule, if on, would require explicit return type on the `render` function |
| 16 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 17 | + |
| 18 | + // The following rules are enabled in an `overrides` field in the |
| 19 | + // `@typescript-eslint/recommended` ruleset, only turned on for TypeScript source modules |
| 20 | + // <https://github.com/typescript-eslint/typescript-eslint/blob/cb2d44650d27d8b917e8ce19423245b834db29d2/packages/eslint-plugin/src/configs/eslint-recommended.ts#L27-L30> |
| 21 | + |
| 22 | + // But as ESLint cannot precisely target `<script lang="ts">` blocks and skip normal `<script>`s, |
| 23 | + // no TypeScript code in `.vue` files would be checked against these rules. |
| 24 | + |
| 25 | + // So we now enable them globally. |
| 26 | + // That would also check plain JavaScript files, which diverges a little from |
| 27 | + // the original intention of the `@typescript-eslint/recommended` rulset. |
| 28 | + // But it should be mostly fine. |
| 29 | + 'no-var': 'error', // ts transpiles let/const to var, so no need for vars any more |
| 30 | + 'prefer-const': 'error', // ts provides better types with const |
| 31 | + 'prefer-rest-params': 'error', // ts provides better types with rest args over arguments |
| 32 | + 'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply |
| 33 | + }, |
| 34 | + |
| 35 | + overrides: [ |
| 36 | + { |
| 37 | + files: ['shims-tsx.d.ts'], |
| 38 | + rules: { |
| 39 | + '@typescript-eslint/no-empty-interface': 'off', |
| 40 | + '@typescript-eslint/no-explicit-any': 'off', |
| 41 | + '@typescript-eslint/no-unused-vars': 'off' |
| 42 | + } |
| 43 | + }, |
| 44 | + { |
| 45 | + files: ['*.js', '*.cjs'], |
| 46 | + rules: { |
| 47 | + // in plain CommonJS modules, you can't use `import foo = require('foo')` to pass this rule, so it has to be disabled |
| 48 | + '@typescript-eslint/no-var-requires': 'off' |
| 49 | + } |
| 50 | + } |
| 51 | + ] |
| 52 | +} |
0 commit comments