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-dynamic-subexpression-invocations.js
More file actions
48 lines (45 loc) · 1.36 KB
/
template-no-dynamic-subexpression-invocations.js
File metadata and controls
48 lines (45 loc) · 1.36 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
const rule = require('../../../lib/rules/template-no-dynamic-subexpression-invocations');
const RuleTester = require('eslint').RuleTester;
const ruleTester = new RuleTester({
parser: require.resolve('ember-eslint-parser'),
parserOptions: { ecmaVersion: 2022, sourceType: 'module' },
});
ruleTester.run('template-no-dynamic-subexpression-invocations', rule, {
valid: [
'<template>{{format-date this.date}}</template>',
'<template>{{(upper-case this.name)}}</template>',
'<template>{{helper "static"}}</template>',
],
invalid: [
{
code: '<template>{{(this.helper "arg")}}</template>',
output: null,
errors: [
{
message: 'Do not use dynamic helper invocations. Use explicit helper names instead.',
type: 'GlimmerSubExpression',
},
],
},
{
code: '<template>{{(@helperName "value")}}</template>',
output: null,
errors: [
{
message: 'Do not use dynamic helper invocations. Use explicit helper names instead.',
type: 'GlimmerSubExpression',
},
],
},
{
code: '<template>{{this.formatter this.data}}</template>',
output: null,
errors: [
{
message: 'Do not use dynamic helper invocations. Use explicit helper names instead.',
type: 'GlimmerMustacheStatement',
},
],
},
],
});