Vize

vue/no-boolean-attr-value

Proibir valores explícitos em atributos HTML booleanos.

Severidade padrão Predefinições Correção automática Opções
warning nuxt, opinionated Sim Nenhuma

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

Incorreto

Os atributos booleanos disabled e checked contêm valores de string redundantes.

<template>
  <input disabled="disabled" />
  <input checked="checked" />
  <button disabled="true">Save</button>
</template>

Correto

A presença de cada atributo booleano expressa o mesmo estado ativado, sem um valor.

<template>
  <input disabled />
  <input checked />
  <button disabled>Save</button>
</template>

Configuração (Vite+)

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

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "vue/no-boolean-attr-value": "warn"
    }
  },
});

Depois, execute vp run lint.

Páginas relacionadas