Vize

petite-vue/no-unsupported-directive

禁止 petite-vue 不支持的指令。

默认严重程度 预设 自动修复 选项
error 无 不支持 无

适用范围:检测为 petite-vue 的 HTML 文档;普通 Vue SFC 不在此规则范围内。

错误示例

v-memo、v-slot:header 和自定义 v-my-directive 不在 petite-vue 支持的指令列表中。petite-vue 脚本将此 HTML 标识为相应方言。

<!doctype html>
<html><body>
<div v-memo="[a, b]"></div>
<template v-slot:header></template>
<div v-my-directive></div>
<script src="https://unpkg.com/petite-vue" init></script>
</body></html>

正确示例

替换后使用受支持的 v-scope、v-effect、v-if、v-bind 和 v-on 语法,不再依赖不支持的指令。

<!doctype html>
<html><body>
<div v-scope="{ count: 0 }" v-effect="console.log(count)"></div>
<div v-if="ok" v-bind:title="title" @click="count++"></div>
<script src="https://unpkg.com/petite-vue" init></script>
</body></html>

配置(Vite+)

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

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "petite-vue/no-unsupported-directive": "error"
    }
  },
});

然后运行 vp run lint。

相关页面