Open rchl opened 4 years ago
Note that I'm not sure how and if that will affect typescript script
blocks in Vue components...
Also, the current use of typescript plugin is rather minimal.
Only the typescript parser from typescript plugin is enabled but otherwise, no rules are utilized (besides one). It would make sense to at least extend the base config from that plugin. That would also take care of setting the parserOptions
so that it wouldn't have to be done in this package itself.
EDIT: Actually extending base configuration from typescript plugin wouldn't work as that would override the parser and break vue plugin. So rules would need to be copied over and scoped to .ts/.tsx extensions instead.
And typescript config doesn't even follow base Nuxt rules like no semi and single quotes (amongst others). Is that on purpose to diverge from JS/Vue style used in base config?
Ran into this recently myself. Ended up having to set checkJs to true in my tsconfig and then turn off strict and allow implicit any. And then add types to global.d.ts to make it not complain about some things.
Ultimately our JS code is a lot better now and intellisense is better, but it's not currently possible to isolated js and ts in the linter using the auto generated nuxt eslint config.
It seems to favor only using js, or only using ts and doesn't favor mixed mode for nuxt 2 migrations from js on nuxt 2 to typescript and js on nuxt 3.
But the way I did it works, if you can go that route.
Fortunately this is a really easy module to fork and then refer to by git url :).
In: https://github.com/nuxt/eslint-config/blob/dc55bbf218c8627d3c4ef73656a32730dd2a9d3c/packages/eslint-config-typescript/index.js#L1-L12
all typescript-specific settings should be in an override block and scoped to
*.ts
extension:One of the many reasons why it should be so is that when enabling some typescript rules, like
@typescript-eslint/no-unused-vars
, you are supposed to disable eslint's ownno-unused-vars
rule (see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md#options) and you don't want to do that in general, only for *.ts.Also, current way overrides
parserOptions.parser
which it would ideally not do for all file types since other might want to usebabel-parser
rather (although I haven't found specific issues with current solution).