Skip to content

Commit ece4355

Browse files
committed
Document template-no-negated-comparison name-clash; drop non-standard 'ne'
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).
1 parent 56f913d commit ece4355

File tree

3 files changed

+12
-24
lines changed

3 files changed

+12
-24
lines changed

docs/rules/template-no-negated-comparison.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
<!-- end auto-generated rule header -->
44

5+
> **Note**: This rule is NOT a port of upstream `ember-template-lint`'s `no-negated-condition`.
6+
> Upstream's rule prefers `not-eq` over `if/else`; this rule bans `not-eq` (and similar) entirely.
7+
> These are opposite goals.
8+
59
Disallows negated comparison operators in templates.
610

711
## Rule Details
812

9-
Use positive comparison operators with `{{unless}}` instead of negated comparison operators like `not-eq` or `ne`.
13+
Use positive comparison operators with `{{unless}}` instead of negated comparison operators like `not-eq`.
1014

1115
## Examples
1216

@@ -20,14 +24,6 @@ Examples of **incorrect** code for this rule:
2024
</template>
2125
```
2226

23-
```gjs
24-
<template>
25-
{{#if (ne this.a this.b)}}
26-
Not equal
27-
{{/if}}
28-
</template>
29-
```
30-
3127
Examples of **correct** code for this rule:
3228

3329
```gjs

lib/rules/template-no-negated-comparison.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = {
2121
if (
2222
node.path &&
2323
node.path.type === 'GlimmerPathExpression' &&
24-
(node.path.original === 'not-eq' || node.path.original === 'ne')
24+
node.path.original === 'not-eq'
2525
) {
2626
context.report({
2727
node,

tests/lib/rules/template-no-negated-comparison.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ ruleTester.run('template-no-negated-comparison', rule, {
2929
`<template>
3030
<div></div>
3131
</template>`,
32+
// `ne` is not a standard Ember/ember-truth-helpers helper; the rule must not flag it.
33+
`<template>
34+
{{#if (ne this.a this.b)}}
35+
Not equal
36+
{{/if}}
37+
</template>`,
3238
],
3339

3440
invalid: [
@@ -46,20 +52,6 @@ ruleTester.run('template-no-negated-comparison', rule, {
4652
},
4753
],
4854
},
49-
{
50-
code: `<template>
51-
{{#if (ne this.a this.b)}}
52-
Not equal
53-
{{/if}}
54-
</template>`,
55-
output: null,
56-
errors: [
57-
{
58-
message: 'Use positive comparison operators instead of negated ones.',
59-
type: 'GlimmerSubExpression',
60-
},
61-
],
62-
},
6355
{
6456
code: `<template>
6557
<div class={{if (not-eq this.state "active") "inactive"}}></div>

0 commit comments

Comments
 (0)