Vize

vue/no-restricted-props

Proíbe a prop configurada.

Severidade padrão Predefinições Correção automática Opções
warning Nenhuma Não Nenhuma

Aplicável a: Templates e blocos de SFC Vue, com o contexto do script quando exigido pela regra.

Incorreto

O componente declara a prop proibida third.

<script setup lang="ts">
defineProps<{ third?: number }>();
</script>
<template>
  <p>ok</p>
</template>

Correto

O componente declara a prop first.

<script setup lang="ts">
defineProps<{ first?: number }>();
</script>
<template>
  <p>ok</p>
</template>

Configuração (Vite+)

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

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "vue/no-restricted-props": "warn"
    },
    "ruleOptions": {
      "vue/no-restricted-props": [
        "third"
      ]
    }
  },
});

Depois, execute vp run lint.

Páginas relacionadas