vue/no-restricted-syntax
Disallow configured syntax in the template.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
None | No | Rule options |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
Bad
The configured CallExpression appears in the template.
<template>
<p>{{ format(value) }}</p>
</template>
Good
The template reads a prepared binding instead of calling a function.
<template>
<p>{{ formattedValue }}</p>
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/no-restricted-syntax": "warn"
},
"ruleOptions": {
"vue/no-restricted-syntax": {
"selectors": [
"CallExpression"
]
}
}
},
});
Then run vp run lint.
Differences from eslint-plugin-vue
The option value may be the ESLint array of selector strings and { selector, message } objects, or { selectors: [...] }. Selectors are a subset of esquery, listed under rule options. A selector outside that subset fails configuration. :nth-child(an+b) formulas, relative :has(> …) selectors, [attr=type(...)], and the :exit suffix are outside the subset.