-
Notifications
You must be signed in to change notification settings - Fork 2
/
yarn.config.cjs
48 lines (42 loc) · 2 KB
/
yarn.config.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/** @type {import('@yarnpkg/types')} */
// eslint-disable-next-line @typescript-eslint/no-require-imports
const { defineConfig } = require("@yarnpkg/types");
// https://yarnpkg.com/features/constraints
// Enforce that the engines.node field is properly set in all workspaces
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
const enforceConsistentEnginesNodeValue = ({ Yarn }) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
for (const workspace of Yarn.workspaces()) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
workspace.set("engines.node", ">=20.16.0");
}
};
// Enforce that a workspaces depend on the same version of a dependency
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
const enforceConsistentDependencies = ({ Yarn }) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
for (const dependency of Yarn.dependencies()) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (dependency.type === `peerDependencies`) {
continue;
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
for (const otherDependency of Yarn.dependencies({
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access,
ident: dependency.ident,
})) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (otherDependency.type === `peerDependencies`) {
continue;
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
dependency.update(otherDependency.range);
}
}
};
module.exports = defineConfig({
constraints: (ctx) => {
enforceConsistentEnginesNodeValue(ctx);
enforceConsistentDependencies(ctx);
},
});