Skip to content

Commit 8f3920b

Browse files
Merge pull request #2693 from johanrd/day_fix/template-no-negated-comparison
Post-merge-review: template-no-negated-comparison: document name-clash; drop non-standard 'ne'
2 parents c22c633 + d8d13e3 commit 8f3920b

3 files changed

Lines changed: 8 additions & 28 deletions

File tree

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Disallows negated comparison operators in templates.
66

77
## Rule Details
88

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

1111
## Examples
1212

@@ -20,14 +20,6 @@ Examples of **incorrect** code for this rule:
2020
</template>
2121
```
2222

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

3325
```gjs
@@ -45,7 +37,3 @@ Examples of **correct** code for this rule:
4537
{{/if}}
4638
</template>
4739
```
48-
49-
## References
50-
51-
- [eslint-plugin-ember template-no-negated-condition](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-no-negated-condition.md)

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)