-
-
Notifications
You must be signed in to change notification settings - Fork 47
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: add no-unused-props
rule
#1061
Conversation
🦋 Changeset detectedLatest commit: cfe9251 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
4fa2ea9
to
3c33117
Compare
Try the Instant Preview in Online PlaygroundInstall the Instant Preview to Your Local
Published Instant Preview Packages:
|
3991329
to
4f69e29
Compare
6491439
to
27d2072
Compare
27d2072
to
cfe9251
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mts
can be ts
now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR introduces the new rule "svelte/no-unused-props" to warn developers about declared props that are not used, thereby helping identify dead code and improve component clarity.
- Adds documentation for the new rule
- Implements the rule logic in the ESLint plugin
- Updates tests, configurations, and related files to integrate the new rule
Reviewed Changes
File | Description |
---|---|
docs/rules/no-unused-props.md | Adds detailed documentation and examples for the new rule |
packages/eslint-plugin-svelte/src/rules/no-unused-props.ts | Implements the rule logic for detecting unused props |
packages/eslint-plugin-svelte/tests/** | Adds new YAML test fixtures to cover various invalid cases |
packages/eslint-plugin-svelte/src/configs/flat/recommended.ts | Updates recommended configuration with the new rule |
packages/eslint-plugin-svelte/src/rule-types.ts | Extends the rule types for the new rule |
README.md, docs/rules.md, packages/eslint-plugin-svelte/src/utils/rules.ts | Adds references and imports for the new rule |
Copilot reviewed 84 out of 84 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
packages/eslint-plugin-svelte/src/rules/no-unused-props.ts:291
- [nitpick] The function name 'hasRestElement' may be misleading as it checks for a rest element by testing if the used properties set is empty. A more descriptive name (e.g., 'patternHasRestElement') could improve code readability.
function hasRestElement(usedProps: Set<string>): boolean {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
This PR gives false positive with brand types and tuples in typescript |
@Jerboas86 We’ve released v3.2.1. Could you please verify if this issue has been resolved? As this rule is relatively complex, there might still be some false positives. |
@baseballyama still here for both (tuples and brand types) with v3.2.1 |
Can you share some repl? const { foo, bar }: { foo: [string, number], bar: string & v.brand("bar") } = $props(); |
Hey guys. |
I've created a issue for above issue: #1134 |
close: #1028