From 390ba91d9328b2e74efd82c54115e69777445a56 Mon Sep 17 00:00:00 2001 From: Huzaifa Al Mesbah Date: Fri, 16 Oct 2026 17:57:13 +0600 Subject: [PATCH] Tooling: Fix the test:php, php-install, lint:css and docGen npm scripts - test:php and php-install used the phpunit and composer containers, which current versions of @wordpress/env no longer provide. Run them in tests-cli and cli instead. - lint:css linted the .ts/.tsx files in src as CSS. Lint only the .scss files, using the SCSS variant of the WordPress stylelint config. - Remove docGen, which pointed at a file that does not exist. - Split two .gitignore entries that had been merged onto one line. - Document the test and lint scripts in the README. Fixes #629. --- .gitignore | 3 ++- README.md | 9 +++++++++ package.json | 9 ++++----- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index a3f4f6a1..e3619bb4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,8 @@ .DS_Store # IDE-specific -.phpunit.result.cachecghooks.lock +.phpunit.result.cache +cghooks.lock # Vendor code /node_modules/ diff --git a/README.md b/README.md index cb7dcf5c..8b8c424b 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,15 @@ You will mainly need these two commands: `npm run build` - Transforms your code according to the configuration provided, so it’s ready for production and optimized for the best performance. `npm run start`- Transforms your code according to the configuration provided, so it’s ready for development. The script will automatically rebuild if you make changes to the code, and you will see the build errors in the console. +### Testing and linting + +With `wp-env` running: + +`npm run php-install` - Installs the Composer dependencies inside `wp-env`. +`npm run test:php` - Runs the PHPUnit tests inside `wp-env`. Extra PHPUnit arguments can be passed after `--`, e.g. `npm run test:php -- --filter Test_Model_Message`. + +`npm run lint:js` and `npm run lint:css` lint the JavaScript/TypeScript and SCSS source files. + ## Issue Workflow ### Creating an issue diff --git a/package.json b/package.json index de9fec75..6261f340 100644 --- a/package.json +++ b/package.json @@ -31,20 +31,19 @@ "start:storybook": "npm run start --workspace=storybook", "build": "wp-scripts build", "build:storybook": "npm run build --workspace=storybook", - "php-install": "wp-env run composer 'composer --ignore-platform-req=php install'", + "php-install": "wp-env run cli --env-cwd=wp-content/plugins/wp-feature-notifications composer install --ignore-platform-req=php", "packages-update": "wp-scripts packages-update", "check-engines": "wp-scripts check-engines", "check-licenses": "wp-scripts check-licenses", "format": "wp-scripts format", - "lint:css": "wp-scripts lint-style ./src", + "lint:css": "wp-scripts lint-style \"src/**/*.scss\"", "lint:js": "wp-scripts lint-js ./src", "lint:md:docs": "wp-scripts lint-md-docs ./src", "lint:pkg-json": "wp-scripts lint-pkg-json ./src", "plugin-zip": "wp-scripts plugin-zip", "test:js": "echo \"🚧 TEST JS: WE'LL THINK ABOUT IT LATER 🚧\" && exit 0", - "test:php": "wp-env run phpunit 'phpunit --configuration=/var/www/html/wp-content/plugins/wp-feature-notifications/phpunit.xml.dist'", + "test:php": "wp-env run tests-cli --env-cwd=wp-content/plugins/wp-feature-notifications vendor/bin/phpunit", "test": "npm run test:php && npm run test:js", - "docGen": "npx docgen src/scripts/wp-notifications.js", "prepare": "husky" }, "repository": { @@ -84,7 +83,7 @@ "prettier": "@wordpress/prettier-config", "stylelint": { "extends": [ - "@wordpress/stylelint-config" + "@wordpress/stylelint-config/scss" ] } }