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

Add new eslint rules (no-unnecessary-condition, no-unused-expressions, etc) and tsconfig noUncheckedIndexedAccess #4513

Merged
merged 25 commits into from
Aug 12, 2024

Conversation

cmdcolin
Copy link
Collaborator

This PR adds some upgrades to linting

specifically

  • adds eslint 9, with flat config
  • new lint rule @typescript-eslint/no-unnecessary-condition. Adding this lint rule surfaces many "superstitious" instances of if-statements/ternarys/etc. which are just always true or always false, detectable via types
  • new lint rule @typescript-eslint/no-confusing-void-expression, avoids returning values from functions where return type void is expected (so many bracketless arrow functions are converted to bracketed ones)
  • tsconfig.json rule noUncheckedIndexedAccess:true, which makes accessing objects and arrays e.g. obj[key] assume to T|undefined which means you have to override the setting to produce the desired result. this results in more common usage of non-null assertion in some cases, but generally improves typing in others

@cmdcolin cmdcolin changed the title Add no-unnecessary-condition and noUncheckedIndexedAccess Add eslint rule @typescript-eslint/no-unnecessary-condition and tsconfig noUncheckedIndexedAccess:true Aug 12, 2024
@cmdcolin
Copy link
Collaborator Author

also adds eslint rule @typescript-eslint/no-unused-expressions which caught an error in coverage calculations in the methylation mode

diff here shows that there was a "unused expression" where a mutation was intended

image

@cmdcolin cmdcolin changed the title Add eslint rule @typescript-eslint/no-unnecessary-condition and tsconfig noUncheckedIndexedAccess:true Add eslint rule @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-unused-expressions and tsconfig noUncheckedIndexedAccess:true Aug 12, 2024
@cmdcolin cmdcolin changed the title Add eslint rule @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-unused-expressions and tsconfig noUncheckedIndexedAccess:true Add new eslint rules (no-unnecessary-condition, no-unused-expressions, etc) and tsconfig noUncheckedIndexedAccess Aug 12, 2024
@cmdcolin cmdcolin merged commit 615b1e3 into main Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant