Vize

script/no-reactive-destructure

Disallow destructuring reactive objects which loses reactivity.

Default severity Presets Automatic fix Options
warning None No None

Applies to: JS/TS scripts in Vue SFCs; examples show the relevant Options API or script setup form.

Bad

const { count, name } = state copies primitive properties out of the reactive object, losing their connection to subsequent property changes.

<script setup lang="ts">
import { reactive } from "vue";
const state = reactive({ count: 0, name: "Ada" });
const { count, name } = state;
</script>

Good

Destructuring toRefs(state) creates refs for count and name, keeping each binding linked to the original reactive property.

<script setup lang="ts">
import { reactive, toRefs } from "vue";
const state = reactive({ count: 0, name: "Ada" });
const { count, name } = toRefs(state);
</script>

Configuration (Vite+)

import { defineConfig } from "@vizejs/vite-plugin/vite-plus";

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "script/no-reactive-destructure": "warn"
    }
  },
});

Then run vp run lint.