-
Notifications
You must be signed in to change notification settings - Fork 8.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
Improvements for eslint-i18n-package #171588
Improvements for eslint-i18n-package #171588
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
bcee420
to
b6322a4
Compare
b6322a4
to
0e8d2bf
Compare
@elasticmachine merge upstream |
…/kibana into feat/eslint-translation-fixes
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
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.
Overall this looks good, some questions and small readability suggestions 👍🏼
packages/kbn-eslint-plugin-i18n/helpers/get_i18n_identifier_from_file_path.ts
Show resolved
Hide resolved
packages/kbn-eslint-plugin-i18n/helpers/get_i18n_identifier_from_file_path.ts
Outdated
Show resolved
Hide resolved
packages/kbn-eslint-plugin-i18n/helpers/get_i18n_identifier_from_file_path.ts
Outdated
Show resolved
Hide resolved
packages/kbn-eslint-plugin-i18n/helpers/get_i18n_identifier_from_file_path.ts
Outdated
Show resolved
Hide resolved
packages/kbn-eslint-plugin-i18n/rules/i18n_translate_should_start_with_the_right_id.test.ts
Show resolved
Hide resolved
packages/kbn-eslint-plugin-i18n/rules/i18n_translate_should_start_with_the_right_id.test.ts
Show resolved
Hide resolved
packages/kbn-eslint-plugin-i18n/rules/i18n_translate_should_start_with_the_right_id.ts
Outdated
Show resolved
Hide resolved
packages/kbn-eslint-plugin-i18n/rules/i18n_translate_should_start_with_the_right_id.ts
Outdated
Show resolved
Hide resolved
💚 Build Succeeded
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
Summary
Screen.Recording.2023-11-20.at.23.01.33.mov
This PR adds the following improvements to the ESLint i18n Translation package:
@kbn/i18n/i18n_translate_should_start_with_the_right_id
This rule checks every instance of
i18n.translate()
if the first parameter that is passed:It checks the repo for the
i18nrc.json
and/x-pack/i18nrc.json
files and determines what the right i18n identifier should be.If the parameter is missing or does not start with the right i18n identifier, it can autofix the parameter.
This rule is useful when defining translated values in plain functions (non-JSX), but it works in JSX as well.
Example
This code:
will be autofixed with:
If
i18n
has not been imported yet, the autofix will automatically add the import statement as well.Bug fixes:
strings_should_be_translated_with_formatted_message
rule has been removed for Obs plugins for now, as the autofix conflicts with thestrings_should_be_translated_with_i18n_translate
and ESLint does not provide a mechanism at present to prefer one autofix suggestion over the other./x-pack/parent_folder/plugin_folder/public
)server
andcommon
folders, i.e./x-pack/parent_folder/plugin_folder/server
)i18n
import lines are added correctly in files that don't have aReact
import yet.