Skip to content

feat(lint): implement vue/noSetupPropsReactivityLoss Part2#1

Closed
AsherDe wants to merge 1 commit intofeat/vue-reactivity-rulefrom
feat/vue-reactivity-rule-detect-body-destructuring
Closed

feat(lint): implement vue/noSetupPropsReactivityLoss Part2#1
AsherDe wants to merge 1 commit intofeat/vue-reactivity-rulefrom
feat/vue-reactivity-rule-detect-body-destructuring

Conversation

@AsherDe
Copy link
Owner

@AsherDe AsherDe commented Oct 13, 2025

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):

  • Body destructuring in method form: setup(props) { const { count } = props; }
  • Body destructuring in arrow functions: setup: (props) => { const { count } = props; }
  • Body destructuring in function expressions
  • Assignment destructuring: ({ count } = props);
  • Array destructuring: const [first] = props;
  • Works in defineComponent() and plain object literals
  • TypeScript files with type annotations

Valid cases (should not report):

  • Safe destructuring with toRefs(props)
  • Supports all Vue import sources: vue, @vue/reactivity, @vue/composition-api
  • Namespace imports: Vue.toRefs(props)
  • Aliased imports: import { toRefs as makeRefs }
  • Destructuring in nested functions (callbacks, handlers)
  • Multiple exports (only checks export default)

All tests pass:

test result: ok. 1764 passed; 0 failed; 0 ignored

File type support verified:

  • .js files
  • .ts files
  • .vue files (extracts and checks <script> content)

…e setup function body (e.g., const { count } = props;).
@AsherDe AsherDe closed this Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant