Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[no-unsafe-negation] Duplicates TypeScript's TS2358, TS2360, and TS2365 errors (?) #1146

Closed
glen-84 opened this issue Oct 27, 2019 · 4 comments
Labels
breaking change This change will require a new major version to be released package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin recommended-rules Discussion about recommended rule sets

Comments

@glen-84
Copy link
Contributor

glen-84 commented Oct 27, 2019

Repro

{
  "rules": {
    "no-unsafe-negation": ["error", { "enforceForOrderingRelations": true }],
  }
}
const a = 1;
const b = 2;
let foo;

if (!a < b) {
    /**/
}

while (!a > b) {
    /**/
}

foo = !a <= b;

foo = !a >= b;

const myObject = {};
const key = "";
const Ctor = Function;

if (!key in myObject) {
    // operator precedence makes it equivalent to (!key) in object
    // and type conversion makes it equivalent to (key ? "false" : "true") in object
}

if (!myObject instanceof Ctor) {
    // operator precedence makes it equivalent to (!obj) instanceof Ctor
    // and it equivalent to always false since boolean values are not objects.
}

Expected Result

TS errors only.

Actual Result

TS and ESLint errors.

image

Additional Info

enforceForOrderingRelations is actually off by default, so technically TS2365 is probably not being duplicated.

Versions

package version
@typescript-eslint/eslint-plugin 2.5.0
@typescript-eslint/parser 2.5.0
TypeScript 3.5.3
ESLint 6.6.0
node 12.13.0
npm 6.12.0
@glen-84 glen-84 added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Oct 27, 2019
@bradzacher
Copy link
Member

Sorry, what is the request here?
You don't want the rule to report errors that TS reports?

I don't think it's a problem reporting the same errors that TS does, because a lot of people don't use the TS compiler in their build (eg babel).

@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party and removed triage Waiting for maintainers to take a look labels Oct 27, 2019
@glen-84
Copy link
Contributor Author

glen-84 commented Oct 28, 2019

I thought that this was the same type of issue as #983 and #999?

@bradzacher bradzacher added breaking change This change will require a new major version to be released recommended-rules Discussion about recommended rule sets and removed awaiting response Issues waiting for a reply from the OP or another party labels Oct 28, 2019
@bradzacher bradzacher added this to the 3.0.0 milestone Oct 28, 2019
@bradzacher
Copy link
Member

Ah I'm sorry, I didn't realise you were referring to the recommended set.
Yup makes sense.

@bradzacher
Copy link
Member

consolidated eslint-recommended changes in #1273

@bradzacher bradzacher removed this from the 3.0.0 milestone Dec 3, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking change This change will require a new major version to be released package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin recommended-rules Discussion about recommended rule sets
Projects
None yet
Development

No branches or pull requests

2 participants