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: `