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

Update: support numeric separators (refs #13568) #13581

Merged
merged 3 commits into from Aug 29, 2020
Merged

Conversation

mdjermanovic
Copy link
Member

@mdjermanovic mdjermanovic commented Aug 18, 2020

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[X] Other, please explain:

refs #13568

Adds support for numeric separators (along with PR #13574).

What changes did you make? (Give an overview)

  • Updated the regex used by astUtils.isDecimalInteger and isDecimalIntegerNumericToken. Also added tests for these helpers and some tests for rules that are using them.
  • Added tests for prefer-numeric-literals and quote-props rules.

In total, this is one line of code + tests and comments.

Is there anything you'd like reviewers to focus on?

@mdjermanovic mdjermanovic added rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion do not merge This pull request should not be merged yet new syntax This issue is related to new syntax that has reached stage 4 labels Aug 18, 2020
@anikethsaha
Copy link
Member

  • package.json should be updated before merging.

I suppose that would be in a separate PR #13568 (comment)

const DECIMAL_INTEGER_PATTERN = /^(0|[1-9]\d*)$/u;
const DECIMAL_INTEGER_PATTERN = /^(0|[1-9](?:_?\d)*)$/u;
Copy link
Member Author

Choose a reason for hiding this comment

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

This actually had a bug: it doesn't recognize NonOctalDecimalIntegerLiteral literals, like 08.

I think we can fix this later since it's an existing edge-case bug that isn't related to numeric separators and requires a non-trivial change.

Copy link
Member

Choose a reason for hiding this comment

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

Mind making an issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

Opened #13588

@mdjermanovic mdjermanovic removed the do not merge This pull request should not be merged yet label Aug 24, 2020
Copy link
Member

@btmills btmills left a comment

Choose a reason for hiding this comment

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

LGTM. The additional tests you added are very thorough.

},
{

// this would be indeed the same as `0x0_0`, but there's no need to autofix this edge case that looks more like a mistake.
Copy link
Member

Choose a reason for hiding this comment

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

Agreed that we don't need to handle this, and I appreciate that you noticed the edge case exists and added an explicit test for it 👍

Copy link
Member

@kaicataldo kaicataldo left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@kaicataldo kaicataldo merged commit 0003dc0 into master Aug 29, 2020
@kaicataldo kaicataldo deleted the numeric-separators branch August 29, 2020 00:35
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Mar 18, 2021
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Mar 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion new syntax This issue is related to new syntax that has reached stage 4 rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants