Skip to content

Conversation

@Sysix
Copy link
Member

@Sysix Sysix commented Apr 29, 2025

I merged after I read about the parse* functions.
The isFinite and isNaN should be dangerous fixes:

isFinite("0"); // true; coerced to number 0
Number.isFinite("0"); // false
isFinite(null); // true; coerced to number 0
Number.isFinite(null); // false

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite

As opposed to the global isNaN() function, the Number.isNaN() method doesn't force-convert the parameter to a number. This makes it safe to pass values that would normally convert to NaN but aren't actually the same value as NaN. This also means that only values of the Number type that are also NaN return true.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN

@github-actions github-actions bot added A-linter Area - Linter C-bug Category - Bug labels Apr 29, 2025
Copy link
Member Author

Sysix commented Apr 29, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Sysix Sysix requested a review from camc314 April 29, 2025 21:14
@Sysix Sysix marked this pull request as ready for review April 29, 2025 21:14
@Sysix Sysix changed the title fix(linter): mark isNan and isFinite as dangerous fixes in unicorn/prefer-number-properties fix(linter): mark isNan and isFinite as dangerous fixes in unicorn/prefer-number-properties Apr 29, 2025
Copy link
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

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

thanks!

@codspeed-hq
Copy link

codspeed-hq bot commented Apr 29, 2025

CodSpeed Instrumentation Performance Report

Merging #10706 will not alter performance

Comparing 04-29-fix_linter_mark_isnan_and_isfinite_as_dangerous_fixes_in_unicorn_prefer-number-properties_ (a88e349) with main (f4ab05f)

Summary

✅ 36 untouched benchmarks

@Sysix Sysix marked this pull request as draft April 29, 2025 21:20
@Sysix
Copy link
Member Author

Sysix commented Apr 29, 2025

There are some more fixes, did not really read the file 👀

EDIT: wanted to create a new function but got stuck with the param hints and my broken rust-analyzer :/

@Sysix Sysix force-pushed the 04-29-fix_linter_mark_isnan_and_isfinite_as_dangerous_fixes_in_unicorn_prefer-number-properties_ branch from 7e05139 to 93a7968 Compare April 29, 2025 21:36
@Sysix Sysix marked this pull request as ready for review April 29, 2025 21:38
@Sysix Sysix requested a review from camc314 April 29, 2025 21:38
Copy link
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

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

i wonder wheter it's work adding an api like

ctx.diagnostic_with_fix_kind(diagnostic, FixKind::Dangerous, | fixer | {} )

@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Apr 30, 2025
Copy link
Contributor

camc314 commented Apr 30, 2025

Merge activity

graphite-app bot pushed a commit that referenced this pull request Apr 30, 2025
…rn/prefer-number-properties` (#10706)

I merged after I read about the `parse*` functions.
The `isFinite` and `isNaN` should be dangerous fixes:

```
isFinite("0"); // true; coerced to number 0
Number.isFinite("0"); // false
isFinite(null); // true; coerced to number 0
Number.isFinite(null); // false
```
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite

> As opposed to the global [isNaN()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN) function, the Number.isNaN() method doesn't force-convert the parameter to a number. This makes it safe to pass values that would normally convert to [NaN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN) but aren't actually the same value as [NaN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN). This also means that only values of the Number type that are also [NaN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN) return true.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN
@graphite-app graphite-app bot force-pushed the 04-29-fix_linter_mark_isnan_and_isfinite_as_dangerous_fixes_in_unicorn_prefer-number-properties_ branch from 93a7968 to 0ee15cd Compare April 30, 2025 07:53
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Apr 30, 2025
@Sysix Sysix added the 0-merge Merge with Graphite Merge Queue label Apr 30, 2025
…rn/prefer-number-properties` (#10706)

I merged after I read about the `parse*` functions.
The `isFinite` and `isNaN` should be dangerous fixes:

```
isFinite("0"); // true; coerced to number 0
Number.isFinite("0"); // false
isFinite(null); // true; coerced to number 0
Number.isFinite(null); // false
```
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite

> As opposed to the global [isNaN()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN) function, the Number.isNaN() method doesn't force-convert the parameter to a number. This makes it safe to pass values that would normally convert to [NaN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN) but aren't actually the same value as [NaN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN). This also means that only values of the Number type that are also [NaN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN) return true.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN
@camc314 camc314 force-pushed the 04-29-fix_linter_mark_isnan_and_isfinite_as_dangerous_fixes_in_unicorn_prefer-number-properties_ branch from 0ee15cd to a88e349 Compare April 30, 2025 10:59
@graphite-app graphite-app bot merged commit a88e349 into main Apr 30, 2025
26 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Apr 30, 2025
@graphite-app graphite-app bot deleted the 04-29-fix_linter_mark_isnan_and_isfinite_as_dangerous_fixes_in_unicorn_prefer-number-properties_ branch April 30, 2025 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants