- Notifications
You must be signed in to change notification settings - Fork37
Add recommended-type-checked#68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
module.exports = { | ||
extends: [ | ||
require.resolve('./index'), | ||
'plugin:@typescript-eslint/recommended-type-checked' | ||
], | ||
// the ts-eslint recommended ruleset sets the parser so we need to set it back | ||
parser: require.resolve('vue-eslint-parser'), | ||
parserOptions: { | ||
parser: require('typescript-eslint-parser-for-extra-files') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. @segevfiner Curiously, what problems were you running into that required this dependency? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. The rules that use type checking see the linked issues in the PR description. | ||
}, | ||
rules: { | ||
// this rule, if on, would require explicit return type on the `render` function | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
// The following rules are enabled in an `overrides` field in the | ||
// `@typescript-eslint/recommended` ruleset, only turned on for TypeScript source modules | ||
// <https://github.com/typescript-eslint/typescript-eslint/blob/cb2d44650d27d8b917e8ce19423245b834db29d2/packages/eslint-plugin/src/configs/eslint-recommended.ts#L27-L30> | ||
// But as ESLint cannot precisely target `<script lang="ts">` blocks and skip normal `<script>`s, | ||
// no TypeScript code in `.vue` files would be checked against these rules. | ||
// So we now enable them globally. | ||
// That would also check plain JavaScript files, which diverges a little from | ||
// the original intention of the `@typescript-eslint/recommended` rulset. | ||
// But it should be mostly fine. | ||
'no-var': 'error', // ts transpiles let/const to var, so no need for vars any more | ||
'prefer-const': 'error', // ts provides better types with const | ||
'prefer-rest-params': 'error', // ts provides better types with rest args over arguments | ||
'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['shims-tsx.d.ts'], | ||
rules: { | ||
'@typescript-eslint/no-empty-interface': 'off', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-unused-vars': 'off' | ||
} | ||
}, | ||
{ | ||
files: ['*.js', '*.cjs'], | ||
rules: { | ||
// in plain CommonJS modules, you can't use `import foo = require('foo')` to pass this rule, so it has to be disabled | ||
'@typescript-eslint/no-var-requires': 'off' | ||
} | ||
} | ||
] | ||
} |