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

Use \d for [0-9] #3097

Merged
merged 1 commit into from
Oct 5, 2021
Merged

Use \d for [0-9] #3097

merged 1 commit into from
Oct 5, 2021

Conversation

valtlai
Copy link
Contributor

@valtlai valtlai commented Sep 27, 2021

Like #1107. Also [\d.] for [0-9.] and [\d_] for [0-9_].

@github-actions
Copy link

github-actions bot commented Sep 27, 2021

JS File Size Changes (gzipped)

A total of 7 files have changed, with a combined diff of -4 B (-0.1%).

file master pull size diff % diff
components/prism-cil.min.js 1.11 KB 1.12 KB +3 B +0.3%
components/prism-http.min.js 658 B 656 B -2 B -0.3%
components/prism-jsstacktrace.min.js 411 B 408 B -3 B -0.7%
components/prism-mongodb.min.js 1.47 KB 1.47 KB +1 B +0.1%
components/prism-psl.min.js 1.64 KB 1.64 KB -1 B -0.1%
components/prism-tremor.min.js 811 B 812 B +1 B +0.1%
components/prism-typoscript.min.js 710 B 707 B -3 B -0.4%

Generated by 🚫 dangerJS against 53a8727

@RunDevelopment
Copy link
Member

Thank you for the PR @valtlai!

While I do agree that \d is better than [0-9], I don't think that replacing 0-9 within character classes like [0-9a-f] with \d improves readability.

Also, we should probably use the regexp/prefer-d rule to enforce this. I opened an issue for this: ota-meshi/eslint-plugin-regexp#341

@RunDevelopment
Copy link
Member

My addition to regexp/prefer-d was just merged and will be part of the next release.

Like #1107. Also `[\d.]` for `[0-9.]` and `[\d_]` for `[0-9_]`.
@valtlai
Copy link
Contributor Author

valtlai commented Oct 5, 2021

I edited this PR to only replace [0-9] with \d, [0-9.] with [\d.] and [0-9_] with [\d_], so character classes like [0-9a-z] are kept as is.

@RunDevelopment RunDevelopment merged commit 9fe2f93 into PrismJS:master Oct 5, 2021
@RunDevelopment
Copy link
Member

Thank you for contributing @valtlai!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants