Skip to content

Commit b94c172

Browse files
committed
Add Syncpack to lint dependency version consistency across workspaces
1 parent 095c963 commit b94c172

4 files changed

Lines changed: 199 additions & 1 deletion

File tree

.github/workflows/static-checks.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ jobs:
7373
- name: Lint package.json files
7474
run: npm run lint:pkg-json
7575

76+
- name: Lint dependency versions across workspaces
77+
run: npm run lint:deps
78+
7679
- name: Lint package-lock.json file
7780
run: npm run lint:lockfile
7881

package-lock.json

Lines changed: 163 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
"sprintf-js": "1.1.1",
108108
"style-loader": "3.2.1",
109109
"stylelint-plugin-logical-css": "^1.2.3",
110+
"syncpack": "^15.1.2",
110111
"typescript": "6.0.2",
111112
"wait-on": "8.0.1"
112113
},
@@ -137,9 +138,11 @@
137138
"preformat:php": "npm run other:update-packages:php",
138139
"format:php": "wp-env run --env-cwd='wp-content/plugins/gutenberg' cli composer run-script format",
139140
"prelint:js": "npm run --if-present --workspaces prelint:js",
140-
"lint": "concurrently \"npm run lint:lockfile\" \"npm run lint:tsconfig\" \"npm run lint:js\" \"npm run lint:pkg-json\" \"npm run lint:css\"",
141+
"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\"",
141142
"lint:css": "wp-scripts lint-style \"**/*.scss\" \"**/*.module.css\"",
142143
"lint:css:fix": "npm run lint:css -- --fix",
144+
"lint:deps": "syncpack lint",
145+
"lint:deps:fix": "syncpack fix",
143146
"lint:js": "node ./tools/eslint/lint-js.cjs",
144147
"lint:js:fix": "npm run lint:js -- --fix",
145148
"lint:js:prune-suppressions": "npm run lint:js -- --prune-suppressions",

syncpack.config.mjs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/** @type {import('syncpack').RcFile} */
2+
export default {
3+
versionGroups: [
4+
{
5+
label: 'Internal @wordpress/* workspace packages: ignore (workspaces are the source of truth).',
6+
dependencies: [ '@wordpress/**' ],
7+
packages: [ '**' ],
8+
isIgnored: true,
9+
},
10+
{
11+
label: 'peerDependencies use intentionally wide ranges; only enforce that the ranges are mutually satisfiable.',
12+
dependencyTypes: [ 'peer' ],
13+
policy: 'sameRange',
14+
},
15+
{
16+
label: 'All dependencies must use the same version across the repo.',
17+
dependencies: [ '**' ],
18+
packages: [ '**' ],
19+
},
20+
],
21+
semverGroups: [
22+
{
23+
label: 'All dependencies must use caret ranges.',
24+
packages: [ '**' ],
25+
dependencyTypes: [ 'prod', 'dev' ],
26+
range: '^',
27+
},
28+
],
29+
};

0 commit comments

Comments
 (0)