Skip to content

Commit 60b143b

Browse files
committed
feat: apply no-var, prefer-const, prefer-reset-params, prefer-spread globally
1 parent 9d2bc08 commit 60b143b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

recommended.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,23 @@ module.exports = {
99

1010
rules: {
1111
// this rule, if on, would require explicit return type on the `render` function
12-
'@typescript-eslint/explicit-function-return-type': 'off'
12+
'@typescript-eslint/explicit-function-return-type': 'off',
13+
14+
// The following rules are enabled in an `overrides` field in the
15+
// `@typescript-eslint/recommended` ruleset, only turned on for TypeScript source modules
16+
// <https://github.com/typescript-eslint/typescript-eslint/blob/cb2d44650d27d8b917e8ce19423245b834db29d2/packages/eslint-plugin/src/configs/eslint-recommended.ts#L27-L30>
17+
18+
// But as ESLint cannot precisely target `<script lang="ts">` blocks and skip normal `<script>`s,
19+
// no TypeScript code in `.vue` files would be checked against these rules.
20+
21+
// So we now enable them globally.
22+
// That would also check plain JavaScript files, which diverges a little from
23+
// the original intention of the `@typescript-eslint/recommended` rulset.
24+
// But it should be mostly fine.
25+
'no-var': 'error', // ts transpiles let/const to var, so no need for vars any more
26+
'prefer-const': 'error', // ts provides better types with const
27+
'prefer-rest-params': 'error', // ts provides better types with rest args over arguments
28+
'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply
1329
},
1430

1531
overrides: [

0 commit comments

Comments
 (0)