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

chore: Use eslint types for exported configs #789

Merged
merged 3 commits into from
Jun 19, 2024
Merged

Conversation

KuSh
Copy link
Contributor

@KuSh KuSh commented Jun 15, 2024

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

This allows svelte configs to pass typescript-eslint type checking
Copy link

changeset-bot bot commented Jun 15, 2024

🦋 Changeset detected

Latest commit: 09efac1

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

@KuSh KuSh changed the title chore: Use const in rules configs chore: Use eslint types for configs Jun 18, 2024
@KuSh KuSh force-pushed the main branch 2 times, most recently from 6a22f0f to 49955bf Compare June 18, 2024 11:43
@baseballyama
Copy link
Member

baseballyama commented Jun 18, 2024

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

@KuSh
Copy link
Contributor Author

KuSh commented Jun 18, 2024

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

Done !

@KuSh KuSh changed the title chore: Use eslint types for configs chore: Use eslint types for exported configs Jun 18, 2024
Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@ota-meshi ota-meshi merged commit 0bc17df into sveltejs:main Jun 19, 2024
13 checks passed
ota-meshi pushed a commit that referenced this pull request Jun 24, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## [email protected]

### Minor Changes

- [#802](#802)
[`be64d36`](be64d36)
Thanks [@ota-meshi](https://github.com/ota-meshi)! - fix: broken
indentation of if condition in `svelte/indent` rule

### Patch Changes

- [#789](#789)
[`0bc17df`](0bc17df)
Thanks [@KuSh](https://github.com/KuSh)! - chore: Use eslint types for
exported configs

- [#805](#805)
[`6e4d3ed`](6e4d3ed)
Thanks [@baseballyama](https://github.com/baseballyama)! - fix: update
`svelte-eslint-parser` to fix nested `{#snippet}`

- [#800](#800)
[`580f44f`](580f44f)
Thanks [@ota-meshi](https://github.com/ota-meshi)! - feat: add name to
flat configs.

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants