Skip to content

Commit

Permalink
Add manypkg.ignoredRules config option
Browse files Browse the repository at this point in the history
  • Loading branch information
emmatown committed May 24, 2021
1 parent 0fecbcb commit dc2b0f9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-wasps-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@manypkg/cli": minor
---

Added `manypkg.ignoredRules` config option
4 changes: 2 additions & 2 deletions packages/cli/src/checks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ROOT_HAS_DEV_DEPENDENCIES from "./ROOT_HAS_DEV_DEPENDENCIES";
import UNSORTED_DEPENDENCIES from "./UNSORTED_DEPENDENCIES";
import INCORRECT_REPOSITORY_FIELD from "./INCORRECT_REPOSITORY_FIELD";

export let checks = [
export let checks = {
EXTERNAL_MISMATCH,
INTERNAL_MISMATCH,
INVALID_DEV_AND_PEER_DEPENDENCY_RELATIONSHIP,
Expand All @@ -16,4 +16,4 @@ export let checks = [
ROOT_HAS_DEV_DEPENDENCIES,
UNSORTED_DEPENDENCIES,
INCORRECT_REPOSITORY_FIELD
];
};
2 changes: 1 addition & 1 deletion packages/cli/src/checks/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const DEPENDENCY_TYPES = [
"peerDependencies"
] as const;

export type Options = { defaultBranch?: string };
export type Options = { defaultBranch?: string; ignoredRules?: string[] };

type RootCheck<ErrorType> = {
type: "root";
Expand Down
29 changes: 19 additions & 10 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,38 @@ import { upgradeDependency } from "./upgrade";
import { npmTagAll } from "./npm-tag";
import spawn from "spawndamnit";
import pLimit from "p-limit";
type PackagesWithConfig = Packages & {
root: Packages["root"] & {
packageJson: Packages["root"]["packageJson"] & {
manypkg?: Options;
};

type RootPackage = Package & {
packageJson: {
manypkg?: Options;
};
};
type PackagesWithConfig = Packages & {
root: RootPackage;
};

let defaultOptions = {
defaultBranch: "master"
};

let runChecks = (
allWorkspaces: Map<string, Package>,
rootWorkspace: Package,
rootWorkspace: RootPackage,
shouldFix: boolean,
options: Options
) => {
let hasErrored = false;
let requiresInstall = false;
let ignoredRules = new Set(
(rootWorkspace.packageJson.manypkg &&
rootWorkspace.packageJson.manypkg.ignoredRules) ||
[]
);
for (let [ruleName, check] of Object.entries(checks)) {
if (ignoredRules.has(ruleName)) {
continue;
}

for (let check of checks) {
if (check.type === "all") {
for (let [, workspace] of allWorkspaces) {
let errors = check.validate(
Expand Down Expand Up @@ -124,10 +134,9 @@ async function execCmd(args: string[]) {
throw new ExitError(1);
}
let shouldFix = things[0] === "fix";

let { packages, root, tool }: PackagesWithConfig = await getPackages(
let { packages, root, tool } = (await getPackages(
process.cwd()
);
)) as PackagesWithConfig;

let options: Options = {
...defaultOptions,
Expand Down

0 comments on commit dc2b0f9

Please sign in to comment.