forked from ember-cli/eslint-plugin-ember
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate-no-heading-inside-button.js
More file actions
77 lines (73 loc) · 2.53 KB
/
template-no-heading-inside-button.js
File metadata and controls
77 lines (73 loc) · 2.53 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const rule = require('../../../lib/rules/template-no-heading-inside-button');
const RuleTester = require('eslint').RuleTester;
const ruleTester = new RuleTester({
parser: require.resolve('ember-eslint-parser'),
parserOptions: { ecmaVersion: 2022, sourceType: 'module' },
});
ruleTester.run('template-no-heading-inside-button', rule, {
valid: [
'<template><button>Click me</button></template>',
'<template><h1>Title</h1></template>',
'<template><div><h2>Heading</h2></div></template>',
// Test cases ported from ember-template-lint
'<template><button>Show More</button></template>',
'<template><button><span>thumbs-up emoji</span>Show More</button></template>',
'<template><button><div>Show More</div></button></template>',
'<template><div>Showing that it is not a button</div></template>',
'<template><div><h1>Page Title in a div is fine</h1></div></template>',
'<template><h1>Page Title</h1></template>',
],
invalid: [
{
code: '<template><button><h1>Bad</h1></button></template>',
output: null,
errors: [{ messageId: 'noHeading' }],
},
{
code: '<template><div role="button"><h2>Bad</h2></div></template>',
output: null,
errors: [{ messageId: 'noHeading' }],
},
// Test cases ported from ember-template-lint
{
code: '<template><button><h1>Page Title</h1></button></template>',
output: null,
errors: [{ messageId: 'noHeading' }],
},
{
code: '<template><button><h2>Heading Title</h2></button></template>',
output: null,
errors: [{ messageId: 'noHeading' }],
},
{
code: '<template><button><h3>Heading Title</h3></button></template>',
output: null,
errors: [{ messageId: 'noHeading' }],
},
{
code: '<template><button><h4>Heading Title</h4></button></template>',
output: null,
errors: [{ messageId: 'noHeading' }],
},
{
code: '<template><button><h5>Heading Title</h5></button></template>',
output: null,
errors: [{ messageId: 'noHeading' }],
},
{
code: '<template><button><div><h1>Heading Title</h1></div></button></template>',
output: null,
errors: [{ messageId: 'noHeading' }],
},
{
code: '<template><button><h6>Heading Title</h6></button></template>',
output: null,
errors: [{ messageId: 'noHeading' }],
},
{
code: '<template><div role="button"><h6>Heading in a div with a role of button</h6></div></template>',
output: null,
errors: [{ messageId: 'noHeading' }],
},
],
});