-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 Plugin: Add I18N ESLint rules #19777
Comments
I have a working version of text domain validation ready, will push it soon.
This is currently enforced using gutenberg/packages/eslint-plugin/configs/custom.js Lines 8 to 28 in 4ea0668
Should be fairly easy to port this to its own proper rule. |
Some cases, off the top of my head:
Might even be fixable by wrapping the found strings in |
It looks like a lot of tasks listed are done. Excellent work! There is only one left on the list that was initially marked as “likely to do”. @swissspidy, what would be your current recommendation on criteria to consider this issue finished? |
I was just thinking the pther day that a rule for catching trailing whitespace would be nice. See https://core.trac.wordpress.org/ticket/55669 This mistake wasn‘t caught in the Gutenberg code base. |
I agree that it would be great to cover as much as possible from the cases that slipped through WP 6.0 Beta phase from the Gutenberg repository ❤️ |
Looks like the rule was only enabled for React Native code and not the whole code base 🙃 @jhnstn Do you recall why it wasn't considered to apply the |
It would be great to find out and potentially enable for the rest of Gutenberg 👍🏻 |
Is your feature request related to a problem? Please describe.
Similar to the i18n sniffs in WPCS there could be some custom ESLint rules to catch some common i18n mistakes.
Describe the solution you'd like
Off the top of my head, there could be rules like follows:
Done
default
instead of just omitting it)sprintf
with placeholdersNot using numbered placeholders when using-> tracked separately in sprintf ESLint rule does not check for numbered placeholders #20554.%s
andsprintf
Likely to-do
gutenberg/.eslintrc.js
Lines 70 to 87 in 622362a
gutenberg/.eslintrc.js
Lines 88 to 92 in 622362a
%s
placeholders instead (e.g. URLs)On the fence
Needs some way to detect whether text is passed as a prop or child that should probably be translatable (e.g.
aria-label
prop). Helps catch places where__()
is forgotten.__()
(e.g.__( 'Hello' + '' + 'World' )
_x()
instead of__()
under certain conditions (needs list of ambiguous terms)__experimentalCreateInterpolateElement
__experimentalCreateInterpolateElement
defaultProps
(when using prop-types)Actual implementation should be split up into multiple PRs.
Describe alternatives you've considered
Find other solutions out there that likely won't work with
@wordpress/i18n
or build something custom.The text was updated successfully, but these errors were encountered: