Skip to content

Commit

Permalink
Merge pull request #17 from arkedge/renovate/prettier-3.x
Browse files Browse the repository at this point in the history
Update dependency prettier to v3
  • Loading branch information
sksat authored May 2, 2024
2 parents 14f4c2c + 092a47c commit d4afe95
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 72 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-promise": "6.1.1",
"npm-run-all2": "5.0.2",
"prettier": "2.8.8",
"prettier": "3.2.5",
"ts-node": "10.9.2",
"typescript": "5.4.5",
"vitest": "1.5.3"
Expand Down
4 changes: 2 additions & 2 deletions src/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ assert(input, "--input <PATH> or process.env.RULES_FILE is required");

const printSemDiag = (
filepath: string,
{ range, msg, objPath, diagKind }: SemDiag
{ range, msg, objPath, diagKind }: SemDiag,
) => {
let semPos;
if (objPath.length === 0) {
Expand Down Expand Up @@ -152,7 +152,7 @@ if (!docResult.is_ok) {
docResult.docRaw.value,
e.diag.objPath,
key.value,
candidates[0]
candidates[0],
);
modified = true;
}
Expand Down
34 changes: 17 additions & 17 deletions src/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,28 +104,28 @@ it("can match with readme rules", async () => {
await expect(rules[2].test(obj)).resolves.toBeTruthy();
expect(
mock,
"acquire team member the first time we need"
"acquire team member the first time we need",
).toHaveBeenCalledTimes(1);

await expect(
getMatchedProj(
rules,
{ kind: WebhookEventKind.Issue, action: "assigned" },
obj
)
obj,
),
).resolves.toEqual([1, 4]);

await expect(rules[2].test(obj2)).resolves.toBeFalsy();
expect(
mock,
"once called, it will not be called again"
"once called, it will not be called again",
).toHaveBeenCalledTimes(1);
await expect(
getMatchedProj(
rules,
{ kind: WebhookEventKind.Issue, action: "assigned" },
obj2
)
obj2,
),
).resolves.toEqual([]);

await expect(rules[3].test(obj3)).resolves.toBeFalsy();
Expand All @@ -137,8 +137,8 @@ it("can match with readme rules", async () => {
getMatchedProj(
rules,
{ kind: WebhookEventKind.PullRequest, action: "assigned" },
obj4
)
obj4,
),
).resolves.toEqual([9]);
});

