From ece435531d51ef6ee25fb7c1f2a5e77ca829dcf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20R=C3=B8ed?= Date: Mon, 13 Apr 2026 14:32:47 +0200 Subject: [PATCH] Document template-no-negated-comparison name-clash; drop non-standard 'ne' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This rule is NOT a port of upstream's no-negated-condition — they have opposite goals. Adds a note to the rule docs to prevent migration confusion. Also removes the 'ne' alias which is not a real Ember truth-helper (only 'not-eq' is standard). --- docs/rules/template-no-negated-comparison.md | 14 +++++-------- lib/rules/template-no-negated-comparison.js | 2 +- .../rules/template-no-negated-comparison.js | 20 ++++++------------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/docs/rules/template-no-negated-comparison.md b/docs/rules/template-no-negated-comparison.md index d5383fe5ad..d7f64903a0 100644 --- a/docs/rules/template-no-negated-comparison.md +++ b/docs/rules/template-no-negated-comparison.md @@ -2,11 +2,15 @@ +> **Note**: This rule is NOT a port of upstream `ember-template-lint`'s `no-negated-condition`. +> Upstream's rule prefers `not-eq` over `if/else`; this rule bans `not-eq` (and similar) entirely. +> These are opposite goals. + Disallows negated comparison operators in templates. ## Rule Details -Use positive comparison operators with `{{unless}}` instead of negated comparison operators like `not-eq` or `ne`. +Use positive comparison operators with `{{unless}}` instead of negated comparison operators like `not-eq`. ## Examples @@ -20,14 +24,6 @@ Examples of **incorrect** code for this rule: ``` -```gjs - -``` - Examples of **correct** code for this rule: ```gjs diff --git a/lib/rules/template-no-negated-comparison.js b/lib/rules/template-no-negated-comparison.js index 3c5244d86e..6ae92584e8 100644 --- a/lib/rules/template-no-negated-comparison.js +++ b/lib/rules/template-no-negated-comparison.js @@ -21,7 +21,7 @@ module.exports = { if ( node.path && node.path.type === 'GlimmerPathExpression' && - (node.path.original === 'not-eq' || node.path.original === 'ne') + node.path.original === 'not-eq' ) { context.report({ node, diff --git a/tests/lib/rules/template-no-negated-comparison.js b/tests/lib/rules/template-no-negated-comparison.js index 187d5c0abb..c6a99f8045 100644 --- a/tests/lib/rules/template-no-negated-comparison.js +++ b/tests/lib/rules/template-no-negated-comparison.js @@ -29,6 +29,12 @@ ruleTester.run('template-no-negated-comparison', rule, { ``, + // `ne` is not a standard Ember/ember-truth-helpers helper; the rule must not flag it. + ``, ], invalid: [ @@ -46,20 +52,6 @@ ruleTester.run('template-no-negated-comparison', rule, { }, ], }, - { - code: ``, - output: null, - errors: [ - { - message: 'Use positive comparison operators instead of negated ones.', - type: 'GlimmerSubExpression', - }, - ], - }, { code: `