Skip to content

Commit 25f9600

Browse files
authored
✨ feat: add workflow for prettier formatting verification (#26)
* ➕ chore: setup prettier * ✨ feat: add workflow for prettier formatting verification * ✨ feat: add prettier format script to package.json * 🔧 chore: order package.json alphabetically and use wildcard for all supported files * 🐛 fix: include only non-defualt config in prettier config * 💚 chore: use wildcard for prettier, remove redundant pull_request event config * ♻️ refactor: run prettier format
1 parent a547ef9 commit 25f9600

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+11251
-11202
lines changed

Diff for: .github/PULL_REQUEST_TEMPLATE.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ Otherwise we may not be able to review your PR. -->
44

55
## PR Checklist
66

7-
- [ ] Addresses an existing open issue: fixes #000
8-
- [ ] That issue was marked as [accepting prs](https://github.com/LearningTypeScript/projects/issues?q=is%3Aopen+is%3Aissue+label%3A%22accepting+prs%22)
9-
- [ ] Steps in [CONTRIBUTING.md](https://github.com/LearningTypeScript/projects/blob/main/.github/CONTRIBUTING.md) were taken
7+
- [ ] Addresses an existing open issue: fixes #000
8+
- [ ] That issue was marked as [accepting prs](https://github.com/LearningTypeScript/projects/issues?q=is%3Aopen+is%3Aissue+label%3A%22accepting+prs%22)
9+
- [ ] Steps in [CONTRIBUTING.md](https://github.com/LearningTypeScript/projects/blob/main/.github/CONTRIBUTING.md) were taken
1010

1111
## Overview
1212

13-
<!-- Description of what is changed and how the code change does that. -->
13+
<!-- Description of what is changed and how the code change does that. -->

Diff for: .github/dependabot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ updates:
1212
- "dependencies"
1313
commit-message:
1414
prefix: ":arrow_up: build"
15-
include: scope
15+
include: scope

Diff for: .github/workflows/prettier.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Prettier
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
check:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: actions/setup-node@v3
15+
with:
16+
node-version: "16"
17+
cache: "npm"
18+
- run: npm ci
19+
- name: Verify if all files are prettier-ed
20+
run: npx prettier --check "**/*" --ignore-unknown

Diff for: .github/workflows/pull_request_title.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
- uses: actions/checkout@v3
1616
- uses: actions/setup-node@v3
1717
with:
18-
node-version: '16'
19-
cache: 'npm'
18+
node-version: "16"
19+
cache: "npm"
2020
- run: npm ci
2121
- name: Commitlint on PR Title
22-
run: echo "${{github.event.pull_request.title}}" | npx commitlint
22+
run: echo "${{github.event.pull_request.title}}" | npx commitlint

Diff for: .prettierrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"useTabs": true
3+
}

Diff for: arrays/analyzing-dna/01-shallow-equality/index.test.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ import * as solution from "./solution";
66
const { shallowEquality } = process.env.TEST_SOLUTIONS ? solution : index;
77

88
describe(shallowEquality, () => {
9-
test.each([
10-
[[], [], true],
11-
[["a"], [], false],
12-
[[], ["a"], false],
13-
[["a"], ["a"], true],
14-
[["a", "c"], ["a", "c"], true],
15-
[["a", "c"], ["c", "a"], false],
16-
[["a", "c"], ["a", "a"], false],
17-
[["a", "c", "g", "t"], ["a", "c", "g", "t"], true],
18-
[["a", "c", "g", "t"], ["a", "c", "g", "a"], false],
19-
])("%j %j", (a, b, result) => {
20-
expect(shallowEquality(a, b)).toBe(result);
21-
});
9+
test.each([
10+
[[], [], true],
11+
[["a"], [], false],
12+
[[], ["a"], false],
13+
[["a"], ["a"], true],
14+
[["a", "c"], ["a", "c"], true],
15+
[["a", "c"], ["c", "a"], false],
16+
[["a", "c"], ["a", "a"], false],
17+
[["a", "c", "g", "t"], ["a", "c", "g", "t"], true],
18+
[["a", "c", "g", "t"], ["a", "c", "g", "a"], false],
19+
])("%j %j", (a, b, result) => {
20+
expect(shallowEquality(a, b)).toBe(result);
21+
});
2222
});

Diff for: arrays/analyzing-dna/01-shallow-equality/solution.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
export function shallowEquality(a: string[], b: string[]) {
2-
if (a.length !== b.length) {
3-
return false;
4-
}
2+
if (a.length !== b.length) {
3+
return false;
4+
}
55

6-
for (let i = 0; i < a.length; i += 1) {
7-
if (a[i] !== b[i]) {
8-
return false;
9-
}
10-
}
6+
for (let i = 0; i < a.length; i += 1) {
7+
if (a[i] !== b[i]) {
8+
return false;
9+
}
10+
}
1111

12-
return true;
12+
return true;
1313
}

Diff for: arrays/analyzing-dna/02-shallow-differences/index.test.ts

+44-44
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,48 @@ import * as solution from "./solution";
66
const { shallowDifferences } = process.env.TEST_SOLUTIONS ? solution : index;
77

88
describe(shallowDifferences, () => {
9-
test.each([
10-
[[], [], []],
11-
[["a"], [], undefined],
12-
[[], ["a"], undefined],
13-
[["a"], ["a"], ["a"]],
14-
[
15-
["a", "c"],
16-
["a", "c"],
17-
["a", "c"],
18-
],
19-
[
20-
["a", "c"],
21-
["c", "a"],
22-
[undefined, undefined],
23-
],
24-
[
25-
["a", "c"],
26-
["a", "a"],
27-
["a", undefined],
28-
],
29-
[
30-
["c", "a"],
31-
["a", "a"],
32-
[undefined, "a"],
33-
],
34-
[["c", "a"], ["c", "a", "t"], undefined],
35-
[
36-
["a", "c", "g", "t"],
37-
["a", "c", "g", "t"],
38-
["a", "c", "g", "t"],
39-
],
40-
[
41-
["a", "c", "g", "t"],
42-
["a", "c", "g", "a"],
43-
["a", "c", "g", undefined],
44-
],
45-
[
46-
["a", "c", "g", "t"],
47-
["a", "c", "a", "t"],
48-
["a", "c", undefined, "t"],
49-
],
50-
])("%j %j", (a, b, result) => {
51-
expect(shallowDifferences(a, b)).toEqual(result);
52-
});
9+
test.each([
10+
[[], [], []],
11+
[["a"], [], undefined],
12+
[[], ["a"], undefined],
13+
[["a"], ["a"], ["a"]],
14+
[
15+
["a", "c"],
16+
["a", "c"],
17+
["a", "c"],
18+
],
19+
[
20+
["a", "c"],
21+
["c", "a"],
22+
[undefined, undefined],
23+
],
24+
[
25+
["a", "c"],
26+
["a", "a"],
27+
["a", undefined],
28+
],
29+
[
30+
["c", "a"],
31+
["a", "a"],
32+
[undefined, "a"],
33+
],
34+
[["c", "a"], ["c", "a", "t"], undefined],
35+
[
36+
["a", "c", "g", "t"],
37+
["a", "c", "g", "t"],
38+
["a", "c", "g", "t"],
39+
],
40+
[
41+
["a", "c", "g", "t"],
42+
["a", "c", "g", "a"],
43+
["a", "c", "g", undefined],
44+
],
45+
[
46+
["a", "c", "g", "t"],
47+
["a", "c", "a", "t"],
48+
["a", "c", undefined, "t"],
49+
],
50+
])("%j %j", (a, b, result) => {
51+
expect(shallowDifferences(a, b)).toEqual(result);
52+
});
5353
});
+8-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
export function shallowDifferences(a: string[], b: string[]) {
2-
if (a.length !== b.length) {
3-
return undefined;
4-
}
2+
if (a.length !== b.length) {
3+
return undefined;
4+
}
55

6-
const result: (string | undefined)[] = [];
6+
const result: (string | undefined)[] = [];
77

8-
for (let i = 0; i < a.length; i += 1) {
9-
result.push(a[i] === b[i] ? a[i] : undefined);
10-
}
8+
for (let i = 0; i < a.length; i += 1) {
9+
result.push(a[i] === b[i] ? a[i] : undefined);
10+
}
1111

12-
return result;
12+
return result;
1313
}

Diff for: arrays/analyzing-dna/03-deep-equality/index.test.ts

+46-46
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,50 @@ import * as solution from "./solution";
66
const { deepEquality } = process.env.TEST_SOLUTIONS ? solution : index;
77

88
describe(deepEquality, () => {
9-
test.each([
10-
[[], [], true],
11-
[[["a"]], [[]], false],
12-
[[[]], [["a"]], false],
13-
[[["a"]], [["a"]], true],
14-
[[["a"]], [["c"]], false],
15-
[[["a", "c"]], [["a", "c"]], true],
16-
[[["a"], ["c"]], [["a"], ["g"]], false],
17-
[[["a", "c"]], [["a", "c"]], true],
18-
[[["a"], ["c"]], [["g"], ["c"]], false],
19-
[
20-
[
21-
["a", "c"],
22-
["g", "t"],
23-
],
24-
[
25-
["a", "c"],
26-
["g", "t"],
27-
],
28-
true,
29-
],
30-
[
31-
[
32-
["c", "c"],
33-
["g", "t"],
34-
],
35-
[
36-
["a", "c"],
37-
["g", "t"],
38-
],
39-
false,
40-
],
41-
[
42-
[
43-
["a", "c"],
44-
["g", "t"],
45-
],
46-
[
47-
["c", "c"],
48-
["g", "t"],
49-
],
50-
false,
51-
],
52-
])("%j %j", (a, b, result) => {
53-
expect(deepEquality(a, b)).toEqual(result);
54-
});
9+
test.each([
10+
[[], [], true],
11+
[[["a"]], [[]], false],
12+
[[[]], [["a"]], false],
13+
[[["a"]], [["a"]], true],
14+
[[["a"]], [["c"]], false],
15+
[[["a", "c"]], [["a", "c"]], true],
16+
[[["a"], ["c"]], [["a"], ["g"]], false],
17+
[[["a", "c"]], [["a", "c"]], true],
18+
[[["a"], ["c"]], [["g"], ["c"]], false],
19+
[
20+
[
21+
["a", "c"],
22+
["g", "t"],
23+
],
24+
[
25+
["a", "c"],
26+
["g", "t"],
27+
],
28+
true,
29+
],
30+
[
31+
[
32+
["c", "c"],
33+
["g", "t"],
34+
],
35+
[
36+
["a", "c"],
37+
["g", "t"],
38+
],
39+
false,
40+
],
41+
[
42+
[
43+
["a", "c"],
44+
["g", "t"],
45+
],
46+
[
47+
["c", "c"],
48+
["g", "t"],
49+
],
50+
false,
51+
],
52+
])("%j %j", (a, b, result) => {
53+
expect(deepEquality(a, b)).toEqual(result);
54+
});
5555
});

Diff for: arrays/analyzing-dna/03-deep-equality/solution.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
export function deepEquality(a: string[][], b: string[][]) {
2-
if (a.length !== b.length) {
3-
return false;
4-
}
2+
if (a.length !== b.length) {
3+
return false;
4+
}
55

6-
for (let i = 0; i < a.length; i += 1) {
7-
if (a[i].length !== b[i].length) {
8-
return false;
9-
}
6+
for (let i = 0; i < a.length; i += 1) {
7+
if (a[i].length !== b[i].length) {
8+
return false;
9+
}
1010

11-
for (let j = 0; j < a[i].length; j += 1) {
12-
if (a[i][j] !== b[i][j]) {
13-
return false;
14-
}
15-
}
16-
}
11+
for (let j = 0; j < a[i].length; j += 1) {
12+
if (a[i][j] !== b[i][j]) {
13+
return false;
14+
}
15+
}
16+
}
1717

18-
return true;
18+
return true;
1919
}

0 commit comments

Comments
 (0)