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-block-params-for-html-elements.js
More file actions
54 lines (51 loc) · 1.6 KB
/
template-no-block-params-for-html-elements.js
File metadata and controls
54 lines (51 loc) · 1.6 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
const rule = require('../../../lib/rules/template-no-block-params-for-html-elements');
const RuleTester = require('eslint').RuleTester;
const ruleTester = new RuleTester({
parser: require.resolve('ember-eslint-parser'),
parserOptions: { ecmaVersion: 2022, sourceType: 'module' },
});
ruleTester.run('template-no-block-params-for-html-elements', rule, {
valid: [
`let div = <template>{{yield "hello"}}</template>;
<template>
<div as |greeting|>{{greeting}}</div>
</template>
`,
'<template><div>Content</div></template>',
'<template><MyComponent as |item|>{{item.name}}</MyComponent></template>',
'<template>{{#each this.items as |item|}}<li>{{item}}</li>{{/each}}</template>',
'<template><button>Click</button></template>',
],
invalid: [
{
code: '<template><div as |content|>{{content}}</div></template>',
output: null,
errors: [
{
message: 'Block params can only be used with components, not HTML elements.',
type: 'GlimmerElementNode',
},
],
},
{
code: '<template><section as |data|><p>{{data}}</p></section></template>',
output: null,
errors: [
{
message: 'Block params can only be used with components, not HTML elements.',
type: 'GlimmerElementNode',
},
],
},
{
code: '<template><ul as |items|><li>{{items}}</li></ul></template>',
output: null,
errors: [
{
message: 'Block params can only be used with components, not HTML elements.',
type: 'GlimmerElementNode',
},
],
},
],
});