vue/no-template-target-blank
Proibir target="_blank" sem rel="noopener noreferrer".
| Severidade padrão | Predefinições | Correção automática | Opções |
|---|---|---|---|
warning |
happy-path, nuxt, ecosystem, opinionated |
Não | Nenhuma |
Aplicável a: Templates e blocos de SFC Vue, com o contexto do script quando exigido pela regra.
Incorreto
O link externo abre um novo contexto de navegação sem a proteção rel esperada.
<template>
<a href="https://example.com" target="_blank">x</a>
</template>
Correto
O mesmo link inclui noopener noreferrer junto de target=_blank.
<template>
<a href="https://example.com" target="_blank" rel="noopener noreferrer">x</a>
</template>
Configuração (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/no-template-target-blank": "warn"
}
},
});
Depois, execute vp run lint.