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

immutable-data: Map Support #934

Closed
xethorn opened this issue Feb 20, 2025 · 4 comments · Fixed by #935
Closed

immutable-data: Map Support #934

xethorn opened this issue Feb 20, 2025 · 4 comments · Fixed by #935
Labels
Status: Released It's now live. Type: Feature New features or options.

Comments

@xethorn
Copy link

xethorn commented Feb 20, 2025

Suggestion

Thank you for this amazing linter, this has helped us keep our codebase maintainable and our data flows easy to understand! I have a request: currently immutable-data supports array and disallows modifications. When it comes to other similar datatypes like Maps, the linter doesn't seem to have rules that prevent modifications.

Example with immutable-data set to error:

export const value = new Map();
value.set('foo', 'bar'); // no errors.

If I missed it, can you please point me in the right direction? Thank you!

@xethorn xethorn added Status: Triage This issue needs to be triaged. Type: Idea Marks an idea, which might be accepted and implemented. labels Feb 20, 2025
@RebeccaStevens RebeccaStevens added Type: Feature New features or options. and removed Type: Idea Marks an idea, which might be accepted and implemented. Status: Triage This issue needs to be triaged. labels Feb 23, 2025
@RebeccaStevens
Copy link
Collaborator

RebeccaStevens commented Feb 23, 2025

We don't currently have map and set support in this rule.
This is definitely something we can add though, however it will require type data, so we won't be able to support in vanilla js.

In the meantime, assuming you are using TypeScript, I would recommend a ReadonlyMap:

export const value: ReadonlyMap<string, string> = new Map();
value.set('foo', 'bar'); // error.

@xethorn
Copy link
Author

xethorn commented Feb 23, 2025

Thank you. I think that's fine to not support this for vanilla js; and yes, set support would be amazing too.

RebeccaStevens added a commit that referenced this issue Feb 23, 2025
BREAKING CHANGE: map and set mutations will now be reported

fix #934
graphite-app bot pushed a commit that referenced this issue Feb 23, 2025
…#935)

BREAKING CHANGE: map and set mutations will now be reported

fix #934
github-actions bot pushed a commit that referenced this issue Feb 23, 2025
# [9.0.0](v8.0.0...v9.0.0) (2025-02-23)

### Features

* **immutable-data:** add support for detecting map and set mutations ([#935](#935)) ([0386f3a](0386f3a)), closes [#934](#934)

### BREAKING CHANGES

* **immutable-data:** map and set mutations will now be reported
Copy link

🎉 This issue has been resolved in version 9.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot added the Status: Released It's now live. label Feb 23, 2025
@xethorn
Copy link
Author

xethorn commented Feb 24, 2025

@RebeccaStevens : I have no words, this is awesome 🫶 Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Released It's now live. Type: Feature New features or options.
Projects
None yet
2 participants