@@ -7,13 +7,14 @@ const ruleTester = new RuleTester({
77} ) ;
88
99ruleTester . run ( 'template-modifier-name-case' , rule , {
10+ // Rule is HBS-only: hyphenated identifiers are not valid JS, so camelCase
11+ // modifier names in .gjs/.gts files are intentional and must not be flagged.
1012 valid : [
1113 '<template><div {{did-insert}}></div></template>' ,
1214 '<template><div {{did-update}}></div></template>' ,
1315 '<template><div {{on-click}}></div></template>' ,
1416 '<template><div {{(modifier "did-insert")}}></div></template>' ,
1517 '<template><div {{(modifier "on-click")}}></div></template>' ,
16-
1718 '<template><div {{did-insert "something"}}></div></template>' ,
1819 '<template><div {{did-insert action=something}}></div></template>' ,
1920 '<template><button {{on "click" somethingAmazing}}></button></template>' ,
@@ -24,69 +25,14 @@ ruleTester.run('template-modifier-name-case', rule, {
2425 '<template><div {{(modifier "foo-bar")}}></div></template>' ,
2526 '<template><div {{(if this.foo (modifier "foo-bar"))}}></div></template>' ,
2627 '<template><div {{(modifier this.fooBar)}}></div></template>' ,
28+ // camelCase modifiers in GJS are not flagged — hyphenated names are invalid JS identifiers
29+ '<template><div {{didInsert}}></div></template>' ,
30+ '<template><div {{doSomething}}></div></template>' ,
31+ '<template><div {{fooBar}}></div></template>' ,
32+ '<template><div {{FooBar}}></div></template>' ,
33+ '<template><div {{(modifier "fooBar")}}></div></template>' ,
2734 ] ,
28- invalid : [
29- {
30- code : '<template><div {{didInsert}}></div></template>' ,
31- output : '<template><div {{did-insert}}></div></template>' ,
32- errors : [ { messageId : 'dasherized' } ] ,
33- } ,
34- {
35- code : '<template><div {{doSomething}}></div></template>' ,
36- output : '<template><div {{do-something}}></div></template>' ,
37- errors : [ { messageId : 'dasherized' } ] ,
38- } ,
39- {
40- code : '<template><div {{fooBar}}></div></template>' ,
41- output : '<template><div {{foo-bar}}></div></template>' ,
42- errors : [ { messageId : 'dasherized' } ] ,
43- } ,
44- // PascalCase: index-0 guard prevents leading dash
45- {
46- code : '<template><div {{FooBar}}></div></template>' ,
47- output : '<template><div {{foo-bar}}></div></template>' ,
48- errors : [ { messageId : 'dasherized' } ] ,
49- } ,
50- {
51- code : '<template><div {{XFoo}}></div></template>' ,
52- output : '<template><div {{x-foo}}></div></template>' ,
53- errors : [ { messageId : 'dasherized' } ] ,
54- } ,
55- // Namespaced :: → /
56- {
57- code : '<template><div {{Foo::barBaz}}></div></template>' ,
58- output : '<template><div {{foo/bar-baz}}></div></template>' ,
59- errors : [ { messageId : 'dasherized' } ] ,
60- } ,
61- {
62- code : '<template><div {{(modifier "didInsert")}}></div></template>' ,
63- output : '<template><div {{(modifier "did-insert")}}></div></template>' ,
64- errors : [ { messageId : 'dasherized' } ] ,
65- } ,
66-
67- {
68- code : '<template><div class="monkey" {{didInsert "something" with="somethingElse"}}></div></template>' ,
69- output :
70- '<template><div class="monkey" {{did-insert "something" with="somethingElse"}}></div></template>' ,
71- errors : [ { messageId : 'dasherized' } ] ,
72- } ,
73- {
74- code : '<template><a href="#" onclick={{amazingActionThing "foo"}} {{doSomething}}></a></template>' ,
75- output :
76- '<template><a href="#" onclick={{amazingActionThing "foo"}} {{do-something}}></a></template>' ,
77- errors : [ { messageId : 'dasherized' } ] ,
78- } ,
79- {
80- code : '<template><div {{(modifier "fooBar")}}></div></template>' ,
81- output : '<template><div {{(modifier "foo-bar")}}></div></template>' ,
82- errors : [ { messageId : 'dasherized' } ] ,
83- } ,
84- {
85- code : '<template><div {{(if this.foo (modifier "fooBar"))}}></div></template>' ,
86- output : '<template><div {{(if this.foo (modifier "foo-bar"))}}></div></template>' ,
87- errors : [ { messageId : 'dasherized' } ] ,
88- } ,
89- ] ,
35+ invalid : [ ] ,
9036} ) ;
9137
9238const hbsRuleTester = new RuleTester ( {
@@ -99,46 +45,55 @@ const hbsRuleTester = new RuleTester({
9945
10046hbsRuleTester . run ( 'template-modifier-name-case' , rule , {
10147 valid : [
102- '<div {{did-insert}}></div>' ,
103- '<div {{did-insert "something"}}></div>' ,
104- '<div {{did-insert action=something}}></div>' ,
105- '<button {{on "click" somethingAmazing}}></button>' ,
106- '<button onclick={{do-a-thing "foo"}}></button>' ,
107- '<button onclick={{doAThing "foo"}}></button>' ,
108- '<a href="#" onclick={{amazingActionThing "foo"}} {{did-insert}}></a>' ,
109- '<div didInsert></div>' ,
110- '<div {{(modifier "foo-bar")}}></div>' ,
111- '<div {{(if this.foo (modifier "foo-bar"))}}></div>' ,
112- '<div {{(modifier this.fooBar)}}></div>' ,
48+ { filename : 'test.hbs' , code : '<div {{did-insert}}></div>' } ,
49+ { filename : 'test.hbs' , code : '<div {{did-insert "something"}}></div>' } ,
50+ { filename : 'test.hbs' , code : '<div {{did-insert action=something}}></div>' } ,
51+ { filename : 'test.hbs' , code : '<button {{on "click" somethingAmazing}}></button>' } ,
52+ { filename : 'test.hbs' , code : '<button onclick={{do-a-thing "foo"}}></button>' } ,
53+ { filename : 'test.hbs' , code : '<button onclick={{doAThing "foo"}}></button>' } ,
54+ {
55+ filename : 'test.hbs' ,
56+ code : '<a href="#" onclick={{amazingActionThing "foo"}} {{did-insert}}></a>' ,
57+ } ,
58+ { filename : 'test.hbs' , code : '<div didInsert></div>' } ,
59+ { filename : 'test.hbs' , code : '<div {{(modifier "foo-bar")}}></div>' } ,
60+ { filename : 'test.hbs' , code : '<div {{(if this.foo (modifier "foo-bar"))}}></div>' } ,
61+ { filename : 'test.hbs' , code : '<div {{(modifier this.fooBar)}}></div>' } ,
11362 ] ,
11463 invalid : [
11564 {
65+ filename : 'test.hbs' ,
11666 code : '<div {{didInsert}}></div>' ,
11767 output : '<div {{did-insert}}></div>' ,
11868 errors : [ { messageId : 'dasherized' } ] ,
11969 } ,
12070 {
71+ filename : 'test.hbs' ,
12172 code : '<div class="monkey" {{didInsert "something" with="somethingElse"}}></div>' ,
12273 output : '<div class="monkey" {{did-insert "something" with="somethingElse"}}></div>' ,
12374 errors : [ { messageId : 'dasherized' } ] ,
12475 } ,
12576 // PascalCase: index-0 guard prevents leading dash
12677 {
78+ filename : 'test.hbs' ,
12779 code : '<div {{FooBar}}></div>' ,
12880 output : '<div {{foo-bar}}></div>' ,
12981 errors : [ { messageId : 'dasherized' } ] ,
13082 } ,
13183 {
84+ filename : 'test.hbs' ,
13285 code : '<a href="#" onclick={{amazingActionThing "foo"}} {{doSomething}}></a>' ,
13386 output : '<a href="#" onclick={{amazingActionThing "foo"}} {{do-something}}></a>' ,
13487 errors : [ { messageId : 'dasherized' } ] ,
13588 } ,
13689 {
90+ filename : 'test.hbs' ,
13791 code : '<div {{(modifier "fooBar")}}></div>' ,
13892 output : '<div {{(modifier "foo-bar")}}></div>' ,
13993 errors : [ { messageId : 'dasherized' } ] ,
14094 } ,
14195 {
96+ filename : 'test.hbs' ,
14297 code : '<div {{(if this.foo (modifier "fooBar"))}}></div>' ,
14398 output : '<div {{(if this.foo (modifier "foo-bar"))}}></div>' ,
14499 errors : [ { messageId : 'dasherized' } ] ,
0 commit comments