Skip to content

feat(enforce-exhaustive-useUnit-destructuring): add new rule for destructured units#175

Merged
kireevmp merged 12 commits intoeffector:masterfrom
Olovyannikov:new/use-unit-destructuring
Apr 13, 2026
Merged

feat(enforce-exhaustive-useUnit-destructuring): add new rule for destructured units#175
kireevmp merged 12 commits intoeffector:masterfrom
Olovyannikov:new/use-unit-destructuring

Conversation

@Olovyannikov
Copy link
Copy Markdown
Contributor

@Olovyannikov Olovyannikov commented Dec 9, 2025

Problem: implicit subscriptions when forgot remove unused subscriptions inside react components
e.g.:

const { setValue } = useUnit({ 
  value: $store, // not used, but create unnecessary re-render
  setValue: event 
})

Why is this important?

Implicit subscriptions can lead to:

  • Performance issues: unnecessary re-renders when unused stores update
  • Hard-to-debug behavior: component re-renders for unclear reasons
  • Memory leaks: subscriptions that are never cleaned up properly

Rule Details

This rule enforces that:

  • All properties passed in an object to useUnit must be destructured to prevent implicit subscriptions;
  • All elements passed in an array to useUnit must be destructured to prevent implicit subscriptions also.

@netlify
Copy link
Copy Markdown

netlify Bot commented Dec 9, 2025

Deploy Preview for eslint-plugin ready!

Name Link
🔨 Latest commit b8243b7
🔍 Latest deploy log https://app.netlify.com/projects/eslint-plugin/deploys/69dd0373fbd2750008c815a2
😎 Deploy Preview https://deploy-preview-175--eslint-plugin.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Olovyannikov Olovyannikov force-pushed the new/use-unit-destructuring branch 2 times, most recently from ddd9966 to 9accf5e Compare December 9, 2025 10:05
@Olovyannikov Olovyannikov changed the title feat(rule): add new rule for destructured units feat(use-unit-desctricturing): add new rule for destructured units Dec 14, 2025
@Olovyannikov Olovyannikov changed the title feat(use-unit-desctricturing): add new rule for destructured units feat(use-unit-destructuring): add new rule for destructured units Dec 15, 2025
@Olovyannikov Olovyannikov force-pushed the new/use-unit-destructuring branch from 9accf5e to 6c9cd69 Compare March 4, 2026 08:13
@Olovyannikov Olovyannikov force-pushed the new/use-unit-destructuring branch from 80edafd to e8e65b7 Compare April 10, 2026 08:25
Copy link
Copy Markdown
Contributor

@kireevmp kireevmp left a comment

Choose a reason for hiding this comment

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

@Olovyannikov Thanks for taking the time to submit this! The rule logic seems to be solid 👍

There are a couple of good opportunities to improve this though – I'd appreciate it if you can take a look at my comments

Comment thread src/rules/use-unit-destructuring/use-unit-destructuring.ts Outdated
Comment thread src/rules/use-unit-destructuring/use-unit-destructuring.ts Outdated
Comment thread src/rules/use-unit-destructuring/use-unit-destructuring.ts Outdated
Comment thread src/rules/use-unit-destructuring/use-unit-destructuring.ts Outdated
Comment thread src/rules/use-unit-destructuring/use-unit-destructuring.ts Outdated
Comment thread src/rules/use-unit-destructuring/use-unit-destructuring.ts Outdated
Comment thread src/rules/use-unit-destructuring/use-unit-destructuring.ts Outdated
Comment thread src/rules/use-unit-destructuring/use-unit-destructuring.test.ts Outdated
@Olovyannikov Olovyannikov requested a review from kireevmp April 10, 2026 17:52
Comment thread src/rules/use-unit-destructuring/use-unit-destructuring.ts Outdated
Comment thread src/rules/use-unit-destructuring/use-unit-destructuring.ts Outdated
Comment thread src/rules/use-unit-destructuring/use-unit-destructuring.ts Outdated
Comment thread src/rules/use-unit-destructuring/use-unit-destructuring.ts Outdated
Comment thread src/rules/use-unit-destructuring/use-unit-destructuring.ts Outdated
Comment thread src/rules/use-unit-destructuring/use-unit-destructuring.test.ts Outdated
Comment thread src/rules/use-unit-destructuring/use-unit-destructuring.test.ts Outdated
Comment thread src/index.ts Outdated
Comment thread src/rules/use-unit-destructuring/use-unit-destructuring.md Outdated
@Olovyannikov Olovyannikov force-pushed the new/use-unit-destructuring branch from 8676017 to 61efbe7 Compare April 12, 2026 09:15
@Olovyannikov Olovyannikov requested a review from kireevmp April 12, 2026 09:15
@Olovyannikov Olovyannikov force-pushed the new/use-unit-destructuring branch 2 times, most recently from 23f77aa to ed112f1 Compare April 12, 2026 09:21
@Olovyannikov Olovyannikov force-pushed the new/use-unit-destructuring branch from ed112f1 to aa98a41 Compare April 12, 2026 09:22
Copy link
Copy Markdown
Contributor

@kireevmp kireevmp left a comment

Choose a reason for hiding this comment

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

@Olovyannikov Thank you for committing your time to polish this PR! I think these are just final cosmetic touches on code location and consistency. Once fixed I believe we'll be in good shape to merge.

Comment thread src/rules/prefer-useUnit-destructuring/prefer-useUnit-destructuring.md Outdated
Comment thread src/rules/prefer-useUnit-destructuring/prefer-useUnit-destructuring.ts Outdated
Comment thread src/rules/prefer-useUnit-destructuring/prefer-useUnit-destructuring.ts Outdated
Comment thread src/rules/prefer-useUnit-destructuring/prefer-useUnit-destructuring.ts Outdated
Comment thread src/shared/create.ts
Comment thread src/shared/create.ts Outdated
Comment thread src/shared/create.ts Outdated
Comment thread src/shared/name.ts
Comment thread src/rules/prefer-useUnit-destructuring/prefer-useUnit-destructuring.ts Outdated
Comment thread .gitignore Outdated
@Olovyannikov Olovyannikov changed the title feat(use-unit-destructuring): add new rule for destructured units feat(enforce-exhaustive-useUnit-destructuring): add new rule for destructured units Apr 13, 2026
@Olovyannikov Olovyannikov force-pushed the new/use-unit-destructuring branch from 9a8b0c5 to 4c53dde Compare April 13, 2026 11:44
Copy link
Copy Markdown
Contributor

@kireevmp kireevmp left a comment

Choose a reason for hiding this comment

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

@Olovyannikov Thank you! I think I just need a changeset from you via pnpm changeset (changelog purposes, looking at a minor here). Once added this is good to merge 🚀

Comment thread src/rules/enforce-exhaustive-useUnit-destructuring/lib/index.ts Outdated
@Olovyannikov Olovyannikov requested a review from kireevmp April 13, 2026 14:45
@Olovyannikov Olovyannikov force-pushed the new/use-unit-destructuring branch from dbd9fc8 to b8243b7 Compare April 13, 2026 14:53
@kireevmp kireevmp added enhancement New feature or request preset:react labels Apr 13, 2026
@kireevmp kireevmp merged commit 5d565c3 into effector:master Apr 13, 2026
4 checks passed
@kireevmp
Copy link
Copy Markdown
Contributor

@Olovyannikov Thanks for seeing this through! I'll be taking a look at #176 as well in the next couple of days to wrap up this rule duo – we're currently aiming to release both in v0.19.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request preset:react

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants