Skip to content

feat(no-unnecessary-state-wrap): support string array in allowReassign, default to ['SvelteSet'], and improve messages #1202

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

baseballyama
Copy link
Member

close: #1154
close: #1180

Copy link

changeset-bot bot commented Apr 19, 2025

⚠️ No Changeset found

Latest commit: 9070e12

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@baseballyama baseballyama changed the title feat(no-unnecessary-state-wrap): support string array in allowReassign, default to [‘SvelteSet’], and improve messages feat(no-unnecessary-state-wrap): support string array in allowReassign, default to ['SvelteSet'], and improve messages Apr 19, 2025
Copy link
Contributor

Try the Instant Preview in Online Playground

ESLint Online Playground

Install the Instant Preview to Your Local

npm i https://pkg.pr.new/eslint-plugin-svelte@9070e12

Published Instant Preview Packages:

View Commit

@benmccann
Copy link
Member

I think set = new SvelteSet([1, 2, 3]) should be allowed as it's cumbersome to write another way, but set = new SvelteSet() should not be because set.clear(); is easier to write

@baseballyama
Copy link
Member Author

I think set = new SvelteSet([1, 2, 3]) should be allowed as it's cumbersome to write another way, but set = new SvelteSet() should not be because set.clear(); is easier to write

Since the rule would become more complex, would it be better to implement it as a separate rule, like prefer-svelteset-new?

@marekdedic
Copy link
Contributor

Why should SvelteSet be allowed by default? I don't see why it's different from e.g. SvelteMap, am I missing something?

@benmccann
Copy link
Member

Since the rule would become more complex, would it be better to implement it as a separate rule, like prefer-svelteset-new?

I think that would be fine. The name seems backwards to me though. Perhaps something like prefer-clear-over-reassignment. I also think you don't necessarily need svelteset in the name because it could apply to SvelteMap as well

Why should SvelteSet be allowed by default? I don't see why it's different from e.g. SvelteMap, am I missing something?

I agree. I think we ended up deciding all reassignments should be allowed by default though, so probably not an issue once that change is made. The prefer-clear-over-reassignment rule can handle the SvelteSet and SvelteMap cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants