Skip to content

Adds enforcement of WordPress's i18n rules#22042

Merged
mhkuu merged 8 commits intotrunkfrom
add/eslint-config-i18n
Feb 21, 2025
Merged

Adds enforcement of WordPress's i18n rules#22042
mhkuu merged 8 commits intotrunkfrom
add/eslint-config-i18n

Conversation

@mhkuu
Copy link
Copy Markdown
Contributor

@mhkuu mhkuu commented Feb 14, 2025

Context

  • We want to adhere to WordPress's i18n rules, throughout our plugin. This PR adds an eslint plugin to our generic eslint config for that purpose. As a result, we can also use this configuration elsewhere.

Summary

This PR can be summarized in the following changelog entry:

  • Adds enforcement of WordPress's i18n rules.
  • [yoastseo] Adds enforcement of WordPress's i18n rules.

Relevant technical choices:

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Run the linter with yarn lint, confirm the number of warnings is below the threshold.
  • Run the tests with yarn test, confirm they all pass.
  • Do a smoke test in the application.

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

  • No further impact.

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes https://github.com/Yoast/lingo-other-tasks/issues/456

@mhkuu mhkuu added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Feb 14, 2025
@mhkuu mhkuu marked this pull request as ready for review February 14, 2025 08:12
Copy link
Copy Markdown
Contributor

@rohans456 rohans456 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is a solid step towards improving the i18n quality of the yoastseo package. The changes are well-structured, and the use of compatibility tools (flatCompat.extends and fixupConfigRules) is correctly implemented. I’ve suggested a small optimization to reduce redundant processing and improve performance.

Comment thread packages/yoastseo/eslint.config.mjs Outdated
export default [
{ ignores: [ "build", "vendor", "examples" ] },
...yoastConfig,
...fixupConfigRules( flatCompat.extends( "plugin:@wordpress/eslint-plugin/i18n" ) ),
Copy link
Copy Markdown
Contributor

@rohans456 rohans456 Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Calling flatCompat.extends(...) inside an array spread could add unnecessary processing overhead.
  • Consider storing the result in a variable before applying fixupConfigRules, like:
const wordpressRules = flatCompat.extends("plugin:@wordpress/eslint-plugin/i18n");
...fixupConfigRules(wordpressRules),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've applied this when moving the rules to the generic config in packages/eslint/default.mjs 🎉

@github-actions
Copy link
Copy Markdown

A merge conflict has been detected for the proposed code changes in this PR. Please resolve the conflict by either rebasing the PR or merging in changes from the base branch.

@github-actions
Copy link
Copy Markdown

@mhkuu Please be aware that following packages have been abandoned and are not actively maintained anymore:

Package name Path
@yoast/babel-preset packages/babel-preset
@yoast/components packages/components
@yoast/e2e-tests packages/e2e-tests
@yoast/helpers packages/helpers
@yoast/jest-preset packages/jest-preset
@yoast/style-guide packages/style-guide

Please consider using the other packages instead.

@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 5b91beb8f200401be1924eae61d8391df50808f0

Details

  • 11 of 18 (61.11%) changed or added relevant lines in 9 files are covered.
  • 2 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.001%) to 53.216%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/js/src/components/WincherPerformanceReport.js 0 1 0.0%
packages/js/src/insights/components/flesch-reading-ease.js 0 1 0.0%
packages/js/src/first-time-configuration/tailwind-components/steps/site-representation/person-section.js 0 2 0.0%
packages/js/src/structured-data-blocks/how-to/legacy/utils/8.2.js 0 3 0.0%
Files with Coverage Reduction New Missed Lines %
packages/js/src/first-time-configuration/tailwind-components/steps/site-representation/person-section.js 1 0.0%
packages/js/src/import.js 1 0.0%
Totals Coverage Status
Change from base Build 61f494b7eed6e03cd1518dc37ed23c600b4c19fd: -0.001%
Covered Lines: 30280
Relevant Lines: 57691

💛 - Coveralls

@mhkuu
Copy link
Copy Markdown
Contributor Author

mhkuu commented Feb 20, 2025

After a discussion with @FAMarfuaty we decided to move the configuration to the generic ESLint config in packages/eslint/default.mjs. That was done in 9393d39, also applying the suggestion from the code review above. Then, in 7b5b390, the errors were resolved for all the other JS packages, and in 4093f43, the unit tests were updated.

@mhkuu mhkuu added this to the 24.7 milestone Feb 21, 2025
@mhkuu
Copy link
Copy Markdown
Contributor Author

mhkuu commented Feb 21, 2025

CR/ACC by @rohans456: ✅

@mhkuu mhkuu merged commit ea2fc96 into trunk Feb 21, 2025
@mhkuu mhkuu deleted the add/eslint-config-i18n branch February 21, 2025 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants