script/no-options-api
Disallow Options API patterns in Vapor mode.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
error |
opinionated |
No | None |
Applies to: Vapor-oriented script checks; explicit enablement also applies the restriction to ordinary scripts.
Bad
The default-export object declares Options API data(), a component option form prohibited by this rule.
<script lang="ts">
export default {
data() {
return { count: 0 };
},
};
</script>
Good
The component state becomes a Composition API ref in Vapor <script setup>, removing the Options API object and its data option.
<script setup lang="ts" vapor>
const count = ref(0);
</script>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"script/no-options-api": "error"
}
},
});
Then run vp run lint.