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

ESLint: Improve regex for valid-sprintf rule to handle '%%' #68270

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

im3dabasia
Copy link
Contributor

Fixes: #52787

What?

Updated the regex in the valid-sprintf ESLint rule to correctly handle escaped percent signs (%%). Added 4 new test cases that cover various scenarios involving %%.

Why?

The current regex fails to handle cases like sprintf('Rotated at %d %% degrees', 90) by mistakenly flagging valid format strings with escaped percent signs as incorrect. This update ensures proper handling of %d %% and similar cases.

Screenshots or screencast

Screenshot 2024-12-24 at 5 24 38 PM

Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: im3dabasia <[email protected]>
Co-authored-by: colorful-tones <[email protected]>
Co-authored-by: swissspidy <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka Mamaduka added [Type] Enhancement A suggestion for improvement. Internationalization (i18n) Issues or PRs related to internationalization efforts [Tool] ESLint plugin /packages/eslint-plugin labels Dec 24, 2024
@Mamaduka Mamaduka requested a review from swissspidy December 24, 2024 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internationalization (i18n) Issues or PRs related to internationalization efforts [Tool] ESLint plugin /packages/eslint-plugin [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ESLint: Improve regex for valid-sprintf rule
2 participants