diff --git a/docs/rules/template-no-class-bindings.md b/docs/rules/template-no-class-bindings.md index fd7ad41418..d2d2ac6724 100644 --- a/docs/rules/template-no-class-bindings.md +++ b/docs/rules/template-no-class-bindings.md @@ -2,8 +2,6 @@ 💼 This rule is enabled in the 📋 `template-lint-migration` [config](https://github.com/ember-cli/eslint-plugin-ember#-configurations). -> **HBS Only**: This rule applies to classic `.hbs` template files only (loose mode). It is not relevant for `gjs`/`gts` files (strict mode), where these patterns cannot occur. - Disallow passing `classBinding` or `classNameBindings` as arguments within templates. These are legacy Ember Classic patterns that should be replaced with modern approaches. diff --git a/lib/rules/template-no-class-bindings.js b/lib/rules/template-no-class-bindings.js index 026028af31..3249ede786 100644 --- a/lib/rules/template-no-class-bindings.js +++ b/lib/rules/template-no-class-bindings.js @@ -6,7 +6,7 @@ module.exports = { description: 'disallow passing classBinding or classNameBindings as arguments in templates', category: 'Best Practices', url: 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/template-no-class-bindings.md', - templateMode: 'loose', + templateMode: 'both', }, fixable: null, schema: [], @@ -23,11 +23,6 @@ module.exports = { }, create(context) { - const isStrictMode = context.filename.endsWith('.gjs') || context.filename.endsWith('.gts'); - if (isStrictMode) { - return {}; - } - const FORBIDDEN_ATTR_NAMES = new Set([ 'classBinding', '@classBinding', diff --git a/tests/lib/rules/template-no-class-bindings.js b/tests/lib/rules/template-no-class-bindings.js index a241d1cecc..e97213a434 100644 --- a/tests/lib/rules/template-no-class-bindings.js +++ b/tests/lib/rules/template-no-class-bindings.js @@ -13,15 +13,6 @@ ruleTester.run('template-no-class-bindings', rule, { '', '', '', - // Rule is HBS-only: @classBinding in GJS/GTS may be a legitimate component argument - { - filename: 'test.gjs', - code: '', - }, - { - filename: 'test.gts', - code: '', - }, ], invalid: [ { @@ -64,6 +55,30 @@ ruleTester.run('template-no-class-bindings', rule, { }, ], }, + // `@ember/component` is still supported, so a classic component invoked from + // a strict-mode template still acts on these arguments. + { + filename: 'test.gjs', + code: '', + output: null, + errors: [ + { + messageId: 'noClassBindings', + data: { name: '@classBinding' }, + }, + ], + }, + { + filename: 'test.gts', + code: '', + output: null, + errors: [ + { + messageId: 'noClassBindings', + data: { name: '@classNameBindings' }, + }, + ], + }, ], });