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(lint): add noDestructuredProps #4983

Open
wants to merge 3 commits into
base: next
Choose a base branch
from

Conversation

ematipico
Copy link
Member

@ematipico ematipico commented Jan 27, 2025

Summary

Implements https://github.com/solidjs-community/eslint-plugin-solid/blob/main/packages/eslint-plugin-solid/docs/no-destructure.md

Closes #4986

How it is implemented

To implement the rule, we query the destructure of props inside a JSX component, then we start iterating over the bindings using an ad-hoc iterator.

The iterator consists of a queue and a current list. We start iterating over the current list, and we return only the bindings we are interested in. If we find nested binding patterns, we add them to the queue.

Once the current list doesn't return any more bindings, we start popping an item from the queue. If there's another list, we mark it as "current list", and we start consuming bindings again.

The iterator is consumed once we don't have any more bindings and the queue is empty.

Compared to the original rule, this rule doesn't provide a code action.

Test Plan

Added test cases from the original rule

@github-actions github-actions bot added A-CLI Area: CLI A-Project Area: project A-Linter Area: linter L-JavaScript Language: JavaScript and super languages A-Diagnostic Area: diagnostocis labels Jan 27, 2025
Copy link

codspeed-hq bot commented Jan 27, 2025

CodSpeed Performance Report

Merging #4983 will degrade performances by 6.4%

Comparing feat/no-props-destructure (2aa5b90) with next (3538867)

Summary

❌ 1 regressions
✅ 94 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
react.production.min_3378072959512366797.js[cached] 1.9 ms 2 ms -6.4%

@ematipico ematipico force-pushed the feat/no-props-destructure branch from 867145a to 2aa5b90 Compare January 28, 2025 09:57
@ematipico ematipico linked an issue Jan 28, 2025 that may be closed by this pull request
@ematipico ematipico marked this pull request as ready for review January 28, 2025 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: CLI A-Diagnostic Area: diagnostocis A-Linter Area: linter A-Project Area: project L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add solid/no-destructure from eslint-plugin-solid
1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy