Skip to content

Commit 8469b2c

Browse files
authored
Merge pull request #151 from actions/prettier-2.3.0
Update prettier to the latest version and re-prettify everything
2 parents ca69a1e + c97a958 commit 8469b2c

File tree

6 files changed

+52
-52
lines changed

6 files changed

+52
-52
lines changed

__mocks__/@actions/github.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
export const context = {
22
payload: {
33
pull_request: {
4-
number: 123
5-
}
4+
number: 123,
5+
},
66
},
77
repo: {
88
owner: "monalisa",
9-
repo: "helloworld"
10-
}
9+
repo: "helloworld",
10+
},
1111
};
1212

1313
const mockApi = {
1414
issues: {
1515
addLabels: jest.fn(),
16-
removeLabel: jest.fn()
16+
removeLabel: jest.fn(),
1717
},
1818
paginate: jest.fn(),
1919
pulls: {
2020
get: jest.fn().mockResolvedValue({}),
2121
listFiles: {
2222
endpoint: {
23-
merge: jest.fn().mockReturnValue({})
24-
}
25-
}
23+
merge: jest.fn().mockReturnValue({}),
24+
},
25+
},
2626
},
2727
repos: {
28-
getContents: jest.fn()
29-
}
28+
getContents: jest.fn(),
29+
},
3030
};
3131

3232
export const GitHub = jest.fn().mockImplementation(() => mockApi);

__tests__/main.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const paginateMock = jest.spyOn(gh, "paginate");
1515
const getPullMock = jest.spyOn(gh.pulls, "get");
1616

1717
const yamlFixtures = {
18-
"only_pdfs.yml": fs.readFileSync("__tests__/fixtures/only_pdfs.yml")
18+
"only_pdfs.yml": fs.readFileSync("__tests__/fixtures/only_pdfs.yml"),
1919
};
2020

2121
afterAll(() => jest.restoreAllMocks());
@@ -33,7 +33,7 @@ describe("run", () => {
3333
owner: "monalisa",
3434
repo: "helloworld",
3535
issue_number: 123,
36-
labels: ["touched-a-pdf-file"]
36+
labels: ["touched-a-pdf-file"],
3737
});
3838
});
3939

