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
Breaking: some rules recognize bigint literals (fixes #11803) #12701
Merged
Merged
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
debb953
update no-magic-numbers to recognize bigint
mysticatea 4c12c64
update yoda to recognize bigint
mysticatea a6758e0
add a no-extend-native test
mysticatea 3c3cd00
update ci.yml temporary (this PR is blocked by #12700)
mysticatea 513f507
add astUtils.isNumericLiteral and use it in some rules
mysticatea 4475a58
Merge branch 'master' into issue11803
mysticatea 339f932
update no-dupe-class-members
mysticatea 4bfdcb1
update no-magic-number to support bigint in options
mysticatea 7ae3a85
update some rules to use getStaticPropertyName
mysticatea 0921b79
update quote-props
mysticatea 97f38f1
revert no-useless-computed-key change
mysticatea fbcddfc
revert "allowing {type: 'bigint'}" and update no-magic-number
mysticatea 49b7c70
Merge remote-tracking branch 'origin/master' into issue11803
mysticatea 3695321
no-magic-number 'ignores' allows negative bigint
mysticatea File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker: For my own understanding, is there a reason we're checking the presence of this property versus using
typeof
like we are below? I wonder if it would be nice to addastUtils.isNumber()
and use it everywhere?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have noticed after I wrote this, it's no problem if it's
typeof node.value === "number" || typeof node.value === "bigint"
.The reason for checking
node.bigint
was thatnode.value
will be null if the runtime doesn't support bigint natively. However, Node.js 10.4.0 supports bigint and ESLint 7 requires 10.11.0, so it's not a problem.astUtils.isNumeric()
or someting like is a good idea.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does bigint support matter tho?
typeof x === 'bigint'
will just befalse
in an engine that doesn't support bigint.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a source code
1n
is given, ESLint expects the AST to be{ type: "Literal", value: 1n }
. However, if the runtime doesn't support BigInt natively, the AST will be{ type: "Literal", value: null }
thentypeof node.value
becomes a wrong value.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that seems like a pretty big flaw in the thing that generates the AST - it should probably supply enough information to know that the value isn't a literal null.