Skip to content

Bug: [no-unnecessary-boolean-literal-compare] doesn't flag values of a type parameter with boolean type constraint #10443

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

Closed
4 tasks done
ronami opened this issue Dec 2, 2024 · 1 comment · Fixed by #10474
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@ronami
Copy link
Member

ronami commented Dec 2, 2024

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=5.7.2&fileType=.ts&code=PTAEDMEMEsBsGcBQBjA9gO3gF1FgptgIwBcoAFPKgLZ4DCGAJtFtBqQEaqqx6ToCUoALwA%2BUADdU0BsNCUa9dExYZhYgN6JQoaOHLy6jZq3TChQ3ACcArnkHqAvogcBuRIhByAFqmuwZUHAoGNi4BFgATKQAPAAqoHgAHvhK8KCc3LzoIhTUhkrGbKCxgqISUjIWBorKJmqgmtq6%2Bnk1habmFlg2dg1OrohAA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tiacTJTIAhtEK0ARhw5IhTWo3yJoQ%2BLTIcAtsRGJ0UJdA7RI4MAF8QZoA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

// fails
const test1: (someCondition: boolean) => void = someCondition => {
  if (someCondition === true) {}
};

// should fail
const test2: <T extends boolean>(someCondition: T) => void = someCondition => {
  if (someCondition === true) {}
};

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error"
  },
};

tsconfig

{
  "compilerOptions": {
    "strictNullChecks": true
  }
}

Expected Result

I expect all use-cases to be consistent and report as errors.

Actual Result

The use-cases with a type constraint doesn't report as an error (even though it should).

Additional Info

This seems similar to #10311, and it looks like the fix should be similar.

Note that this issue is also similar to #10442, and I wasn't sure if I should create one issue for each rule or aggregate them under a single issue. I apologize if this was a bit spammy. I checked existing rules for similar problems after resolving #10311.

@ronami ronami added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Dec 2, 2024
@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels Dec 7, 2024
@JoshuaKGoldberg
Copy link
Member

Heh, I'm not sure whether this is a dup of #10442. Since it's unclear I think filing either one or two issues would both be fine.

Not important background information: @kirkwaiblinger and I have been watching the total open issue count fluctuate around 300 for a few weeks now. At least I -and I think also Kirk- like having it <300 as a vanity number. By filing two issues you've slightly increased the amount we've posted sad memes in a private Discord thread. That's probably the only downside. 😛

kirkwaiblinger added a commit to kirkwaiblinger/typescript-eslint that referenced this issue Dec 13, 2024
@github-actions github-actions bot added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label Dec 22, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
2 participants