@@ -10,7 +10,7 @@ ruleTester.run('template-no-link-to-tagname', rule, {
1010 valid : [
1111 {
1212 filename : 'test.gjs' ,
13- code : '<template><LinkTo @route="index">Home</LinkTo></template>' ,
13+ code : 'import { LinkTo } from \'@ember/routing\';\n <template><LinkTo @route="index">Home</LinkTo></template>' ,
1414 output : null ,
1515 } ,
1616 {
@@ -24,6 +24,24 @@ ruleTester.run('template-no-link-to-tagname', rule, {
2424 output : null ,
2525 } ,
2626
27+ // User-authored LinkTo component (no @ember/routing import) — should NOT be flagged
28+ {
29+ filename : 'test.gjs' ,
30+ code : '<template><LinkTo @tagName="button">Home</LinkTo></template>' ,
31+ output : null ,
32+ } ,
33+ {
34+ filename : 'test.gts' ,
35+ code : '<template><LinkTo @tagName="button">Home</LinkTo></template>' ,
36+ output : null ,
37+ } ,
38+
39+ // Bare tagName (without @) is just an HTML attribute, not flagged
40+ {
41+ filename : 'test.gjs' ,
42+ code : 'import { LinkTo } from \'@ember/routing\';\n<template><LinkTo @route="index" tagName="button">Home</LinkTo></template>' ,
43+ output : null ,
44+ } ,
2745 '<template><Foo @route="routeName" @tagName="button">Link text</Foo></template>' ,
2846 '<template><LinkTo @route="routeName">Link text</LinkTo></template>' ,
2947 '<template>{{#link-to "routeName"}}Link text{{/link-to}}</template>' ,
@@ -35,19 +53,26 @@ ruleTester.run('template-no-link-to-tagname', rule, {
3553 invalid : [
3654 {
3755 filename : 'test.gjs' ,
38- code : '<template><LinkTo @route="index" tagName="button">Home </LinkTo></template>' ,
56+ code : 'import { LinkTo } from \'@ember/routing\';\n <template><LinkTo @route="about" @ tagName="span">About </LinkTo></template>' ,
3957 output : null ,
4058 errors : [ { messageId : 'noLinkToTagname' } ] ,
4159 } ,
4260 {
43- filename : 'test.gjs ' ,
44- code : '<template><LinkTo @route="about" @tagName="span">About</LinkTo></template>' ,
61+ filename : 'test.gts ' ,
62+ code : 'import { LinkTo } from \'@ember/routing\';\n <template><LinkTo @route="about" @tagName="span">About</LinkTo></template>' ,
4563 output : null ,
4664 errors : [ { messageId : 'noLinkToTagname' } ] ,
4765 } ,
66+ // Renamed import
4867 {
4968 filename : 'test.gjs' ,
50- code : '<template><link-to @route="contact" tagName="div">Contact</link-to></template>' ,
69+ code : 'import { LinkTo as Link } from \'@ember/routing\';\n<template><Link @tagName="button">x</Link></template>' ,
70+ output : null ,
71+ errors : [ { messageId : 'noLinkToTagname' } ] ,
72+ } ,
73+ {
74+ filename : 'test.gts' ,
75+ code : 'import { LinkTo as Link } from \'@ember/routing\';\n<template><Link @route="index" @tagName="button">x</Link></template>' ,
5176 output : null ,
5277 errors : [ { messageId : 'noLinkToTagname' } ] ,
5378 } ,
@@ -80,6 +105,8 @@ const hbsRuleTester = new RuleTester({
80105
81106hbsRuleTester . run ( 'template-no-link-to-tagname' , rule , {
82107 valid : [
108+ // Bare tagName (without @) is just an HTML attribute, not flagged
109+ '<LinkTo @route="index" tagName="button">Home</LinkTo>' ,
83110 '<Foo @route="routeName" @tagName="button">Link text</Foo>' ,
84111 '<LinkTo @route="routeName">Link text</LinkTo>' ,
85112 '{{#link-to "routeName"}}Link text{{/link-to}}' ,
@@ -91,17 +118,42 @@ hbsRuleTester.run('template-no-link-to-tagname', rule, {
91118 {
92119 code : '<LinkTo @route="routeName" @tagName="button">Link text</LinkTo>' ,
93120 output : null ,
94- errors : [ { message : 'tagName attribute on LinkTo is deprecated' } ] ,
121+ errors : [
122+ {
123+ message :
124+ '@tagName on <LinkTo> is not supported (removed in Ember 4.0). <LinkTo> always renders an <a> element.' ,
125+ } ,
126+ ] ,
127+ } ,
128+ {
129+ code : '<link-to @route="contact" @tagName="div">Contact</link-to>' ,
130+ output : null ,
131+ errors : [
132+ {
133+ message :
134+ '@tagName on <LinkTo> is not supported (removed in Ember 4.0). <LinkTo> always renders an <a> element.' ,
135+ } ,
136+ ] ,
95137 } ,
96138 {
97139 code : '{{#link-to "routeName" tagName="button"}}Link text{{/link-to}}' ,
98140 output : null ,
99- errors : [ { message : 'tagName attribute on LinkTo is deprecated' } ] ,
141+ errors : [
142+ {
143+ message :
144+ '@tagName on <LinkTo> is not supported (removed in Ember 4.0). <LinkTo> always renders an <a> element.' ,
145+ } ,
146+ ] ,
100147 } ,
101148 {
102149 code : '{{link-to "Link text" "routeName" tagName="button"}}' ,
103150 output : null ,
104- errors : [ { message : 'tagName attribute on LinkTo is deprecated' } ] ,
151+ errors : [
152+ {
153+ message :
154+ '@tagName on <LinkTo> is not supported (removed in Ember 4.0). <LinkTo> always renders an <a> element.' ,
155+ } ,
156+ ] ,
105157 } ,
106158 ] ,
107159} ) ;
0 commit comments