-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat(eslint): add i18n eslint plugin #362
base: master
Are you sure you want to change the base?
Conversation
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.
Adding it like this would be fine with me, but we could also look into perhaps declaring a few attribute names where we do want to enforce i18n
.
config/js/eslint-react.config.js
Outdated
@@ -14,6 +16,10 @@ module.exports = { | |||
}, | |||
|
|||
rules: { | |||
'i18next/no-literal-string': [ | |||
'warn', | |||
{ markupOnly: true, onlyAttribute: [''] }, |
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.
Perhaps we could change this so that label
and displayName
attributes would require i18n
?
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.
Yeah I could do that. Is it necessary to translate displayName though? That's only for developers right?
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.
I've enabled it for label
in 4e5acac. I've not enabled it for displayName as that's only used in error messages and not user facing.
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.
This comment has been minimized.
This comment has been minimized.
Hi! Due to a lack of activity on this issue over time (180 days) it seems to be stale. If still relevant, please provide information that moves it forward, e.g. additional information, a pull request with suggested changes, or a reason to keep it open. Any activity will keep it open, otherwise it will be closed automatically in 30 days. Thanks! 🤖 |
Automatically closing due to lack of activity. 🤖 |
See this slack thread: https://dhis2.slack.com/archives/CPGUFVC56/p1615363540343500
This adds https://github.com/edvardchen/eslint-plugin-i18next, which warns on untranslated strings in jsx. The settings are what I've been using in the scheduler. We could tweak them a bit more later on, and for example add linting of certain attributes as well. I'm ignoring this rule for test files, as react components defined in test files won't be shipped to the end user.
I've set it to warn initially so that it's not a breaking change and to allow us to try it out first. Once we're happy with it we could move it to error and fine-tune the rule.