Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scope typescript settings to *.ts files #82

Open
rchl opened this issue Feb 19, 2020 · 3 comments
Open

Scope typescript settings to *.ts files #82

rchl opened this issue Feb 19, 2020 · 3 comments
Labels
enhancement New feature or request nuxt2-legacy Issues related to the legacy Nuxt 2 eslint config

Comments

@rchl
Copy link

rchl commented Feb 19, 2020

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:

    overrides: [
        {
            files: ['*.ts'],
            plugins: ['@typescript-eslint'],
            parserOptions: {
              parser: '@typescript-eslint/parser'
            },
            rules: {
              '@typescript-eslint/no-unused-vars': ['error', { args: 'all', argsIgnorePattern: '^_' }]
            }
    ],

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 own no-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 use babel-parser rather (although I haven't found specific issues with current solution).

@rchl
Copy link
Author

rchl commented Feb 19, 2020

Note that I'm not sure how and if that will affect typescript script blocks in Vue components...

@manniL manniL added the enhancement New feature or request label Apr 2, 2020
@rchl
Copy link
Author

rchl commented Jun 3, 2020

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.

@rchl
Copy link
Author

rchl commented Jun 3, 2020

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?

@antfu antfu added the nuxt2-legacy Issues related to the legacy Nuxt 2 eslint config label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request nuxt2-legacy Issues related to the legacy Nuxt 2 eslint config
Projects
None yet
Development

No branches or pull requests

3 participants