From fa8096cc625fbb336a997418153d7a92ab9888f6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Feb 2026 22:38:37 +0000 Subject: [PATCH 1/2] Initial plan From d3c06129a951f8d8790b0ba3980858ea4b4dc9e9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Feb 2026 22:44:36 +0000 Subject: [PATCH 2/2] Port template-no-debugger rule from PR #2371 Co-authored-by: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> --- README.md | 7 ++- docs/rules/template-no-debugger.md | 52 +++++++++++++++++ lib/rules/template-no-debugger.js | 41 ++++++++++++++ tests/lib/rules/template-no-debugger.js | 75 +++++++++++++++++++++++++ 4 files changed, 172 insertions(+), 3 deletions(-) create mode 100644 docs/rules/template-no-debugger.md create mode 100644 lib/rules/template-no-debugger.js create mode 100644 tests/lib/rules/template-no-debugger.js diff --git a/README.md b/README.md index 73a87c3c50..1997fcd7ea 100644 --- a/README.md +++ b/README.md @@ -176,9 +176,10 @@ rules in templates can be disabled with eslint directives with mustache or html ### Best Practices -| Name | Description | 💼 | 🔧 | 💡 | -| :----------------------------------------------- | :---------------------------- | :- | :- | :- | -| [template-no-log](docs/rules/template-no-log.md) | disallow {{log}} in templates | | | | +| Name | Description | 💼 | 🔧 | 💡 | +| :--------------------------------------------------------- | :--------------------------------- | :- | :- | :- | +| [template-no-debugger](docs/rules/template-no-debugger.md) | disallow {{debugger}} in templates | | | | +| [template-no-log](docs/rules/template-no-log.md) | disallow {{log}} in templates | | | | ### Components diff --git a/docs/rules/template-no-debugger.md b/docs/rules/template-no-debugger.md new file mode 100644 index 0000000000..506bc7a07b --- /dev/null +++ b/docs/rules/template-no-debugger.md @@ -0,0 +1,52 @@ +# ember/template-no-debugger + + + +Disallows usage of `{{debugger}}` in templates. + +The `{{debugger}}` helper is useful for debugging but should not be present in production code. + +## Rule Details + +This rule disallows the use of `{{debugger}}` statements in templates. + +## Examples + +Examples of **incorrect** code for this rule: + +```gjs + +``` + +```gjs + +``` + +Examples of **correct** code for this rule: + +```gjs + +``` + +```gjs + +``` + +## Related Rules + +- [no-debugger](https://eslint.org/docs/rules/no-debugger) from ESLint + +## References + +- [ember-template-lint no-debugger](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-debugger.md) diff --git a/lib/rules/template-no-debugger.js b/lib/rules/template-no-debugger.js new file mode 100644 index 0000000000..21f1edba01 --- /dev/null +++ b/lib/rules/template-no-debugger.js @@ -0,0 +1,41 @@ +/** @type {import('eslint').Rule.RuleModule} */ +module.exports = { + meta: { + type: 'problem', + docs: { + description: 'disallow {{debugger}} in templates', + category: 'Best Practices', + url: 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/template-no-debugger.md', + }, + fixable: null, + schema: [], + messages: { + unexpected: 'Unexpected debugger statement in template.', + }, + }, + + create(context) { + function checkForDebugger(node) { + if ( + node.path && + node.path.type === 'GlimmerPathExpression' && + node.path.original === 'debugger' + ) { + context.report({ + node, + messageId: 'unexpected', + }); + } + } + + return { + GlimmerMustacheStatement(node) { + checkForDebugger(node); + }, + + GlimmerBlockStatement(node) { + checkForDebugger(node); + }, + }; + }, +}; diff --git a/tests/lib/rules/template-no-debugger.js b/tests/lib/rules/template-no-debugger.js new file mode 100644 index 0000000000..d984e600c1 --- /dev/null +++ b/tests/lib/rules/template-no-debugger.js @@ -0,0 +1,75 @@ +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const rule = require('../../../lib/rules/template-no-debugger'); +const RuleTester = require('eslint').RuleTester; + +//------------------------------------------------------------------------------ +// Tests +//------------------------------------------------------------------------------ + +const ruleTester = new RuleTester({ + parser: require.resolve('ember-eslint-parser'), + parserOptions: { ecmaVersion: 2022, sourceType: 'module' }, +}); + +ruleTester.run('template-no-debugger', rule, { + valid: [ + ``, + ``, + ``, + ``, + ], + + invalid: [ + { + code: ``, + output: null, + errors: [ + { + message: 'Unexpected debugger statement in template.', + type: 'GlimmerMustacheStatement', + }, + ], + }, + { + code: ``, + output: null, + errors: [ + { + message: 'Unexpected debugger statement in template.', + type: 'GlimmerMustacheStatement', + }, + ], + }, + { + code: ``, + output: null, + errors: [ + { + message: 'Unexpected debugger statement in template.', + type: 'GlimmerBlockStatement', + }, + ], + }, + ], +});