forked from ember-cli/eslint-plugin-ember
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate-inline-link-to.js
More file actions
53 lines (51 loc) · 1.71 KB
/
template-inline-link-to.js
File metadata and controls
53 lines (51 loc) · 1.71 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
const rule = require('../../../lib/rules/template-inline-link-to');
const RuleTester = require('eslint').RuleTester;
const ruleTester = new RuleTester({
parser: require.resolve('ember-eslint-parser'),
parserOptions: { ecmaVersion: 2022, sourceType: 'module' },
});
ruleTester.run('template-inline-link-to', rule, {
valid: [
"<template>{{#link-to 'routeName' prop}}Link text{{/link-to}}</template>",
"<template>{{#link-to 'routeName'}}Link text{{/link-to}}</template>",
],
invalid: [
{
code: "<template>{{link-to 'Link text' 'routeName'}}</template>",
output: "<template>{{#link-to 'routeName'}}Link text{{/link-to}}</template>",
errors: [
{
message: 'The inline form of link-to is not allowed. Use the block form instead.',
},
],
},
{
code: "<template>{{link-to 'Link text' 'routeName' one two}}</template>",
output: "<template>{{#link-to 'routeName' one two}}Link text{{/link-to}}</template>",
errors: [
{
message: 'The inline form of link-to is not allowed. Use the block form instead.',
},
],
},
{
code: "<template>{{link-to (concat 'Hello' @username) 'routeName' one two}}</template>",
output:
"<template>{{#link-to 'routeName' one two}}{{concat 'Hello' @username}}{{/link-to}}</template>",
errors: [
{
message: 'The inline form of link-to is not allowed. Use the block form instead.',
},
],
},
{
code: "<template>{{link-to 1234 'routeName' one two}}</template>",
output: null,
errors: [
{
message: 'The inline form of link-to is not allowed. Use the block form instead.',
},
],
},
],
});