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

package.json Cleanup #417

Open
kevinfodness opened this issue Jan 17, 2025 · 1 comment
Open

package.json Cleanup #417

kevinfodness opened this issue Jan 17, 2025 · 1 comment
Labels
enhancement New feature or request javascript Requires understanding JavaScript

Comments

@kevinfodness
Copy link
Member

kevinfodness commented Jan 17, 2025

Description

We should implement some changes to package.json to bring it in line with our current standards:

  1. Remove check-node-version package and pre* steps. The specific version of node to be used is handled in PR checks and in deploy steps via our reusable GitHub Actions. The only purpose for this is to prevent developers who are working locally from using the wrong version of node, but it adds overhead to every action taken on npm scripts, both locally and in CI. Let's simplify the config and reduce dependencies by removing it.
  2. Add the --noEmit flag to tsc in the check-types script to ensure that no output is ever written when types are being checked.
  3. Rename the lint script to eslint and remove the check-types call from the script. Running npm run eslint should only ever run the eslint check. Also rename the lint:watch command to eslint:watch.
  4. Rename test to jest and test:watch to jest:watch.
  5. Create a new test command that invokes check-types, eslint, stylelint, and jest. This is because the reusable GitHub Action for running node tests will run npm run test by default, and currently the only thing being checked by that command is Jest, so this change will ensure that all of the required tests are being run on PR checks (audit and build are run separately).
  6. Update dist-tag to 6.7 for the version of WP dependencies that we're using. CI has already kept the actual versions of packages up-to-date but the command should reflect the current latest version of WP.
  7. Downgrade React to 18.3 (current version in use by WP) and tell Dependabot not to upgrade it (see comment below).
  8. Remove prop-types package (use TypeScript and default values in destructuring instead).
  9. Remove react-dom package (only needed when creating a new React app on the frontend, can be added by implementers later if necessary).
  10. Remove @alleyinteractive/create-entry package (invoked via npx, doesn't need to be in the project's devDependencies).
  11. Remove all of the @types packages since referenced packages export their own types now.
  12. Install ajv package (bug in wp-scripts causes builds to crash if this package doesn't exist - can be removed later if this is fixed by WP or in our build-tool package in block-editor-tools).
  13. Remove .npmrc file forcing the use of legacy-peer-deps which is no longer needed.
  14. Recompile package-lock.json after these changes are made (remove node_modules folder, remove package-lock.json, reinstall). Confirm this works on both macOS and on Linux systems (npm ci should succeed on both and scripts should succeed on both, including the new test command and the build command).

Use Case

Users of this package should get the latest set of node/JavaScript configuration.

@kevinfodness kevinfodness added enhancement New feature or request javascript Requires understanding JavaScript labels Jan 17, 2025
@mogmarsh
Copy link
Contributor

if CI caused the updates to React, that can be disabled by adding

ignore:
      - dependency-name: "react"

to dependabot.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request javascript Requires understanding JavaScript
Projects
None yet
Development

No branches or pull requests

2 participants