WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.5k stars 4.2k forks source link

ESLint: Improve regex for `valid-sprintf` rule #52787

Open swissspidy opened 1 year ago

swissspidy commented 1 year ago

What problem does this address?

Code like sprintf( 'Rotated at %d%% degrees', 90 ) is totally fine, yet the valid-sprintf rule currently flags this.

The PHP counterpart does not flag this as it uses a different regex, see https://github.com/WordPress/WordPress-Coding-Standards/blob/1767f3a1169407d84f1d17e4cd9d80844d693e9e/WordPress/Sniffs/WP/I18nSniff.php#L45-L68

What is your proposed solution?

Improve the regex so that cases like %d%% or %d %% are not flagged as multiple unordered placeholders.

colorful-tones commented 6 months ago

@swissspidy could this be a duplicate of this? https://github.com/WordPress/gutenberg/issues/47794

swissspidy commented 6 months ago

No relation at all!