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

ESLint: Set "no-unnecessary-condition" rule to error #2755

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

regexowl
Copy link
Collaborator

This adds "no-unnecessary-condition" and sets the output to error. This should help us eliminate superfluous conditional chaining and uncover potentially faulty conditions.

Docs: https://typescript-eslint.io/rules/no-unnecessary-condition/

@regexowl regexowl marked this pull request as draft January 16, 2025 11:04
@regexowl
Copy link
Collaborator Author

My IDE is clever, I'm usually not (especially when I copy over a part of the code). Let's add a new rule to make our linting tighter.

@regexowl regexowl force-pushed the no-unnecessary-condition branch from 939a998 to 34537e1 Compare January 16, 2025 12:48
@regexowl regexowl force-pushed the no-unnecessary-condition branch 2 times, most recently from 21e881c to 80bb886 Compare January 17, 2025 08:05
@regexowl regexowl marked this pull request as ready for review January 17, 2025 08:05
@regexowl
Copy link
Collaborator Author

Originally added all autofix changes, but those break the service. We're combining optional chaining and type assertion in some cases. Meaning we ignore the possibility of undefined values, but when we get one everything crashes. Fun. 🙃

Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.66%. Comparing base (8d34f85) to head (fb0248e).
Report is 1 commits behind head on main.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2755   +/-   ##
=======================================
  Coverage   84.66%   84.66%           
=======================================
  Files         186      186           
  Lines       20996    20996           
  Branches     2033     2033           
=======================================
  Hits        17777    17777           
  Misses       3197     3197           
  Partials       22       22           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d34f85...fb0248e. Read the comment docs.

@regexowl regexowl force-pushed the no-unnecessary-condition branch 2 times, most recently from ee510cd to 3dc2e0c Compare January 17, 2025 15:33
This adds "no-unnecessary-condition" and sets the output to warn. This should help us eliminate superfluous conditional chaining and uncover potentially faulty conditions.

Docs: https://typescript-eslint.io/rules/no-unnecessary-condition/
@lucasgarfield lucasgarfield force-pushed the no-unnecessary-condition branch from 3dc2e0c to fb0248e Compare January 17, 2025 17:20
Copy link
Collaborator

@lucasgarfield lucasgarfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it! This is going to really help the review process - one less thing to look for!

@lucasgarfield lucasgarfield enabled auto-merge (rebase) January 17, 2025 17:20
@lucasgarfield
Copy link
Collaborator

My IDE is clever, I'm usually not (especially when I copy over a part of the code). Let's add a new rule to make our linting tighter.

Hard disagree on the second part 😉

@lucasgarfield lucasgarfield merged commit 7986828 into osbuild:main Jan 17, 2025
7 of 17 checks passed
@regexowl regexowl deleted the no-unnecessary-condition branch January 20, 2025 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants