# vue/no-template-target-blank
disallow target="_blank" attribute without rel="noopener noreferrer"
# 📖 Rule Details
This rule disallows using target="_blank"
attribute without rel="noopener noreferrer"
to avoid a security vulnerability(see here for more details (opens new window)).
<template>
<!-- ✓ Good -->
<a href="http://example.com" target="_blank" rel="noopener noreferrer">link</a>
<!-- ✗ BAD -->
<a href="http://example.com" target="_blank" >link</a>
</temlate>
# 🔧 Options
{
"vue/no-template-target-blank": ["error", {
"allowReferrer": true,
"enforceDynamicLinks": "always"
}]
}
allowReferrer
... Iftrue
, does not require noreferrer.defaultfalse
enforceDynamicLinks ("always" | "never")
... Ifalways
, enforces the rule if the href is a dynamic link. defaultalways
.
# { allowReferrer: false }
(default)
<template>
<!-- ✓ Good -->
<a href="http://example.com" target="_blank" rel="noopener noreferrer">link</a>
<!-- ✗ BAD -->
<a href="http://example.com" target="_blank" rel="noopener">link</a>
</temlate>
# { allowReferrer: true }
<template>
<!-- ✓ Good -->
<a href="http://example.com" target="_blank" rel="noopener">link</a>
<!-- ✗ BAD -->
<a href="http://example.com" target="_blank" >link</a>
</temlate>
# { "enforceDynamicLinks": "always" }
(default)
<template>
<!-- ✓ Good -->
<a :href="link" target="_blank" rel="noopener noreferrer">link</a>
<!-- ✗ BAD -->
<a :href="link" target="_blank">link</a>
</temlate>
# { "enforceDynamicLinks": "never" }
<template>
<!-- ✓ Good -->
<a :href="link" target="_blank">link</a>
<!-- ✗ BAD -->
<a href="http://example.com" target="_blank" >link</a>
</temlate>
# 🚀 Version
This rule was introduced in eslint-plugin-vue v7.0.0