Skip to content
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

Improve linting and watching JS #21315

Merged
merged 21 commits into from
Apr 23, 2024
Merged

Improve linting and watching JS #21315

merged 21 commits into from
Apr 23, 2024

Conversation

igorschoester
Copy link
Member

@igorschoester igorschoester commented Apr 13, 2024

Context

  • Mostly, I got triggered by the yarn start not working and grunt shell:webpack-watch looping.

Summary

This PR can be summarized in the following changelog entry:

  • Fixes yarn start command, and it replaces the grunt shell:webpack-watch command.
  • Replaces grunt shell:webpack with either grunt shell:yarn:build --scope @yoast/wordpress-seo or yarn build --scope @yoast/wordpress-seo
  • Replaces grunt shell:webpack-prod with either grunt shell:yarn-prod:build--scope @yoast/wordpress-seo or NODE_ENV=production yarn build --scope @yoast/wordpress-seo
  • Replaces grunt shell:build-packages with either grunt shell:yarn:build --ignore @yoast/wordpress-seo or yarn build --ignore @yoast/wordpress-seo
  • Replaces grunt shell:build-packages-prod with either grunt shell:yarn-prod:build --ignore @yoast/wordpress-seo or NODE_ENV=production yarn build --ignore @yoast/wordpress-seo
  • Expands yarn lint to also check the tooling, splitting to yarn lint:packages and yarn lint:tooling.
  • Removes unused Grunt commands.
  • Removes unused dependencies.
  • Removes verbose test output from yarn test command, if you still want output like before append --stream.
  • Fixes the webpack config' optimization, by re-adding the WP scripts default.
  • Removes webpack config building exclusions: our own packages, WP packages, parse5 and chart.js; Relying on them already being built.
  • Upgrades ESLint and plugins (import, jsx-a11y and react) to the latest versions.
  • [@yoast/analysis-report 0.1.0] Upgrades ESLint and plugins (import, jsx-a11y and react) to the latest versions.
  • [@yoast/replacement-variable-editor 0.1.0] Upgrades ESLint and plugins (import, jsx-a11y and react) to the latest versions.
  • [@yoast/search-metadata-previews 0.1.0] Upgrades ESLint and plugins (import, jsx-a11y and react) to the latest versions.
  • [@yoast/ui-library 0.1.0] Upgrades ESLint and plugins (import, jsx-a11y and react) to the latest versions.
  • [@yoast/babel-preset 0.1.0 enhancement] Removes source-maps generation in production environment.

Relevant technical choices:

Fix start script
Removing the prestart, the copy command does not exist and the the CSS is a side-effect.
Specified the --webpack-src-dir to prevent an infinite loop from the watching.

Remove JS deps from root
These are dependencies from packages/js?
Kind of in between I suppose, because we do build packages/js via the root. And draft-js is built as an external in the plugin build. But I think packages/js should determine which versions.

Grunt tasks
Replacing specific shell commands with an abstract Yarn one so we can call any command.
Moving the NODE_ENV setting out of the scripts themselves and into the shell commands. From the terminal you can specify it yourself, but we are more precise in our Grunt tasks.

Webpack config
Since we are transpiling separately from bundling, we no longer need the exceptions inside the node_modules folder. And maybe some were already not needed?
Adding the optimization back from the default, I am assuming that was accidentally removed by adding another key.
Removing packages check, I think this is a remnant from the yoastseo/src imports that we no longer have.

Linting
Added linting over our tooling (at root level at least).

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Devs: please check the tooling
    • Run grunt build
      • Do a smoke test
    • Run grunt release
      • Verify there are no source-maps for JS files (check js/dist)
      • Do a smoke test
    • Run grunt watch
      • Changing tooling file should trigger the tooling linting
      • Changing JS file inside packages should trigger build and linting of the packages
      • Changing JS test file inside packages/js/tests should trigger linting of just packages/js
    • Run yarn test
      • It no longer always outputs all the things, if you want the previous behavior you have to add --stream to the command
    • Run yarn lint
      • Verify it runs both yarn lint:packages and yarn lint:tooling
    • Run yarn start
      • Verify it rebuilds when changing some code, and mostly that it is not stuck in some loop that keeps rebuilding
  • Smoke test like usual, but extra checks on:
    • the replacement variable editor due to the removed deps from the root
    • the analysis (yoastseo) due to the no longer building of parse5
      • Lingo suggested to test the H1 assessment
      • Edit a post in the block editor
      • Add two H1 headings to the content
      • Verify the SEO analysis detected a problem:
        • Single title: H1s should only be used as your main title. Find all H1s in your text that aren't your main title and change them to a lower heading level!

    • the wincher integration due to the no longer building of chart.js
      • Activate Premium
      • Edit a post in the block editor
      • Add a focus keyphrase
      • Go to Track SEO performance
      • Toggle Tracking on, a graph should appear (single dot if never tracked before)

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:

  • Since it is tooling, no need to specifically test these changes. The normal smoke testing should suffice.

Impact check

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

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 #

* specify webpack src to avoid getting into a build loop
* remove pre side effect:
  * don't enforce building CSS before
  * remove unknown copy command
* fix jest env troubles in JS package: not sure why the jest eslint plugin doesn't pick up the jest/globals env anymore
* fix react/display name in yoastseo, even though the function is not React
* ignore react/no-deprecated in to-be-remove yoast-components package
* remove obsolete --no-sort
In favor of adding it yourself if wanted:
* remove --stream
* remove --
No longer needed now that packages transpile themselves
Not sure about Parse5, so leaving that
Chart.js is ignored if removing it, even though it is an entry too, not sure why
The monorepo symlinks all the packages in the node_modules, so they end up the same in the bundle
@igorschoester igorschoester added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Apr 13, 2024
@igorschoester igorschoester requested a review from a team as a code owner April 13, 2024 07:31
Copy link

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

Package name Path
yoast-components packages/yoast-components
@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

Pull Request Test Coverage Report for Build e3fadd5e21d8a9c6a958f917beaa1ffc635cae55

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 52.21%

Totals Coverage Status
Change from base Build 199aec6cb137c3bbf3fc1f0fa86edc98de12b256: 0.0%
Covered Lines: 28515
Relevant Lines: 55179

💛 - Coveralls

@pls78 pls78 self-assigned this Apr 22, 2024
@pls78 pls78 added this to the 22.7 milestone Apr 23, 2024
Copy link
Member

@pls78 pls78 left a comment

Choose a reason for hiding this comment

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

CR && Acc: ✅

@pls78 pls78 merged commit 447fe11 into trunk Apr 23, 2024
18 checks passed
@pls78 pls78 deleted the igor/improve-tooling branch April 23, 2024 10:09
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