Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Yarn-related rules #39

Merged
merged 18 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
"chalk": "^4.1.2",
"dependency-graph": "^0.11.0",
"execa": "^5.1.1",
"pony-cause": "^2.1.10",
"superstruct": "^1.0.3",
"yargs": "^17.7.2"
},
"devDependencies": {
Expand Down
42 changes: 30 additions & 12 deletions src/execute-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,31 @@ export type RootRuleExecutionResultNode = {
children: RuleExecutionResultNode[];
};

/**
* The arguments passed to every rule's `execute` method.
*/
export type RuleExecutionArguments = {
/**
* A reference to a template repository that serves as a baseline for the
* project.
*/
template: MetaMaskRepository;
/**
* A reference to the project repository.
*/
project: MetaMaskRepository;
/**
* A supporting function that causes the rule to pass.
*/
pass: () => SuccessfulPartialRuleExecutionResult;
/**
* A supporting function that causes the rule to fail.
*/
fail: (
failures: FailedPartialRuleExecutionResult['failures'],
) => FailedPartialRuleExecutionResult;
};

/**
* A lint rule that can be executed against a project.
*/
Expand All @@ -85,14 +110,7 @@ export type Rule = {
/**
* The "body" of the rule.
*/
execute(args: {
project: MetaMaskRepository;
template: MetaMaskRepository;
pass: () => SuccessfulPartialRuleExecutionResult;
fail: (
failures: FailedPartialRuleExecutionResult['failures'],
) => FailedPartialRuleExecutionResult;
}): Promise<PartialRuleExecutionResult>;
execute(args: RuleExecutionArguments): Promise<PartialRuleExecutionResult>;
};

/**
Expand Down Expand Up @@ -218,8 +236,8 @@ async function executeRule({
}

/**
* A helper intended to be used in a rule which ends its execution by marking it
* as passing.
* A helper for a rule which is intended to end its execution by marking it as
* passing.
*
* @returns Part of a successful rule execution result (the rest will be filled
* in automatically).
Expand All @@ -231,8 +249,8 @@ export function pass(): SuccessfulPartialRuleExecutionResult {
}

/**
* A helper intended to be used in a rule which ends its execution by marking it
* as failing.
* A helper for a rule which is intended to end its execution by marking it as
* failing.
*
* @param failures - The list of associated failures.
* @returns Part of a failed rule execution result (the rest will be filled
Expand Down
Loading