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

feat: svelte support #364

Merged
merged 2 commits into from Dec 25, 2023
Merged

feat: svelte support #364

merged 2 commits into from Dec 25, 2023

Conversation

thenbe
Copy link
Contributor

@thenbe thenbe commented Dec 17, 2023

Description

This PR adds svelte support (as per #282 (comment))

It includes the following rules:

  1. Stylistic rules for users not using prettier

  2. The recommended rule-set from eslint-plugin-svelte

  3. Rules that users always need to amend for svelte anyways, such as:

    • setting varsIgnorePattern for svelte specific stuff such as $$Props
    • turning off import/no-mutable-exports because svelte uses export let myprop to declare props
    • etc
  4. Some additional rules from eslint-plugin-svelte that are likely to indicate an issue (I tried to avoid the more opinionated ones)


Linked Issues

Additional context

A few points:

  • The Rules type does not include svelte rules because they are not a part of https://github.com/antfu/eslint-define-config.
  • For the dependency setup: Users are only prompted to install eslint-plugin-svelte. They don't need to install svelte-eslint-parser directly, since it's already a dependency of eslint-plugin-svelte.
    • NOTE: I had to include svelte-eslint-parser as a peer dependency. Without it, this project will fail to build (it errors about not finding svelte). And if we install svelte and remove svelte-eslint-parser, we can build but we get an error when consuming this package Error: Dynamic require of "fs" is not supported. This current setup builds successfully and can be consumed successfully.

Copy link
Owner

@antfu antfu left a comment

Choose a reason for hiding this comment

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

Thanks! In general I am happy to have it, if you are willing to help maintaining it (like I might ping you when ppl raise Svelte related issues), is that ok for you? Thanks

varsIgnorePattern: '^\\$\\$Props$',
}],

...pluginSvelte.configs.recommended.rules as any,
Copy link
Owner

Choose a reason for hiding this comment

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

I wonder how many rules are in it? Should we just expand it inline so have a clear image what to include and compose (for example, would it include some rules in the stylistic category?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are 14 rules marked as recommended today, none of which are categorized as stylistic.

I don't have an opinion on this issue, we can be more explicit by expanding the rules.

Copy link
Contributor Author

@thenbe thenbe Dec 20, 2023

Choose a reason for hiding this comment

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

expanded: 9e31d9d (#364)

@thenbe
Copy link
Contributor Author

thenbe commented Dec 20, 2023

Sure thing!

@antfu antfu merged commit ec6313c into antfu:main Dec 25, 2023
5 checks passed
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

2 participants