@@ -51,7 +51,7 @@ describe("run", () => {
5151
let mockInput = {
5252
"repo-token": "foo",
5353
"configuration-path": "bar",
54-
"sync-labels": true
54+
"sync-labels": true,
5555
};
5656

5757
jest
@@ -62,8 +62,8 @@ describe("run", () => {
6262
mockGitHubResponseChangedFiles("foo.txt");
6363
getPullMock.mockResolvedValue(<any>{
6464
data: {
65-
labels: [{ name: "touched-a-pdf-file" }]
66-
}
65+
labels: [{ name: "touched-a-pdf-file" }],
66+
},
6767
});
6868

6969
await run();
@@ -74,15 +74,15 @@ describe("run", () => {
7474
owner: "monalisa",
7575
repo: "helloworld",
7676
issue_number: 123,
77-
name: "touched-a-pdf-file"
77+
name: "touched-a-pdf-file",
7878
});
7979
});
8080

8181
it("(with sync-labels: false) it issues no delete calls even when there are preexisting PR labels that no longer match the glob pattern", async () => {
8282
let mockInput = {
8383
"repo-token": "foo",
8484
"configuration-path": "bar",
85-
"sync-labels": false
85+
"sync-labels": false,
8686
};
8787

8888
jest
@@ -93,8 +93,8 @@ describe("run", () => {
9393
mockGitHubResponseChangedFiles("foo.txt");
9494
getPullMock.mockResolvedValue(<any>{
9595
data: {
96-
labels: [{ name: "touched-a-pdf-file" }]
97-
}
96+
labels: [{ name: "touched-a-pdf-file" }],
97+
},
9898
});
9999

100100
await run();
@@ -106,11 +106,11 @@ describe("run", () => {
106106

107107
function usingLabelerConfigYaml(fixtureName: keyof typeof yamlFixtures): void {
108108
reposMock.mockResolvedValue(<any>{
109-
data: { content: yamlFixtures[fixtureName], encoding: "utf8" }
109+
data: { content: yamlFixtures[fixtureName], encoding: "utf8" },
110110
});
111111
}
112112

113113
function mockGitHubResponseChangedFiles(...files: string[]): void {
114-
const returnValue = files.map(f => ({ filename: f }));
114+
const returnValue = files.map((f) => ({ filename: f }));
115115
paginateMock.mockReturnValue(<any>returnValue);
116116
}

dist/index.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19859,7 +19859,7 @@ function run() {
1985919859
const { data: pullRequest } = yield client.pulls.get({
1986019860
owner: github.context.repo.owner,
1986119861
repo: github.context.repo.repo,
19862-
pull_number: prNumber
19862+
pull_number: prNumber,
1986319863
});
1986419864
core.debug(`fetching changed files for pr #${prNumber}`);
1986519865
const changedFiles = yield getChangedFiles(client, prNumber);
@@ -19871,7 +19871,7 @@ function run() {
1987119871
if (checkGlobs(changedFiles, globs)) {
1987219872
labels.push(label);
1987319873
}
19874-
else if (pullRequest.labels.find(l => l.name === label)) {
19874+
else if (pullRequest.labels.find((l) => l.name === label)) {
1987519875
labelsToRemove.push(label);
1987619876
}
1987719877
}
@@ -19901,10 +19901,10 @@ function getChangedFiles(client, prNumber) {
1990119901
const listFilesOptions = client.pulls.listFiles.endpoint.merge({
1990219902
owner: github.context.repo.owner,
1990319903
repo: github.context.repo.repo,
19904-
pull_number: prNumber
19904+
pull_number: prNumber,
1990519905
});
1990619906
const listFilesResponse = yield client.paginate(listFilesOptions);
19907-
const changedFiles = listFilesResponse.map(f => f.filename);
19907+
const changedFiles = listFilesResponse.map((f) => f.filename);
1990819908
core.debug("found changed files:");
1990919909
for (const file of changedFiles) {
1991019910
core.debug(" " + file);
@@ -19927,7 +19927,7 @@ function fetchContent(client, repoPath) {
1992719927
owner: github.context.repo.owner,
1992819928
repo: github.context.repo.repo,
1992919929
path: repoPath,
19930-
ref: github.context.sha
19930+
ref: github.context.sha,
1993119931
});
1993219932
return Buffer.from(response.data.content, response.data.encoding).toString();
1993319933
});
@@ -19950,7 +19950,7 @@ function getLabelGlobMapFromObject(configObject) {
1995019950
function toMatchConfig(config) {
1995119951
if (typeof config === "string") {
1995219952
return {
19953-
any: [config]
19953+
any: [config],
1995419954
};
1995519955
}
1995619956
return config;
@@ -19983,7 +19983,7 @@ function isMatch(changedFile, matchers) {
1998319983
}
1998419984
// equivalent to "Array.some()" but expanded for debugging and clarity
1998519985
function checkAny(changedFiles, globs) {
19986-
const matchers = globs.map(g => new minimatch_1.Minimatch(g));
19986+
const matchers = globs.map((g) => new minimatch_1.Minimatch(g));
1998719987
core.debug(` checking "any" patterns`);
1998819988
for (const changedFile of changedFiles) {
1998919989
if (isMatch(changedFile, matchers)) {
@@ -19996,7 +19996,7 @@ function checkAny(changedFiles, globs) {
1999619996
}
1999719997
// equivalent to "Array.every()" but expanded for debugging and clarity
1999819998
function checkAll(changedFiles, globs) {
19999-
const matchers = globs.map(g => new minimatch_1.Minimatch(g));
19999+
const matchers = globs.map((g) => new minimatch_1.Minimatch(g));
2000020000
core.debug(` checking "all" patterns`);
2000120001
for (const changedFile of changedFiles) {
2000220002
if (!isMatch(changedFile, matchers)) {
@@ -20026,17 +20026,17 @@ function addLabels(client, prNumber, labels) {
2002620026
owner: github.context.repo.owner,
2002720027
repo: github.context.repo.repo,
2002820028
issue_number: prNumber,
20029-
labels: labels
20029+
labels: labels,
2003020030
});
2003120031
});
2003220032
}
2003320033
function removeLabels(client, prNumber, labels) {
2003420034
return __awaiter(this, void 0, void 0, function* () {
20035-
yield Promise.all(labels.map(label => client.issues.removeLabel({
20035+
yield Promise.all(labels.map((label) => client.issues.removeLabel({
2003620036
owner: github.context.repo.owner,
2003720037
repo: github.context.repo.repo,
2003820038
issue_number: prNumber,
20039-
name: label
20039+
name: label,
2004020040
})));
2004120041
});
2004220042
}

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"@vercel/ncc": "^0.23.0",
3838
"jest": "^24.8.0",
3939
"jest-circus": "^24.7.1",
40-
"prettier": "^1.17.1",
40+
"prettier": "^2.3.0",
4141
"ts-jest": "^24.0.2",
4242
"typescript": "^3.5.1"
4343
}

src/labeler.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export async function run() {
2727
const { data: pullRequest } = await client.pulls.get({
2828
owner: github.context.repo.owner,
2929
repo: github.context.repo.repo,
30-
pull_number: prNumber
30+
pull_number: prNumber,
3131
});
3232

3333
core.debug(`fetching changed files for pr #${prNumber}`);
@@ -43,7 +43,7 @@ export async function run() {
4343
core.debug(`processing ${label}`);
4444
if (checkGlobs(changedFiles, globs)) {
4545
labels.push(label);
46-
} else if (pullRequest.labels.find(l => l.name === label)) {
46+
} else if (pullRequest.labels.find((l) => l.name === label)) {
4747
labelsToRemove.push(label);
4848
}
4949
}
@@ -77,11 +77,11 @@ async function getChangedFiles(
7777
const listFilesOptions = client.pulls.listFiles.endpoint.merge({
7878
owner: github.context.repo.owner,
7979
repo: github.context.repo.repo,
80-
pull_number: prNumber
80+
pull_number: prNumber,
8181
});
8282

8383
const listFilesResponse = await client.paginate(listFilesOptions);
84-
const changedFiles = listFilesResponse.map(f => f.filename);
84+
const changedFiles = listFilesResponse.map((f) => f.filename);
8585

8686
core.debug("found changed files:");
8787
for (const file of changedFiles) {
@@ -115,7 +115,7 @@ async function fetchContent(
115115
owner: github.context.repo.owner,
116116
repo: github.context.repo.repo,
117117
path: repoPath,
118-
ref: github.context.sha
118+
ref: github.context.sha,
119119
});
120120

121121
return Buffer.from(response.data.content, response.data.encoding).toString();
@@ -143,7 +143,7 @@ function getLabelGlobMapFromObject(
143143
function toMatchConfig(config: StringOrMatchConfig): MatchConfig {
144144
if (typeof config === "string") {
145145
return {
146-
any: [config]
146+
any: [config],
147147
};
148148
}
149149

@@ -184,7 +184,7 @@ function isMatch(changedFile: string, matchers: IMinimatch[]): boolean {
184184

185185
// equivalent to "Array.some()" but expanded for debugging and clarity
186186
function checkAny(changedFiles: string[], globs: string[]): boolean {
187-
const matchers = globs.map(g => new Minimatch(g));
187+
const matchers = globs.map((g) => new Minimatch(g));
188188
core.debug(` checking "any" patterns`);
189189
for (const changedFile of changedFiles) {
190190
if (isMatch(changedFile, matchers)) {
@@ -199,7 +199,7 @@ function checkAny(changedFiles: string[], globs: string[]): boolean {
199199

200200
// equivalent to "Array.every()" but expanded for debugging and clarity
201201
function checkAll(changedFiles: string[], globs: string[]): boolean {
202-
const matchers = globs.map(g => new Minimatch(g));
202+
const matchers = globs.map((g) => new Minimatch(g));
203203
core.debug(` checking "all" patterns`);
204204
for (const changedFile of changedFiles) {
205205
if (!isMatch(changedFile, matchers)) {
@@ -237,7 +237,7 @@ async function addLabels(
237237
owner: github.context.repo.owner,
238238
repo: github.context.repo.repo,
239239
issue_number: prNumber,
240-
labels: labels
240+
labels: labels,
241241
});
242242
}
243243

@@ -247,12 +247,12 @@ async function removeLabels(
247247
labels: string[]
248248
) {
249249
await Promise.all(
250-
labels.map(label =>
250+
labels.map((label) =>
251251
client.issues.removeLabel({
252252
owner: github.context.repo.owner,
253253
repo: github.context.repo.repo,
254254
issue_number: prNumber,
255-
name: label
255+
name: label,
256256
})
257257
)
258258
);

0 commit comments

Comments
 (0)