-
-
Notifications
You must be signed in to change notification settings - Fork 714
feat(lint): detect props destructuring in setup function body #7744
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
base: main
Are you sure you want to change the base?
feat(lint): detect props destructuring in setup function body #7744
Conversation
…cturing only Foundation version with: - Vue component discovery (export default, defineComponent) - setup function detection (method & property forms) - Parameter destructuring check (setup({ foo })) Removed: - Root scope destructuring - toRefs/toRef validation - Nested scope checking - TypeScript tests ~604 lines → ~245 lines
…e setup function body (e.g., const { count } = props;).
🦋 Changeset detectedLatest commit: 3325fe4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
WalkthroughAdds a new Vue-focused lint rule Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 1
🧹 Nitpick comments (5)
crates/biome_rule_options/src/no_vue_setup_props_reactivity_loss.rs (1)
3-6
: Add rustdoc and keep options aligned with ruleStruct looks correct with serde/derive settings. Please add a brief rustdoc so it’s discoverable in docs, and ensure the rule uses this options type (see rule file).
Apply this minimal doc add:
#[derive(Default, Clone, Debug, Deserialize, Deserializable, Eq, PartialEq, Serialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase", deny_unknown_fields, default)] -pub struct NoVueSetupPropsReactivityLossOptions {} +/// Options for the `noVueSetupPropsReactivityLoss` rule. +/// Currently no customisable settings. +pub struct NoVueSetupPropsReactivityLossOptions {}As per coding guidelines
crates/biome_js_analyze/src/lint/nursery/no_vue_setup_props_reactivity_loss.rs (4)
15-43
: Docs mention only parameter destructuring; include body destructuring exampleThe rule also detects root‑scope body destructuring. Add a short invalid example to make that explicit.
Apply:
/// ### Invalid /// /// ```js,expect_diagnostic /// export default { /// setup({ count }) { /// return () => h('div', count); /// } /// } /// ``` +/// +/// ```js,expect_diagnostic +/// export default { +/// setup(props) { +/// const { count } = props; // body destructuring loses reactivity +/// return () => h('div', count); +/// } +/// } +/// ```As per coding guidelines
262-283
: Same issue for assignments: constrain RHS to the bareprops
identifierAvoid flagging
({ x } = toRefs(props))
.Apply:
fn check_assignment_destructuring( assignment: &JsAssignmentExpression, reference: &JsReferenceIdentifier, ) -> Option<DestructuringInfo> { let right_expr = assignment.right().ok()?; - // Ensure reference is in the right side of = - if !right_expr.range().contains_range(reference.range()) { + // Only flag when RHS is exactly the same identifier (optionally parenthesised) + let is_same_identifier = match &right_expr { + AnyJsExpression::JsReferenceIdentifier(id) => id.range() == reference.range(), + AnyJsExpression::JsParenthesizedExpression(p) => { + let inner = p.expression().ok()?; + inner.range() == reference.range() + } + _ => false, + }; + if !is_same_identifier { return None; }This matches the rule intent while avoiding safe
toRefs
destructuring.
359-361
: Name check is strict (no computed keys); acceptable for nowThis won’t match computed
["setup"]
, which is fine for MVP. Consider supporting computed names later if needed.
238-260
: Restrict destructuring check & add missing test fortoRefs(props)
Refine the initializer guard to only flag when the RHS is exactly the same identifier (allowing parentheses):let is_same_identifier = match &init_expr { AnyJsExpression::JsReferenceIdentifier(id) => id.range() == reference.range(), AnyJsExpression::JsParenthesizedExpression(p) => { let inner = p.expression().ok()?; inner.range() == reference.range() } _ => false, }; if !is_same_identifier { return None; }No existing spec covers
const { x } = toRefs(props)
—please add a test to confirm this pattern is permitted.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (31)
crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rs
is excluded by!**/migrate/eslint_any_rule_to_biome.rs
and included by**
crates/biome_configuration/src/analyzer/linter/rules.rs
is excluded by!**/rules.rs
and included by**
crates/biome_diagnostics_categories/src/categories.rs
is excluded by!**/categories.rs
and included by**
crates/biome_js_analyze/src/lint/nursery.rs
is excluded by!**/nursery.rs
and included by**
crates/biome_js_analyze/tests/specs/correctness/noConstantMathMinMaxClamp/invalid.jsonc.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/correctness/noUnusedVariables/validVariables.ts.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/missingDependenciesInvalid.js.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/nursery/noVueReservedProps/valid-define-component-setup.js.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-array-destructuring.js.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-arrow-function.js.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-assignment-destructuring.js.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-define-component.js.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-destructuring.js.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-function-expression.js.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-parameter-destructuring.js.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-typescript.ts.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-vue-file.vue.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid.js.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-multiple-exports.js.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-non-vue-contexts.js.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-typescript.ts.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-vue-file.vue.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid.js.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/style/noParameterAssign/invalidFixUnsafe.js.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/style/useComponentExportOnlyModules/valid_component_and_number_constant_with_ignored_constant_export.jsx.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/style/useFilenamingConvention/Valid_Renamed_Export.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/style/useFilenamingConvention/_valid.js.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/suspicious/noWith/invalid.js.snap
is excluded by!**/*.snap
and included by**
crates/biome_js_analyze/tests/specs/suspicious/noWith/valid.js.snap
is excluded by!**/*.snap
and included by**
packages/@biomejs/backend-jsonrpc/src/workspace.ts
is excluded by!**/backend-jsonrpc/src/workspace.ts
and included by**
packages/@biomejs/biome/configuration_schema.json
is excluded by!**/configuration_schema.json
and included by**
📒 Files selected for processing (20)
.changeset/itchy-wings-hope.md
(1 hunks).changeset/yummy-melons-serve.md
(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_vue_setup_props_reactivity_loss.rs
(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-array-destructuring.js
(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-arrow-function.js
(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-assignment-destructuring.js
(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-define-component.js
(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-destructuring.js
(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-function-expression.js
(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-parameter-destructuring.js
(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-typescript.ts
(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-vue-file.vue
(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid.js
(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-multiple-exports.js
(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-non-vue-contexts.js
(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-typescript.ts
(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-vue-file.vue
(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid.js
(1 hunks)crates/biome_rule_options/src/lib.rs
(1 hunks)crates/biome_rule_options/src/no_vue_setup_props_reactivity_loss.rs
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**
📄 CodeRabbit inference engine (CLAUDE.md)
Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}
Files:
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-typescript.ts
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-parameter-destructuring.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-vue-file.vue
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-non-vue-contexts.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-define-component.js
crates/biome_js_analyze/src/lint/nursery/no_vue_setup_props_reactivity_loss.rs
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-destructuring.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-multiple-exports.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-typescript.ts
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-arrow-function.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-vue-file.vue
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-function-expression.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-array-destructuring.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-assignment-destructuring.js
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-typescript.ts
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-parameter-destructuring.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-vue-file.vue
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-non-vue-contexts.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-define-component.js
crates/biome_js_analyze/src/lint/nursery/no_vue_setup_props_reactivity_loss.rs
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-destructuring.js
crates/biome_rule_options/src/no_vue_setup_props_reactivity_loss.rs
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-multiple-exports.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-typescript.ts
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-arrow-function.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid.js
crates/biome_rule_options/src/lib.rs
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-vue-file.vue
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-function-expression.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-array-destructuring.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-assignment-destructuring.js
**/tests/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place test files under a tests/ directory in each crate
Files:
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-typescript.ts
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-parameter-destructuring.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-vue-file.vue
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-non-vue-contexts.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-define-component.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-destructuring.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-multiple-exports.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-typescript.ts
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-arrow-function.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-vue-file.vue
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-function-expression.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-array-destructuring.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-assignment-destructuring.js
.changeset/**/*.md
📄 CodeRabbit inference engine (CONTRIBUTING.md)
.changeset/**/*.md
: Create changesets using thejust new-changeset
command; do not author them manually
In changeset markdown, only use headers #### or #####
Changeset descriptions must end every sentence with a full stop (.)
For bug fixes, start the changeset description with a linked issue reference like “Fixed #1234”
Prefer past tense for what was done and present tense for current behavior in changesets
Files:
.changeset/yummy-melons-serve.md
.changeset/itchy-wings-hope.md
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Before committing, format Rust and TOML files (e.g., via
just f
/just format
)
Files:
crates/biome_js_analyze/src/lint/nursery/no_vue_setup_props_reactivity_loss.rs
crates/biome_rule_options/src/no_vue_setup_props_reactivity_loss.rs
crates/biome_rule_options/src/lib.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and options via inline rustdoc in Rust source
Files:
crates/biome_js_analyze/src/lint/nursery/no_vue_setup_props_reactivity_loss.rs
crates/biome_rule_options/src/no_vue_setup_props_reactivity_loss.rs
crates/biome_rule_options/src/lib.rs
🧠 Learnings (2)
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_rule_options/lib/*.rs : Define per-rule options in biome_rule_options/lib/<rule>.rs with a dedicated options struct/enum (camelCase serde names, deny_unknown_fields, default) and derive Serialize/Deserialize/Deserializable (and schemars JsonSchema when schema feature is on)
Applied to files:
crates/biome_rule_options/src/no_vue_setup_props_reactivity_loss.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/tests/specs/nursery/** : Place snapshot tests for new rules under tests/specs/nursery/<ruleName>/ with files prefixed by invalid* and valid*
Applied to files:
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-multiple-exports.js
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid.js
🧬 Code graph analysis (12)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-typescript.ts (5)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-arrow-function.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-define-component.js (1)
props
(5-5)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-destructuring.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-function-expression.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-multiple-exports.js (1)
props
(6-6)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-parameter-destructuring.js (2)
crates/biome_js_analyze/tests/specs/suspicious/noRedeclare/valid-declaration-merging.ts (1)
h
(131-133)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-non-vue-contexts.js (2)
foo
(21-21)foo
(35-35)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-define-component.js (4)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-arrow-function.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-destructuring.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-function-expression.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-multiple-exports.js (1)
props
(6-6)
crates/biome_js_analyze/src/lint/nursery/no_vue_setup_props_reactivity_loss.rs (3)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (2)
RuleDomain
(904-912)TextRange
(9283-9283)crates/biome_analyze/src/rule.rs (4)
domains
(591-594)recommended
(561-564)sources
(576-579)inspired
(252-257)crates/biome_rowan/src/ast/mod.rs (1)
cast_ref
(142-151)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-destructuring.js (5)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-arrow-function.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-define-component.js (1)
props
(5-5)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-function-expression.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-multiple-exports.js (1)
props
(6-6)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-assignment-destructuring.js (1)
count
(4-4)
crates/biome_rule_options/src/no_vue_setup_props_reactivity_loss.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoVueSetupPropsReactivityLossOptions
(8248-8248)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-typescript.ts (5)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-arrow-function.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-define-component.js (1)
props
(5-5)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-destructuring.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-function-expression.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-multiple-exports.js (1)
props
(6-6)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-arrow-function.js (5)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-define-component.js (1)
props
(5-5)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-destructuring.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-function-expression.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-multiple-exports.js (1)
props
(6-6)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-assignment-destructuring.js (1)
count
(4-4)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-function-expression.js (4)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-arrow-function.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-define-component.js (1)
props
(5-5)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-destructuring.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-multiple-exports.js (1)
props
(6-6)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid.js (5)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-arrow-function.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-define-component.js (1)
props
(5-5)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-destructuring.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-function-expression.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-assignment-destructuring.js (1)
count
(4-4)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-array-destructuring.js (5)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-arrow-function.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-define-component.js (1)
props
(5-5)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-destructuring.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-function-expression.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-multiple-exports.js (1)
props
(6-6)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-assignment-destructuring.js (5)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-arrow-function.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-define-component.js (1)
props
(5-5)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-destructuring.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-function-expression.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-multiple-exports.js (1)
props
(6-6)
🔇 Additional comments (20)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-array-destructuring.js (1)
1-7
: Verify array destructuring test case.Array destructuring on props (
const [first] = props;
) is unusual since Vue props are objects. This pattern would extractundefined
in practice. Consider whether this edge case meaningfully tests the rule or if it adds confusion..changeset/yummy-melons-serve.md (1)
5-7
: Add full stops to end sentences.Lines 5 and 7 are missing full stops. As per coding guidelines, changeset descriptions must end every sentence with a full stop.
Apply this diff:
-Added the nursery rule [`noVueSetupPropsReactivityLoss`](https://biomejs.dev/linter/rules/no-vue-setup-props-reactivity-loss/). +Added the nursery rule [`noVueSetupPropsReactivityLoss`](https://biomejs.dev/linter/rules/no-vue-setup-props-reactivity-loss/). -This new rule disallows usages that cause the reactivity of `props` passed to the `setup` function to be lost. +This new rule disallows usages that cause the reactivity of `props` passed to the `setup` function to be lost.⛔ Skipped due to learnings
Learnt from: CR PR: biomejs/biome#0 File: CONTRIBUTING.md:0-0 Timestamp: 2025-10-02T12:55:57.554Z Learning: Applies to .changeset/**/*.md : Changeset descriptions must end every sentence with a full stop (.)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-non-vue-contexts.js (2)
1-37
: LGTM!The test cases properly cover non-Vue contexts that should be ignored by the rule: non-setup methods, standalone functions, class methods, and non-exported objects. All scenarios are valid and comprehensive.
1-37
: LGTM! Comprehensive non-Vue context coverage.The test cases correctly verify that the rule only applies to Vue component contexts and ignores setup functions in regular objects, classes, and standalone functions.
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-vue-file.vue (2)
1-11
: LGTM!Valid Vue SFC pattern—no destructuring, props returned intact. Template correctly accesses
props.count
.
1-11
: LGTM! Valid Vue SFC test case.Correctly demonstrates a safe pattern where props are returned without destructuring, preserving reactivity.
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-destructuring.js (2)
1-7
: LGTM!Correctly demonstrates the invalid pattern: body-level destructuring that breaks Vue reactivity. The rule should flag line 4.
1-7
: LGTM! Correct invalid test case.Properly demonstrates props destructuring in the setup function body, which should trigger the rule.
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-typescript.ts (2)
1-12
: LGTM!Properly demonstrates the invalid pattern in TypeScript with type annotations. Line 9 destructuring should be flagged by the rule.
1-12
: LGTM! TypeScript support verified.Correctly tests that the rule detects destructuring in TypeScript files with type annotations.
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-arrow-function.js (2)
1-7
: LGTM!Correctly tests arrow function syntax with body destructuring. Line 3 should be flagged.
1-7
: LGTM! Arrow function variant tested.Correctly verifies that the rule detects destructuring in arrow function setup implementations.
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-multiple-exports.js (2)
1-16
: LGTM!Correctly validates that the rule only checks
export default
, not named exports. Line 5 destructuring in the named export should be ignored, whilst the default export demonstrates safe usage.
1-16
: LGTM! Correct scope limitation.Properly tests that the rule only applies to default exports, which aligns with Vue's component export conventions.
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-define-component.js (2)
1-8
: LGTM!Correctly tests the invalid pattern with Vue's
defineComponent
helper. Line 4 destructuring should be flagged.
1-8
: LGTM! defineComponent variant covered.Correctly tests that the rule detects destructuring when using Vue's
defineComponent
API.crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-assignment-destructuring.js (1)
1-8
: Good coverage for assignment destructuring in setup bodyCovers the tricky assignment form
({ count } = props)
in root scope. Nice.crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-parameter-destructuring.js (1)
3-43
: Solid matrix of parameter destructuring patternsThorough set: defaults, renames, rest, defineComponent, named export. Looks good.
crates/biome_js_analyze/src/lint/nursery/no_vue_setup_props_reactivity_loss.rs (1)
335-345
: Minor: handle missing.binding()
gracefullyIf a malformed parameter sneaks in,
.binding().ok()?
is fine; nothing to change. LGTM.crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid-typescript.ts (1)
1-13
: LGTM! Valid TypeScript pattern.Correctly demonstrates the safe approach in TypeScript, accessing props directly without destructuring to preserve reactivity.
crates/biome_js_analyze/src/lint/nursery/no_vue_setup_props_reactivity_loss.rs
Show resolved
Hide resolved
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.
Actionable comments posted: 1
♻️ Duplicate comments (1)
crates/biome_js_analyze/src/lint/nursery/no_vue_setup_props_reactivity_loss.rs (1)
84-89
: Options wiring fixed — thanks
type Options = NoVueSetupPropsReactivityLossOptions;
is now correctly wired. This resolves the previous API mismatch.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid.js.snap
is excluded by!**/*.snap
and included by**
📒 Files selected for processing (3)
crates/biome_js_analyze/src/lint/nursery/no_vue_setup_props_reactivity_loss.rs
(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid.js
(1 hunks)crates/biome_rule_options/src/no_vue_setup_props_reactivity_loss.rs
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- crates/biome_rule_options/src/no_vue_setup_props_reactivity_loss.rs
🧰 Additional context used
📓 Path-based instructions (5)
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**
📄 CodeRabbit inference engine (CLAUDE.md)
Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}
Files:
crates/biome_js_analyze/src/lint/nursery/no_vue_setup_props_reactivity_loss.rs
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid.js
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_js_analyze/src/lint/nursery/no_vue_setup_props_reactivity_loss.rs
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid.js
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Before committing, format Rust and TOML files (e.g., via
just f
/just format
)
Files:
crates/biome_js_analyze/src/lint/nursery/no_vue_setup_props_reactivity_loss.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and options via inline rustdoc in Rust source
Files:
crates/biome_js_analyze/src/lint/nursery/no_vue_setup_props_reactivity_loss.rs
**/tests/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place test files under a tests/ directory in each crate
Files:
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid.js
🧬 Code graph analysis (2)
crates/biome_js_analyze/src/lint/nursery/no_vue_setup_props_reactivity_loss.rs (2)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (2)
RuleDomain
(904-912)NoVueSetupPropsReactivityLossOptions
(8248-8248)crates/biome_rowan/src/ast/mod.rs (1)
cast_ref
(142-151)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/valid.js (5)
crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-define-component.js (1)
props
(5-5)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-function-expression.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-arrow-function.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-destructuring.js (1)
props
(4-4)crates/biome_js_analyze/tests/specs/nursery/noVueSetupPropsReactivityLoss/invalid-body-assignment-destructuring.js (1)
count
(4-4)
crates/biome_js_analyze/src/lint/nursery/no_vue_setup_props_reactivity_loss.rs
Show resolved
Hide resolved
CodSpeed Performance ReportMerging #7744 will not alter performanceComparing Summary
Footnotes
|
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.
This second changeset isn't necessary.
Summary
This PR extends the
noVueSetupPropsReactivityLoss
rule to detect props destructuring in the setup function body, not just in parameters.PR#7513
Test Plan
Added comprehensive test coverage with 9 new test files covering:
Invalid cases (should report errors):
setup(props) { const { count } = props; }
setup: (props) => { const { count } = props; }
({ count } = props);
const [first] = props;
defineComponent()
and plain object literalsValid cases (should not report):
toRefs(props)
vue
,@vue/reactivity
,@vue/composition-api
Vue.toRefs(props)
import { toRefs as makeRefs }
export default
)All tests pass:
File type support verified:
.js
files.ts
files.vue
files (extracts and checks<script>
content)