-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
First pass at I18N-specific ESLint rules #20555
Conversation
Size Change: +2 B (0%) Total Size: 884 kB
ℹ️ View Unchanged
|
These rules work great! What's left here before this can be merged? |
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.
Looking good 👍
I raised it earlier and now it's reported by JimSchofield in #21920 (i18n ESlint rules do not correctly default text-domain). Any thoughts about how to make things easier for 3rd party projects to use the default ESLint ruleset? |
I missed in my review that all rules should be included in the table listing in the root README.md of https://github.com/WordPress/gutenberg/blob/master/packages/eslint-plugin/README.md#rules Fix proposed at: #22042 |
Description
This PR adds new I18N-related ESLint rules to
@wordpress/eslint-plugin
and leverages them in Gutenberg. Changes in this PR:@wordpress/i18n-text-domain
makes sure the text domain is not forgotten and matches a whitelist of allowed text domains. For WordPress projects, using the default domain (
'default'
) can be allowed. This rule is also partially auto-fixable!@wordpress/i18n-translator-comments
makes sure any translation functions with placeholders in them have accompanying translator comments.
@wordpress/i18n-no-variables
Enforce string literals as translation function arguments
@wordpress/i18n-no-placeholders-only
Prevent using only placeholders in translatable strings
@wordpress/i18n-no-collapsible-whitespace
Disallow collapsible whitespace in translatable strings.
@wordpress/i18n-ellipsis
Disallow using three dots in translatable strings
i18n
ruleset that includes all i18n-related rules and is included in therecommended
ruleset.valid-sprintf
rule has been moved from thecustom
ruleset to thei18n
ruleset.See #19777 for context.
I might work on more enhancements mentioned on that issue depending on usefulness and demand. Please leave a comment there with any suggestions!
How has this been tested?
Rigorous unit tests as well as application of the new rules against the Gutenberg code base.
Types of changes
New feature (non-breaking change which adds functionality)
Checklist: