eslint-plugin-svelte3 icon indicating copy to clipboard operation
eslint-plugin-svelte3 copied to clipboard

Not able to use type-aware rules (setting Eslint parserOptions.project turns off all linting in Svelte files)

Open mckravchyk opened this issue 4 years ago • 3 comments

When I define parserOptions.project Eslint won't lint Svelte files.

I think this may be due to the fact that when parserOptions.project are set, Eslint will only lint files in the scope of tsconfig.json - which probably excludes .svelte files;

I was able to apply an override for .svelte files (project: false) but I can't use type-aware rules in .svelte files - which require the parser to work.

As an example, @typescript-eslint/no-floating-promises is such rule.

v3.2.1

mckravchyk avatar Sep 20 '21 06:09 mckravchyk

See also https://github.com/typescript-eslint/typescript-eslint/issues/3174#issuecomment-797334643

JounQin avatar Sep 24 '21 05:09 JounQin

Maybe it helps somebody else but for SvelteKit it seems like I got it working with https://github.com/mohe2015/sveltekit-advanced-typescript/commit/98c42be37363ee000d61b5e829d0ebab3b254e6e

mohe2015 avatar Oct 04 '21 20:10 mohe2015

I'm having this same problem. @mohe2015's solution of adding extraFileExtensions: ['.svelte'] to parserOptions resulted in linting errors in .svelte files which should not apply to Svelte syntax. So I disabled the corresponding rules for .svelte files like so:

overrides: [
  {
    files: ['*.svelte'],
    processor: 'svelte3/svelte3',
    rules: {
      "import/no-mutable-exports": 0,
      "no-multiple-empty-lines": 0,
    }
  }
],

Still, this feels like a hack. Is there a better solution?

DePasqualeOrg avatar May 24 '22 00:05 DePasqualeOrg