* This rule will enforce that the specified fields are present in the * `package.json` of all workspaces and that they have the expected value. * * @param {Context} context * @param {Record any) | string>} fields
({ Yarn }, fields)
| 145 | * @param {Record<string, ((workspace: Workspace) => any) | string>} fields |
| 146 | */ |
| 147 | function enforceFieldsWithValuesOnAllWorkspaces({ Yarn }, fields) { |
| 148 | for (const workspace of Yarn.workspaces()) { |
| 149 | // Skip the root workspace |
| 150 | if (workspace.cwd === '.') { |
| 151 | continue |
| 152 | } |
| 153 | |
| 154 | for (const [field, value] of Object.entries(fields)) { |
| 155 | workspace.set( |
| 156 | field, |
| 157 | typeof value === `function` ? value(workspace) : value, |
| 158 | ) |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | module.exports = defineConfig({ |
| 164 | constraints: async (ctx) => { |
no test coverage detected