Skip to content

Commit 06e093e

Browse files
committed
Fix template-deprecated-inline-view-helper false positive in GJS/GTS
The {{view}} and view.* patterns are classic Ember only; in GJS/GTS files, `view` may be a legitimate imported JS binding or local variable.
1 parent b705850 commit 06e093e

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

lib/rules/template-deprecated-inline-view-helper.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ module.exports = {
2323
},
2424

2525
create(context) {
26+
const isStrictMode = context.filename.endsWith('.gjs') || context.filename.endsWith('.gts');
27+
if (isStrictMode) {
28+
return {};
29+
}
30+
2631
const sourceCode = context.sourceCode;
2732

2833
// Track block param names to avoid false positives on locals like:

tests/lib/rules/template-deprecated-inline-view-helper.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ ruleTester.run('template-deprecated-inline-view-helper', rule, {
3030
'<template>{{yield hash=view.foo}}</template>',
3131
// hash pair with key "to" should not be flagged
3232
'<template>{{some-component to=view.foo}}</template>',
33+
// Rule is HBS-only: `view` in GJS/GTS may be a legitimate imported JS binding
34+
{
35+
filename: 'test.gjs',
36+
code: "<template>{{view 'awful-fishsticks'}}</template>",
37+
},
38+
{
39+
filename: 'test.gts',
40+
code: '<template>{{view.bad-fishsticks}}</template>',
41+
},
3342
],
3443
invalid: [
3544
{

0 commit comments

Comments
 (0)