Vize

script/prefer-define-options

Prefer defineOptions() over a plain <script> that only sets name/inheritAttrs

Bad · Good

Default severity: warning
Presets: none
Automatic fix: None; review the suggested change
Applies to: JS/TS scripts in Vue SFCs; examples show the relevant Options API or script setup form
Options: No rule-specific options. Severity and preset selection are configurable.

Configuration (Vite+)

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

export default defineConfig({
  lint: {
    vize: {
      "preset": "incremental",
      "rules": {
        "script/prefer-define-options": "warn"
      }
    },
  },
});
vp run lint

Bad

The plain script’s only meaningful statement exports an object containing just name and inheritAttrs; these options can be expressed by defineOptions.

<script lang="ts">
export default { name: 'MyComponent', inheritAttrs: false }
</script>

Good

The shown data() method makes the script carry real Options API logic, so it falls outside this rule’s conservative options-only suggestion. This Good demonstrates an allowed exception; the direct migration would put defineOptions({ name: 'MyComponent', inheritAttrs: false }) in <script setup>.

<script lang="ts">
// Real options logic — keep the plain script.
export default {
name: 'MyComponent',
data() { return { count: 0 } },
}
</script>

Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.

Implementation · All rules