forked from ember-cli/eslint-plugin-ember
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate-link-href-attributes.js
More file actions
43 lines (40 loc) · 1.42 KB
/
template-link-href-attributes.js
File metadata and controls
43 lines (40 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const rule = require('../../../lib/rules/template-link-href-attributes');
const RuleTester = require('eslint').RuleTester;
const ruleTester = new RuleTester({
parser: require.resolve('ember-eslint-parser'),
parserOptions: { ecmaVersion: 2022, sourceType: 'module' },
});
ruleTester.run('template-link-href-attributes', rule, {
valid: [
'<template><a href="/about">About</a></template>',
'<template><a href="https://example.com">External</a></template>',
'<template><button>Click me</button></template>',
'<template><a role="link" aria-disabled="true">valid</a></template>',
'<template><a role="button" aria-disabled="true">valid</a></template>',
'<template><a href="">Empty href</a></template>',
'<template><a href="#">Hash href</a></template>',
'<template><a href={{this.link}}>Dynamic href</a></template>',
],
invalid: [
{
code: '<template><a>Link</a></template>',
output: null,
errors: [{ messageId: 'missingHref' }],
},
{
code: '<template><a onclick="doSomething()">Click</a></template>',
output: null,
errors: [{ messageId: 'missingHref' }],
},
{
code: '<template><a role="button">Action</a></template>',
output: null,
errors: [{ messageId: 'missingHref' }],
},
{
code: '<template><a aria-disabled="true">Disabled only</a></template>',
output: null,
errors: [{ messageId: 'missingHref' }],
},
],
});