forked from ember-cli/eslint-plugin-ember
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate-deprecated-render-helper.js
More file actions
74 lines (70 loc) · 2.26 KB
/
template-deprecated-render-helper.js
File metadata and controls
74 lines (70 loc) · 2.26 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
const rule = require('../../../lib/rules/template-deprecated-render-helper');
const RuleTester = require('eslint').RuleTester;
const ruleTester = new RuleTester({
parser: require.resolve('ember-eslint-parser'),
parserOptions: { ecmaVersion: 2022, sourceType: 'module' },
});
ruleTester.run('template-deprecated-render-helper', rule, {
valid: [
'<template><MyComponent /></template>',
'<template>{{this.render}}</template>',
'<template>{{valid-compoennt}}</template>',
'<template>{{input placeholder=(t "email") value=email}}</template>',
'<template>{{title "CrossCheck Web" prepent=true separator=" | "}}</template>',
'<template>{{hockey-player teamName="Boston Bruins"}}</template>',
'<template>{{false}}</template>',
'<template>{{"foo"}}</template>',
'<template>{{42}}</template>',
'<template>{{null}}</template>',
'<template>{{undefined}}</template>',
],
invalid: [
{
code: '<template>{{render "user"}}</template>',
output: '<template>{{user}}</template>',
errors: [{ messageId: 'deprecated' }],
},
{
code: "<template>{{render 'ken-griffey'}}</template>",
output: '<template>{{ken-griffey}}</template>',
errors: [{ messageId: 'deprecated' }],
},
{
code: "<template>{{render 'baseball-player' pitcher}}</template>",
output: '<template>{{baseball-player model=pitcher}}</template>',
errors: [{ messageId: 'deprecated' }],
},
],
});
const hbsRuleTester = new RuleTester({
parser: require.resolve('ember-eslint-parser/hbs'),
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
},
});
hbsRuleTester.run('template-deprecated-render-helper', rule, {
valid: [
'{{valid-compoennt}}',
'{{input placeholder=(t "email") value=email}}',
'{{title "CrossCheck Web" prepent=true separator=" | "}}',
'{{hockey-player teamName="Boston Bruins"}}',
'{{false}}',
'{{"foo"}}',
'{{42}}',
'{{null}}',
'{{undefined}}',
],
invalid: [
{
code: "{{render 'ken-griffey'}}",
output: '{{ken-griffey}}',
errors: [{ messageId: 'deprecated' }],
},
{
code: "{{render 'baseball-player' pitcher}}",
output: '{{baseball-player model=pitcher}}',
errors: [{ messageId: 'deprecated' }],
},
],
});