Expand Down Expand Up @@ -217,7 +217,7 @@ it("treat rules about issue and pr exclusively", () => {
pr:
- assigned
project: 1`,
"issue rule on pr event"
"issue rule on pr event",
);
});

Expand Down Expand Up @@ -253,8 +253,8 @@ it("can limit firing event", async () => {
kind: WebhookEventKind.Issue,
action: "assigned",
},
arg("assignee")
)
arg("assignee"),
),
).resolves.toEqual([1]);
await expect(
getMatchedProj(
Expand All @@ -263,8 +263,8 @@ it("can limit firing event", async () => {
kind: WebhookEventKind.Issue,
action: "opened",
},
arg("assignee")
)
arg("assignee"),
),
).resolves.toEqual([1, 2]);
await expect(
getMatchedProj(
Expand All @@ -273,8 +273,8 @@ it("can limit firing event", async () => {
kind: WebhookEventKind.PullRequest,
action: "opened",
},
arg("assignee")
)
arg("assignee"),
),
).resolves.toEqual([2]);
await expect(
getMatchedProj(
Expand All @@ -283,7 +283,7 @@ it("can limit firing event", async () => {
kind: WebhookEventKind.PullRequest,
action: "assigned",
},
arg("assignee")
)
arg("assignee"),
),
).resolves.toEqual([]);
});
20 changes: 10 additions & 10 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ interface Rule {
export async function getMatchedProj(
rules: Rule[],
webhookEvent: WebhookEventAction,
obj: MatchArg
obj: MatchArg,
): Promise<number[]> {
const ruleMatchedProjectNumbers = await Promise.all(
rules.map(async (rule) => {
Expand All @@ -104,7 +104,7 @@ export async function getMatchedProj(
}
}
return [];
})
}),
);
const targetProjs: TargetProj[] = ruleMatchedProjectNumbers.flat();
return filterTargetProjs(targetProjs);
Expand All @@ -114,7 +114,7 @@ function filterTargetProjs(targetProjs: TargetProj[]): number[] {
// lift `priority` from `TargetProjNumber`
const targetProjsFlat = targetProjs.flatMap(
(
p: TargetProj
p: TargetProj,
): Array<
| ({ kind: TargetProjKind.Number } & TargetProjNumber)
| TargetProjOnly
Expand All @@ -127,7 +127,7 @@ function filterTargetProjs(targetProjs: TargetProj[]): number[] {
}));
}
return [p];
}
},
);
// dictionary order (priority >> kind)
targetProjsFlat.sort((a, b) => {
Expand Down Expand Up @@ -172,13 +172,13 @@ function filterTargetProjs(targetProjs: TargetProj[]): number[] {
export function processRulesV0(
format: EitherFormat,
filepath: string,
src: string
src: string,
): ParseResult<Config> {
const { docResult, content, error } = parseFile(
format,
configSchema,
filepath,
src
src,
);
return {
docResult,
Expand Down Expand Up @@ -229,7 +229,7 @@ function parseFile<Schema extends z.ZodType<any, any, any>>(
format: EitherFormat,
schema: Schema,
filepath: string,
yaml: string
yaml: string,
): ParseResult<Schema["_output"]> {
const result = format.parse(yaml);
if (!result.is_ok) {
Expand Down Expand Up @@ -336,13 +336,13 @@ function getWebhookEventTarget(parsed: RuleSchema): WebhookEventActionTarget {
export function processRules(
format: EitherFormat,
filepath: string,
src: string
src: string,
): ParseResult<Rule[]> {
const { docResult, content, error } = parseFile(
format,
versionedSchema,
filepath,
src
src,
);
return {
docResult,
Expand Down Expand Up @@ -426,7 +426,7 @@ const extractSemDiag = (doc: Document, error: z.ZodError) => {
if (
(issue.code === "invalid_union" &&
issue.unionErrors.every((e) =>
e.errors.every((e) => e.message === "Required")
e.errors.every((e) => e.message === "Required"),
)) ||
issue.message === "Required"
) {
Expand Down
4 changes: 2 additions & 2 deletions src/configFormat/jsonFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { type ObjPath } from "../types";

const parserGrammar = nearley.Grammar.fromCompiled(
grammar as nearley.CompiledRules
grammar as nearley.CompiledRules,
);

export type JsonTagged<T> = {
Expand Down Expand Up @@ -215,7 +215,7 @@ function findDelegator(node: Value | null) {
return (keyName: string): DocumentNode | null => {
if (node?.type === "Object") {
const key = node?.children.find(
(pair) => pair.key.value.toString() === keyName
(pair) => pair.key.value.toString() === keyName,
)?.key;
if (typeof key === "undefined") {
return null;
Expand Down
8 changes: 4 additions & 4 deletions src/configFormat/yamlFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type ParseResultWrapped<T, U> = ParseResult<YamlTagged<T>, YamlTagged<U>>;

export class YamlFormat implements Format {
parse(
s: string
s: string,
): ParseResultWrapped<YamlDocument, YAML.Document.Parsed<YAML.ParsedNode>> {
const lineCounter = new LineCounter();
const doc = YAML.parseDocument(s, { lineCounter, prettyErrors: true });
Expand All @@ -45,7 +45,7 @@ export class YamlFormat implements Format {
export class YamlDocument implements Document {
constructor(
private readonly doc: YAML.Document.Parsed,
private readonly lineCounter: LineCounter
private readonly lineCounter: LineCounter,
) {}

toJS() {
Expand Down Expand Up @@ -77,7 +77,7 @@ export class YamlDocument implements Document {

function toDocumentNode(
node: YAML.ParsedNode,
lineCounter: LineCounter
lineCounter: LineCounter,
): DocumentNode & FindKey {
return {
loc: {
Expand All @@ -92,7 +92,7 @@ function findDelegator(node: YAML.ParsedNode | null, lineCounter: LineCounter) {
return (keyName: string) => {
if (YAML.isMap(node)) {
const key = node?.items.find(
(pair) => pair.key.toString() === keyName
(pair) => pair.key.toString() === keyName,
)?.key;
if (typeof key === "undefined") {
return null;
Expand Down
22 changes: 11 additions & 11 deletions src/configSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const composeEAsync =
const y = flatten(f(x));
return await existsAsync(
g,
async (g) => await existsAsync(y, async (y) => await g(y))
async (g) => await existsAsync(y, async (y) => await g(y)),
);
};

Expand All @@ -78,7 +78,7 @@ const composeAAsync =
const y = flatten(f(x));
return await forallAsync(
g,
async (g) => await existsAsync(y, async (y) => await g(y))
async (g) => await existsAsync(y, async (y) => await g(y)),
);
};

Expand Down Expand Up @@ -147,7 +147,7 @@ const numberParser = z.union([_number.transform(unit), _number.array()], {
(i) =>
// i.code === z.ZodIssueCode.invalid_type is required because of type inference
i.code === z.ZodIssueCode.invalid_type &&
i.received === z.ZodParsedType.array
i.received === z.ZodParsedType.array,
)
) {
// error is array of something
Expand Down Expand Up @@ -239,7 +239,7 @@ const loginEq =
return async (x: X & GetTeamMemberProp) => {
const y = await p(x);
return proj(x).some((g) =>
y.some((y) => curryingStrictEq(g.login)(y.login))
y.some((y) => curryingStrictEq(g.login)(y.login)),
);
};
}
Expand All @@ -258,7 +258,7 @@ const labelParser = stringish

const issueSchema = z.object({
assignees: loginParser(
(x: Issue & GetTeamMemberProp) => x.assignees
(x: Issue & GetTeamMemberProp) => x.assignees,
).transform(extendEAsync((x: Issue & GetTeamMemberProp) => x)),
labels: labelParser
.transform(extendPropE<Issue>()("labels"))
Expand All @@ -274,10 +274,10 @@ const prSchema = z.object({
} else {
return [];
}
})
}),
).transform(extendEAsync((x: PullRequest & GetTeamMemberProp) => x)),
assignees: loginParser(
(x: PullRequest & GetTeamMemberProp) => x.assignees
(x: PullRequest & GetTeamMemberProp) => x.assignees,
).transform(extendEAsync((x: PullRequest & GetTeamMemberProp) => x)),
labels: labelParser
.transform(extendPropE<PullRequest>()("labels"))
Expand Down Expand Up @@ -363,7 +363,7 @@ const targetProjNumberSchema = _number
return projectNumber;
}),
})
.transform((x) => x.not)
.transform((x) => x.not),
);

const targetProjSchema = targetProjNumberSchema
Expand All @@ -387,7 +387,7 @@ const targetProjSchema = targetProjNumberSchema
return r;
}),
})
.transform((x) => x.only)
.transform((x) => x.only),
)
.or(
z
Expand All @@ -400,7 +400,7 @@ const targetProjSchema = targetProjNumberSchema
return r;
}),
})
.transform((x) => x.reject)
.transform((x) => x.reject),
);

const ruleSchema = payloadSchema
Expand All @@ -411,7 +411,7 @@ const ruleSchema = payloadSchema
.strict()
.refine(
(p) => typeof p.issue === "undefined" || typeof p.pr === "undefined",
"issue and pr cannot be specified together"
"issue and pr cannot be specified together",
)
.refine((p) => {
// issue rule
Expand Down
Loading

0 comments on commit d4afe95

Please sign in to comment.