petite-vue/valid-v-scope
Require v-scope to bind an object literal
Default severity: error
Presets: none
Automatic fix: None; review the suggested change
Applies to: HTML documents detected as petite-vue; ordinary Vue SFCs are outside this rule's scope.
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": {
"petite-vue/valid-v-scope": "error"
}
},
},
});
vp run lint
Bad
The four nonempty v-scope values are an identifier, a call, arithmetic, and a number; none parses as an object literal.
<!doctype html>
<html><body>
<div v-scope="count"></div>
<div v-scope="foo()"></div>
<div v-scope="a + b"></div>
<div v-scope="123"></div>
<script src="https://unpkg.com/petite-vue" init></script>
</body></html>
Good
A valueless v-scope uses the root scope. The other values are object literals, including the parenthesized object, which the rule accepts.
<!doctype html>
<html><body>
<div v-scope></div>
<div v-scope="{}"></div>
<div v-scope="{ count: 0 }"></div>
<div v-scope="({ count: 0 })"></div>
<script src="https://unpkg.com/petite-vue" init></script>
</body></html>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.