sveltejs / eslint-plugin-svelte

ESLint plugin for Svelte using AST
https://sveltejs.github.io/eslint-plugin-svelte/
MIT License
276 stars 29 forks source link

chore: Use eslint types for exported configs #789

Closed KuSh closed 1 week ago

KuSh commented 2 weeks ago

This allows svelte configs to pass typescript-eslint type checking

Actually when migrating a project to eslint 9 I get typescript 2345 error

Argument of type '{ plugins: { readonly svelte: Plugin; }; files?: undefined; languageOptions?: undefined; rules?: undefined; processor?: undefined; } | { files: string[]; languageOptions: { parser: any; }; rules: { ...; }; processor: string; plugins?: undefined; } | { ...; }' is not assignable to parameter of type 'ConfigWithExtends'.
  Type '{ files: string[]; languageOptions: { parser: any; }; rules: { 'no-inner-declarations': string; 'no-self-assign': string; 'svelte/comment-directive': string; 'svelte/system': string; }; processor: string; plugins?: undefined; }' is not assignable to type 'ConfigWithExtends'.
    Types of property 'rules' are incompatible.
      Type '{ 'no-inner-declarations': string; 'no-self-assign': string; 'svelte/comment-directive': string; 'svelte/system': string; }' is not assignable to type 'Partial<Record<string, RuleEntry>>'.
        Property ''no-inner-declarations'' is incompatible with index signature.
          Type 'string' is not assignable to type 'RuleEntry | undefined'. ts(2345)
---
(property) 'flat/recommended': ({
    plugins: {
        readonly svelte: ESLint.Plugin;
    };
    files?: undefined;
    languageOptions?: undefined;
    rules?: undefined;
    processor?: undefined;
} | {
    files: string[];
    languageOptions: {
        parser: any;
    };
    rules: {
        ...;
    };
    processor: string;
    plugins?: undefined;
} | {
    ...;
})[]

Using const to define rule levels fixe the problem

changeset-bot[bot] commented 2 weeks ago

🦋 Changeset detected

Latest commit: 09efac121f9dfa87b297230e96d5b10f3856c34c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | -------------------- | ----- | | eslint-plugin-svelte | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

baseballyama commented 1 week ago

@KuSh Thank you for the update! Can you add the changeset? I think this can be recognize as fix.

KuSh commented 1 week ago

@KuSh Thank you for the update! Can you add the changeset? I think this can be recognize as fix.

Done !