Skip to content

Conversation

marekdedic
Copy link
Contributor

No description provided.

Copy link

changeset-bot bot commented Sep 4, 2025

🦋 Changeset detected

Latest commit: 5774d2f

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 Minor

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

Copy link
Contributor

github-actions bot commented Sep 4, 2025

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@a299b31

Published Instant Preview Packages:

View Commit

@marekdedic marekdedic force-pushed the prefer-svelte-reactivity-returned-vars branch 3 times, most recently from 0441041 to a299b31 Compare September 4, 2025 23:32
@marekdedic marekdedic marked this pull request as ready for review September 4, 2025 23:33
Copy link
Member

@baseballyama baseballyama left a comment

Choose a reason for hiding this comment

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

Why should we be forced to use SvelteSet or SvelteMap even when the values aren’t changing?

@marekdedic
Copy link
Contributor Author

Firstly, this PR is part of a wider effort to move the rule to better detect when variables are "encapsulated" inside a function/class and not report them - this PR is an off-shoot of #1287

But this should make sense even on its own anyway - but I think it does. Example

fileA:

function makeSet() {
  const a = new Set();
  // Populate the set etc.
  return a;
}

export makeSet;

fileB:

<script>
  import { makeSet } from "fileA";

  const a = makeSet();
</script>

<!-- Print the set here -->

<button onclick={a.add(42);}>Click me!</button>

In this example, this PR reports the incorrect usage of Set. I hope to pair it with the rest of #1287 to ignore all encapsulated uses by default so that we don't get too many FPs.

@marekdedic marekdedic force-pushed the prefer-svelte-reactivity-returned-vars branch from a299b31 to 5774d2f Compare September 14, 2025 20:01
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.

2 participants