|
| 1 | +% Enforces that all workspaces depend on other workspaces using `workspace:*` in devDependencies |
| 2 | +gen_enforced_dependency(WorkspaceCwd, DependencyIdent, 'workspace:*', 'devDependencies') :- |
| 3 | + workspace_has_dependency(WorkspaceCwd, DependencyIdent, DependencyRange, 'devDependencies'), |
| 4 | + % Only consider dependency ranges that start with 'workspace:' |
| 5 | + atom_concat('workspace:', _, DependencyRange). |
| 6 | + |
| 7 | +% Enforces the license in all public workspaces while removing it from private workspaces |
| 8 | +gen_enforced_field(WorkspaceCwd, 'license', 'MIT') :- |
| 9 | + \+ workspace_field(WorkspaceCwd, 'private', true). |
| 10 | +gen_enforced_field(WorkspaceCwd, 'license', null) :- |
| 11 | + workspace_field(WorkspaceCwd, 'private', true). |
| 12 | + |
| 13 | +% Enforces the repository field for all public workspaces while removing it from private workspaces |
| 14 | +gen_enforced_field(WorkspaceCwd, 'repository.type', 'git') :- |
| 15 | + \+ workspace_field(WorkspaceCwd, 'private', true). |
| 16 | +gen_enforced_field(WorkspaceCwd, 'repository.url', 'https://github.com/babel/babel.git') :- |
| 17 | + \+ workspace_field(WorkspaceCwd, 'private', true). |
| 18 | +gen_enforced_field(WorkspaceCwd, 'repository.directory', WorkspaceCwd) :- |
| 19 | + \+ workspace_field(WorkspaceCwd, 'private', true). |
| 20 | +gen_enforced_field(WorkspaceCwd, 'repository', null) :- |
| 21 | + workspace_field(WorkspaceCwd, 'private', true). |
| 22 | + |
| 23 | +% Enforces 'publishConfig.access' is set to public for public workspaces while removing it from private workspaces |
| 24 | +gen_enforced_field(WorkspaceCwd, 'publishConfig.access', 'public') :- |
| 25 | + \+ workspace_field(WorkspaceCwd, 'private', true). |
| 26 | +gen_enforced_field(WorkspaceCwd, 'publishConfig.access', null) :- |
| 27 | + workspace_field(WorkspaceCwd, 'private', true). |
| 28 | + |
| 29 | +% Enforces the engines.node field for all workspaces except '@babel/eslint*' |
| 30 | +gen_enforced_field(WorkspaceCwd, 'engines.node', '>=6.9.0') :- |
| 31 | + \+ workspace_field(WorkspaceCwd, 'private', true), |
| 32 | + % Get the workspace name |
| 33 | + workspace_ident(WorkspaceCwd, WorkspaceIdent), |
| 34 | + % Exempt from the rule as it supports '>=4'. TODO: remove with the next major |
| 35 | + WorkspaceIdent \= '@babel/plugin-proposal-unicode-property-regex', |
| 36 | + % Exempt from the rule as it supports '>=6.0.0'. TODO: remove with the next major |
| 37 | + WorkspaceIdent \= '@babel/parser', |
| 38 | + % Skip '@babel/eslint*' workspaces. TODO: remove with the next major |
| 39 | + \+ atom_concat('@babel/eslint', _, WorkspaceIdent). |
| 40 | + |
| 41 | +% Enforces the engines.node field for '@babel/eslint*' workspaces |
| 42 | +% TODO: remove with the next major |
| 43 | +gen_enforced_field(WorkspaceCwd, 'engines.node', '^10.13.0 || ^12.13.0 || >=14.0.0') :- |
| 44 | + \+ workspace_field(WorkspaceCwd, 'private', true), |
| 45 | + % Get the workspace name |
| 46 | + workspace_ident(WorkspaceCwd, WorkspaceIdent), |
| 47 | + % Only target '@babel/eslint*' workspaces |
| 48 | + atom_concat('@babel/eslint', _, WorkspaceIdent). |
| 49 | + |
| 50 | +% Removes the 'engines.node' field from private workspaces |
| 51 | +gen_enforced_field(WorkspaceCwd, 'engines.node', null) :- |
| 52 | + workspace_field(WorkspaceCwd, 'private', true). |
| 53 | + |
| 54 | +% Enforces the author field to be consistent |
| 55 | +gen_enforced_field(WorkspaceCwd, 'author', 'The Babel Team (https://babel.dev/team)') :- |
| 56 | + \+ workspace_field(WorkspaceCwd, 'private', true). |
| 57 | +gen_enforced_field(WorkspaceCwd, 'author', null) :- |
| 58 | + workspace_field(WorkspaceCwd, 'private', true). |
| 59 | + |
| 60 | +% Enforces the main and types field to start with ./ |
| 61 | +gen_enforced_field(WorkspaceCwd, FieldName, ExpectedValue) :- |
| 62 | + % Fields the rule applies to |
| 63 | + member(FieldName, ['main', 'types']), |
| 64 | + % Get current value |
| 65 | + workspace_field(WorkspaceCwd, FieldName, CurrentValue), |
| 66 | + % Must not start with ./ already |
| 67 | + \+ atom_concat('./', _, CurrentValue), |
| 68 | + % Store './' + CurrentValue in ExpectedValue |
| 69 | + atom_concat('./', CurrentValue, ExpectedValue). |
0 commit comments