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

chore: enable radix #9563

Merged
merged 4 commits into from
Jul 23, 2024
Merged

chore: enable radix #9563

merged 4 commits into from
Jul 23, 2024

Conversation

abrahamguo
Copy link
Contributor

PR Checklist

Overview

Enable radix (docs)

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @abrahamguo!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

Copy link

netlify bot commented Jul 14, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit cff1fff
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/669f98f15aea0f0008b89727
😎 Deploy Preview https://deploy-preview-9563--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 99 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Jul 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.45%. Comparing base (102f9df) to head (cff1fff).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9563   +/-   ##
=======================================
  Coverage   88.45%   88.45%           
=======================================
  Files         422      422           
  Lines       14695    14695           
  Branches     4298     4298           
=======================================
  Hits        12998    12998           
  Misses       1372     1372           
  Partials      325      325           
Flag Coverage Δ
unittest 88.45% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
packages/eslint-plugin/src/util/misc.ts 98.63% <100.00%> (ø)

@@ -160,7 +160,7 @@ type RequireKeys<
> = ExcludeKeys<Obj, Keys> & { [k in Keys]-?: Exclude<Obj[k], undefined> };

function getEnumNames<T extends string>(myEnum: Record<T, unknown>): T[] {
return Object.keys(myEnum).filter(x => isNaN(parseInt(x))) as T[];
return Object.keys(myEnum).filter(x => isNaN(+x)) as T[];
Copy link
Member

Choose a reason for hiding this comment

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

Why wouldn't we use this?

Suggested change
return Object.keys(myEnum).filter(x => isNaN(+x)) as T[];
return Object.keys(myEnum).filter(x => isNaN(parseInt(x, 10))) as T[];

Copy link
Contributor Author

@abrahamguo abrahamguo Jul 21, 2024

Choose a reason for hiding this comment

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

I personally prefer using an operator instead of a function when available, especially since the + operator works more safely than parseInt does by default (i.e., + assumes base 10 by default). However, I'm happy to change it if you'd like

Copy link
Member

@kirkwaiblinger kirkwaiblinger Jul 21, 2024

Choose a reason for hiding this comment

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

Gotcha, I'm cool with it, just wanted to check to make sure there was intentionality 👍 . I can never quite keep straight the differences between parseInt() and Number()/+ but I trust and defer to your judgement here 🙂.

I would personally say I do much prefer the explicit style....

Suggested change
return Object.keys(myEnum).filter(x => isNaN(+x)) as T[];
return Object.keys(myEnum).filter(x => isNaN(Number(x))) as T[];

Up to you though! Other team members might have different opinions too 🤷

Copy link
Member

Choose a reason for hiding this comment

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

I also prefer Number(x) :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good! I have changed it to Number and added no-implicit-coercion (docs) to enforce the style. That rule does not report on any other code besides those two uses of the + operator.
Let me know if you'd prefer that in a separate PR

kirkwaiblinger
kirkwaiblinger previously approved these changes Jul 21, 2024
Copy link
Member

@kirkwaiblinger kirkwaiblinger left a comment

Choose a reason for hiding this comment

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

nice!

@kirkwaiblinger kirkwaiblinger merged commit 1e32db1 into typescript-eslint:main Jul 23, 2024
63 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants