diff --git a/docs/rules/template-no-extra-mut-helper-argument.md b/docs/rules/template-no-extra-mut-helper-argument.md index 3e18f04b2c..f46f3ecfc4 100644 --- a/docs/rules/template-no-extra-mut-helper-argument.md +++ b/docs/rules/template-no-extra-mut-helper-argument.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. - Disallows passing more than one argument to the `mut` helper. @@ -15,13 +13,13 @@ A common mistake when using the Ember handlebars template `mut(attr)` helper is This rule **forbids** the following: ```hbs -{{my-component click=(action (mut isClicked true))}} +{{my-component click=(fn (mut isClicked true))}} ``` This rule **allows** the following: ```hbs -{{my-component click=(action (mut isClicked) true)}} +{{my-component click=(fn (mut isClicked) true)}} ``` ## Related Rules diff --git a/lib/rules/template-no-extra-mut-helper-argument.js b/lib/rules/template-no-extra-mut-helper-argument.js index 8fda9ca18e..4dbad15451 100644 --- a/lib/rules/template-no-extra-mut-helper-argument.js +++ b/lib/rules/template-no-extra-mut-helper-argument.js @@ -7,7 +7,7 @@ module.exports = { category: 'Possible Errors', recommended: false, url: 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/template-no-extra-mut-helper-argument.md', - templateMode: 'loose', + templateMode: 'both', }, fixable: null, schema: [], @@ -22,7 +22,7 @@ module.exports = { create(context) { const ERROR_MESSAGE = - 'The handlebars `mut(attr)` helper should only have one argument passed to it. To pass a value, use: `(action (mut attr) value)`.'; + 'The handlebars `mut(attr)` helper should only have one argument passed to it. To pass a value, use: `(fn (mut attr) value)`.'; return { GlimmerSubExpression(node) { diff --git a/tests/lib/rules/template-no-extra-mut-helper-argument.js b/tests/lib/rules/template-no-extra-mut-helper-argument.js index 0307aca048..799a349b34 100644 --- a/tests/lib/rules/template-no-extra-mut-helper-argument.js +++ b/tests/lib/rules/template-no-extra-mut-helper-argument.js @@ -8,20 +8,20 @@ const ruleTester = new RuleTester({ ruleTester.run('template-no-extra-mut-helper-argument', rule, { valid: [ - '', - '', + '', + '', '', - '', - '', + '', + '', ], invalid: [ { - code: '', + code: '', output: null, errors: [ { message: - 'The handlebars `mut(attr)` helper should only have one argument passed to it. To pass a value, use: `(action (mut attr) value)`.', + 'The handlebars `mut(attr)` helper should only have one argument passed to it. To pass a value, use: `(fn (mut attr) value)`.', }, ], }, @@ -31,17 +31,29 @@ ruleTester.run('template-no-extra-mut-helper-argument', rule, { errors: [ { message: - 'The handlebars `mut(attr)` helper should only have one argument passed to it. To pass a value, use: `(action (mut attr) value)`.', + 'The handlebars `mut(attr)` helper should only have one argument passed to it. To pass a value, use: `(fn (mut attr) value)`.', }, ], }, { - code: '', + code: '', output: null, errors: [ { message: - 'The handlebars `mut(attr)` helper should only have one argument passed to it. To pass a value, use: `(action (mut attr) value)`.', + 'The handlebars `mut(attr)` helper should only have one argument passed to it. To pass a value, use: `(fn (mut attr) value)`.', + }, + ], + }, + // `mut` is an ambient strict-mode keyword, so this reports in gjs/gts as well + { + filename: 'test.gjs', + code: '', + output: null, + errors: [ + { + message: + 'The handlebars `mut(attr)` helper should only have one argument passed to it. To pass a value, use: `(fn (mut attr) value)`.', }, ], }, @@ -58,20 +70,20 @@ const hbsRuleTester = new RuleTester({ hbsRuleTester.run('template-no-extra-mut-helper-argument', rule, { valid: [ - '{{my-component click=(action (mut isClicked))}}', - '{{my-component click=(action (mut isClicked) true)}}', + '{{my-component click=(fn (mut isClicked))}}', + '{{my-component click=(fn (mut isClicked) true)}}', '{{my-component isClickedMutable=(mut isClicked)}}', - '', - '', + '', + '', ], invalid: [ { - code: '{{my-component click=(action (mut isClicked true))}}', + code: '{{my-component click=(fn (mut isClicked true))}}', output: null, errors: [ { message: - 'The handlebars `mut(attr)` helper should only have one argument passed to it. To pass a value, use: `(action (mut attr) value)`.', + 'The handlebars `mut(attr)` helper should only have one argument passed to it. To pass a value, use: `(fn (mut attr) value)`.', }, ], }, @@ -81,17 +93,17 @@ hbsRuleTester.run('template-no-extra-mut-helper-argument', rule, { errors: [ { message: - 'The handlebars `mut(attr)` helper should only have one argument passed to it. To pass a value, use: `(action (mut attr) value)`.', + 'The handlebars `mut(attr)` helper should only have one argument passed to it. To pass a value, use: `(fn (mut attr) value)`.', }, ], }, { - code: '', + code: '', output: null, errors: [ { message: - 'The handlebars `mut(attr)` helper should only have one argument passed to it. To pass a value, use: `(action (mut attr) value)`.', + 'The handlebars `mut(attr)` helper should only have one argument passed to it. To pass a value, use: `(fn (mut attr) value)`.', }, ], },