From b94c1723ec06722c612f9ebc47f263925ef29c17 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Tue, 5 May 2026 16:47:03 +0530 Subject: [PATCH] Add Syncpack to lint dependency version consistency across workspaces --- .github/workflows/static-checks.yml | 3 + package-lock.json | 163 ++++++++++++++++++++++++++++ package.json | 5 +- syncpack.config.mjs | 29 +++++ 4 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 syncpack.config.mjs diff --git a/.github/workflows/static-checks.yml b/.github/workflows/static-checks.yml index 52f3c9ba579079..6f6b683c1adead 100644 --- a/.github/workflows/static-checks.yml +++ b/.github/workflows/static-checks.yml @@ -73,6 +73,9 @@ jobs: - name: Lint package.json files run: npm run lint:pkg-json + - name: Lint dependency versions across workspaces + run: npm run lint:deps + - name: Lint package-lock.json file run: npm run lint:lockfile diff --git a/package-lock.json b/package-lock.json index 85c5d832866388..d279dd7d82c866 100644 --- a/package-lock.json +++ b/package-lock.json @@ -85,6 +85,7 @@ "sprintf-js": "1.1.1", "style-loader": "3.2.1", "stylelint-plugin-logical-css": "^1.2.3", + "syncpack": "^15.1.2", "typescript": "6.0.2", "wait-on": "8.0.1" }, @@ -52961,6 +52962,168 @@ "url": "https://opencollective.com/synckit" } }, + "node_modules/syncpack": { + "version": "15.1.2", + "resolved": "https://registry.npmjs.org/syncpack/-/syncpack-15.1.2.tgz", + "integrity": "sha512-LDDT44/Skk5r6cDsbemGPD1t8p40iBqWz0Kkj5Khmx/e4blaXSA+nckYepHgb9xLY8Be+xuS0gVWHsYjKZufIw==", + "dev": true, + "license": "MIT", + "bin": { + "syncpack": "index.cjs" + }, + "engines": { + "node": ">=14.17.0" + }, + "funding": { + "url": "https://github.com/sponsors/JamieMason" + }, + "optionalDependencies": { + "syncpack-darwin-arm64": "15.1.2", + "syncpack-darwin-x64": "15.1.2", + "syncpack-linux-arm64": "15.1.2", + "syncpack-linux-arm64-musl": "15.1.2", + "syncpack-linux-x64": "15.1.2", + "syncpack-linux-x64-musl": "15.1.2", + "syncpack-windows-arm64": "15.1.2", + "syncpack-windows-x64": "15.1.2" + } + }, + "node_modules/syncpack-darwin-arm64": { + "version": "15.1.2", + "resolved": "https://registry.npmjs.org/syncpack-darwin-arm64/-/syncpack-darwin-arm64-15.1.2.tgz", + "integrity": "sha512-RQET2RNmX7yKorqCE6Q7kppC7eT9lw742QYPfWIL8Nh26RerT+erOp8zhdgv/3OmDkETF9olqyts79HY48V4SA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://github.com/sponsors/JamieMason" + } + }, + "node_modules/syncpack-darwin-x64": { + "version": "15.1.2", + "resolved": "https://registry.npmjs.org/syncpack-darwin-x64/-/syncpack-darwin-x64-15.1.2.tgz", + "integrity": "sha512-pmVr4Qw5o42aUfeZVaPXmnQNaoMhBNywcFK24FqSlo3MCK3WCJ0UwfhmcD7u82BGwASd4RFPGxgV18iJLFRnoA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://github.com/sponsors/JamieMason" + } + }, + "node_modules/syncpack-linux-arm64": { + "version": "15.1.2", + "resolved": "https://registry.npmjs.org/syncpack-linux-arm64/-/syncpack-linux-arm64-15.1.2.tgz", + "integrity": "sha512-iRsv6tPNX9ZaDEjjpFdYwJj6EHerMVzl2euWt6qmYaW8/SaR6s5W+cc+qXPXijPsBlK65gibdHBfsBgJYB//CA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://github.com/sponsors/JamieMason" + } + }, + "node_modules/syncpack-linux-arm64-musl": { + "version": "15.1.2", + "resolved": "https://registry.npmjs.org/syncpack-linux-arm64-musl/-/syncpack-linux-arm64-musl-15.1.2.tgz", + "integrity": "sha512-Xs1wOUrMZqu0yo85NjAiccbBVkDYhT2P8yOh2+R56MK7ywtyBuM3TxR2IwEmXE8NPW3++hzdF0a7a7IbiW74bQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://github.com/sponsors/JamieMason" + } + }, + "node_modules/syncpack-linux-x64": { + "version": "15.1.2", + "resolved": "https://registry.npmjs.org/syncpack-linux-x64/-/syncpack-linux-x64-15.1.2.tgz", + "integrity": "sha512-Vwc7HLu05rUTgoN2zwcM/F/KiSw7/1prb/S4P+P5UtLXHfQ3Y23dvW1el6ABg7pOBbk08Zgr3i4DSS7Wiw0rog==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://github.com/sponsors/JamieMason" + } + }, + "node_modules/syncpack-linux-x64-musl": { + "version": "15.1.2", + "resolved": "https://registry.npmjs.org/syncpack-linux-x64-musl/-/syncpack-linux-x64-musl-15.1.2.tgz", + "integrity": "sha512-bBtQUTEECd1nefHWfQskwkFdaVXn54whSLHacc9bQijqn4p8lZ2JR3vokqVx8w/dKSrJsxkEM4K7zfHOori38w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://github.com/sponsors/JamieMason" + } + }, + "node_modules/syncpack-windows-arm64": { + "version": "15.1.2", + "resolved": "https://registry.npmjs.org/syncpack-windows-arm64/-/syncpack-windows-arm64-15.1.2.tgz", + "integrity": "sha512-WZnjy0zM9TNWCKxNVo6PGprBKusYykqiAj2qGYWgkMMtGECpFOfEsrmt3R4s58ttQMAg44N+HVDhXtIFQeJOpg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "funding": { + "url": "https://github.com/sponsors/JamieMason" + } + }, + "node_modules/syncpack-windows-x64": { + "version": "15.1.2", + "resolved": "https://registry.npmjs.org/syncpack-windows-x64/-/syncpack-windows-x64-15.1.2.tgz", + "integrity": "sha512-xyWsvn2Bbvubt4sIZGguqbv8pXiGWKifIYgzZWWUIWdaNvGThNLlrEWBlHABDx+Ov1yKLiKHjBiXQMgplMN92w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "funding": { + "url": "https://github.com/sponsors/JamieMason" + } + }, "node_modules/tabbable": { "version": "6.4.0", "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.4.0.tgz", diff --git a/package.json b/package.json index bae3be3b8dc657..4068f27c1f0b27 100644 --- a/package.json +++ b/package.json @@ -107,6 +107,7 @@ "sprintf-js": "1.1.1", "style-loader": "3.2.1", "stylelint-plugin-logical-css": "^1.2.3", + "syncpack": "^15.1.2", "typescript": "6.0.2", "wait-on": "8.0.1" }, @@ -137,9 +138,11 @@ "preformat:php": "npm run other:update-packages:php", "format:php": "wp-env run --env-cwd='wp-content/plugins/gutenberg' cli composer run-script format", "prelint:js": "npm run --if-present --workspaces prelint:js", - "lint": "concurrently \"npm run lint:lockfile\" \"npm run lint:tsconfig\" \"npm run lint:js\" \"npm run lint:pkg-json\" \"npm run lint:css\"", + "lint": "concurrently \"npm run lint:lockfile\" \"npm run lint:tsconfig\" \"npm run lint:js\" \"npm run lint:pkg-json\" \"npm run lint:deps\" \"npm run lint:css\"", "lint:css": "wp-scripts lint-style \"**/*.scss\" \"**/*.module.css\"", "lint:css:fix": "npm run lint:css -- --fix", + "lint:deps": "syncpack lint", + "lint:deps:fix": "syncpack fix", "lint:js": "node ./tools/eslint/lint-js.cjs", "lint:js:fix": "npm run lint:js -- --fix", "lint:js:prune-suppressions": "npm run lint:js -- --prune-suppressions", diff --git a/syncpack.config.mjs b/syncpack.config.mjs new file mode 100644 index 00000000000000..24f67c2d50100c --- /dev/null +++ b/syncpack.config.mjs @@ -0,0 +1,29 @@ +/** @type {import('syncpack').RcFile} */ +export default { + versionGroups: [ + { + label: 'Internal @wordpress/* workspace packages: ignore (workspaces are the source of truth).', + dependencies: [ '@wordpress/**' ], + packages: [ '**' ], + isIgnored: true, + }, + { + label: 'peerDependencies use intentionally wide ranges; only enforce that the ranges are mutually satisfiable.', + dependencyTypes: [ 'peer' ], + policy: 'sameRange', + }, + { + label: 'All dependencies must use the same version across the repo.', + dependencies: [ '**' ], + packages: [ '**' ], + }, + ], + semverGroups: [ + { + label: 'All dependencies must use caret ranges.', + packages: [ '**' ], + dependencyTypes: [ 'prod', 'dev' ], + range: '^', + }, + ], +};