Skip to content

Commit 1138d06

Browse files
committed
Run linter formatter
1 parent 702c30b commit 1138d06

25 files changed

+178
-294
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module.exports = {
2323
"react/no-unescaped-entities": "off",
2424
"@typescript-eslint/no-non-null-assertion": "off",
2525
"react/prop-types": "off",
26+
"react/display-name": "off"
2627
},
2728
settings: {
2829
react: {

packages/gitgraph-core/src/__tests__/gitgraph.clear.test.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,9 @@ describe("Gitgraph.clear", () => {
3737
const core = new GitgraphCore();
3838
const gitgraph = core.getUserApi();
3939

40-
gitgraph
41-
.branch("dev")
42-
.commit("one")
43-
.commit("two");
40+
gitgraph.branch("dev").commit("one").commit("two");
4441
gitgraph.clear();
45-
gitgraph
46-
.branch("feat")
47-
.commit("three")
48-
.commit("four");
42+
gitgraph.branch("feat").commit("three").commit("four");
4943

5044
const { commits } = core.getRenderedData();
5145

packages/gitgraph-core/src/__tests__/gitgraph.getRenderedData.branches.test.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,7 @@ describe("Gitgraph.getRenderedData.branches", () => {
163163
const core = new GitgraphCore();
164164
const gitgraph = core.getUserApi();
165165

166-
gitgraph
167-
.commit()
168-
.commit()
169-
.branch("develop")
170-
.commit();
166+
gitgraph.commit().commit().branch("develop").commit();
171167

172168
const { commits } = core.getRenderedData();
173169
[, two, three] = commits;

packages/gitgraph-core/src/__tests__/gitgraph.getRenderedData.branchesPaths.test.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ describe("Gitgraph.getRenderedData.branchesPaths", () => {
7979
const gitgraph = core.getUserApi();
8080

8181
gitgraph.branch("master").commit("Initial commit");
82-
gitgraph
83-
.branch("dev")
84-
.commit()
85-
.commit();
82+
gitgraph.branch("dev").commit().commit();
8683

8784
const { branchesPaths } = core.getRenderedData();
8885

packages/gitgraph-core/src/__tests__/gitgraph.getRenderedData.position.test.ts

+5-20
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ describe("Gitgraph.getRenderedData.position", () => {
77
const core = new GitgraphCore();
88
const gitgraph = core.getUserApi();
99

10-
gitgraph
11-
.commit("one")
12-
.commit("two")
13-
.commit("three");
10+
gitgraph.commit("one").commit("two").commit("three");
1411

1512
const { commits } = core.getRenderedData();
1613

@@ -39,10 +36,7 @@ describe("Gitgraph.getRenderedData.position", () => {
3936
});
4037
const gitgraph = core.getUserApi();
4138

42-
gitgraph
43-
.commit("one")
44-
.commit("two")
45-
.commit("three");
39+
gitgraph.commit("one").commit("two").commit("three");
4640

4741
const { commits } = core.getRenderedData();
4842

@@ -71,10 +65,7 @@ describe("Gitgraph.getRenderedData.position", () => {
7165
});
7266
const gitgraph = core.getUserApi();
7367

74-
gitgraph
75-
.commit("one")
76-
.commit("two")
77-
.commit("three");
68+
gitgraph.commit("one").commit("two").commit("three");
7869

7970
const { commits } = core.getRenderedData();
8071

@@ -103,10 +94,7 @@ describe("Gitgraph.getRenderedData.position", () => {
10394
});
10495
const gitgraph = core.getUserApi();
10596

106-
gitgraph
107-
.commit("one")
108-
.commit("two")
109-
.commit("three");
97+
gitgraph.commit("one").commit("two").commit("three");
11098

11199
const { commits } = core.getRenderedData();
112100

@@ -583,10 +571,7 @@ describe("Gitgraph.getRenderedData.position", () => {
583571
});
584572
const gitgraph = core.getUserApi();
585573

586-
const master = gitgraph
587-
.branch("master")
588-
.commit("one")
589-
.commit("two");
574+
const master = gitgraph.branch("master").commit("one").commit("two");
590575

591576
// Branch has more commits.
592577
const dev = gitgraph.branch("dev").commit("three");

packages/gitgraph-core/src/__tests__/gitgraph.subscribe.test.ts

+5-22
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ describe("Gitgraph.subscribe", () => {
1010
const onUpdate = jest.fn();
1111
core.subscribe(onUpdate);
1212

13-
gitgraph
14-
.commit()
15-
.commit()
16-
.commit();
13+
gitgraph.commit().commit().commit();
1714

1815
jest.runAllTimers();
1916

@@ -28,15 +25,8 @@ describe("Gitgraph.subscribe", () => {
2825
const onUpdate = jest.fn();
2926
core.subscribe(onUpdate);
3027

31-
const master = gitgraph
32-
.branch("master")
33-
.commit()
34-
.commit()
35-
.commit();
36-
const dev = gitgraph
37-
.branch("dev")
38-
.commit()
39-
.commit();
28+
const master = gitgraph.branch("master").commit().commit().commit();
29+
const dev = gitgraph.branch("dev").commit().commit();
4030
master.merge(dev);
4131

4232
jest.runAllTimers();
@@ -52,20 +42,13 @@ describe("Gitgraph.subscribe", () => {
5242
const onUpdate = jest.fn();
5343
const unsubscribe = core.subscribe(onUpdate);
5444

55-
const master = gitgraph
56-
.branch("master")
57-
.commit()
58-
.commit()
59-
.commit();
45+
const master = gitgraph.branch("master").commit().commit().commit();
6046

6147
jest.runAllTimers();
6248

6349
unsubscribe();
6450

65-
const dev = gitgraph
66-
.branch("dev")
67-
.commit()
68-
.commit();
51+
const dev = gitgraph.branch("dev").commit().commit();
6952
master.merge(dev);
7053

7154
jest.runAllTimers();

packages/gitgraph-core/src/__tests__/gitgraph.tag.test.ts

+3-12
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ describe("Gitgraph.tag", () => {
88
const master = gitgraph
99
.branch("master")
1010
.commit({ subject: "one-tagged", hash: "one-tagged-hash" });
11-
gitgraph
12-
.branch("dev")
13-
.commit("two")
14-
.commit("three");
11+
gitgraph.branch("dev").commit("two").commit("three");
1512
master.commit("four");
1613
gitgraph.tag("this-one", "one-tagged-hash");
1714

@@ -110,10 +107,7 @@ describe("Gitgraph.tag", () => {
110107
const gitgraph = core.getUserApi();
111108

112109
const master = gitgraph.branch("master").commit("one");
113-
gitgraph
114-
.branch("dev")
115-
.commit("two")
116-
.commit("three");
110+
gitgraph.branch("dev").commit("two").commit("three");
117111
master.commit({ subject: "four-tagged", hash: "four-tagged-hash" });
118112
gitgraph.tag("this-one");
119113

@@ -138,10 +132,7 @@ describe("Gitgraph.tag", () => {
138132
const gitgraph = core.getUserApi();
139133

140134
const master = gitgraph.branch("master").commit("one");
141-
gitgraph
142-
.branch("dev")
143-
.commit("two")
144-
.commit("three");
135+
gitgraph.branch("dev").commit("two").commit("three");
145136
master.commit("four-tagged");
146137
gitgraph.tag("tag-one").tag("tag-two");
147138

packages/gitgraph-core/src/commit.ts

+6-14
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,10 @@ interface CommitOptions<TNode> extends CommitRenderOptions<TNode> {
3333
*/
3434
const getRandomHash = () =>
3535
(
36-
Math.random()
37-
.toString(16)
38-
.substring(3) +
39-
Math.random()
40-
.toString(16)
41-
.substring(3) +
42-
Math.random()
43-
.toString(16)
44-
.substring(3) +
45-
Math.random()
46-
.toString(16)
47-
.substring(3)
36+
Math.random().toString(16).substring(3) +
37+
Math.random().toString(16).substring(3) +
38+
Math.random().toString(16).substring(3) +
39+
Math.random().toString(16).substring(3)
4840
).substring(0, 40);
4941

5042
class Commit<TNode = SVGElement> {
@@ -55,11 +47,11 @@ class Commit<TNode = SVGElement> {
5547
/**
5648
* Commit x position
5749
*/
58-
public x: number = 0;
50+
public x = 0;
5951
/**
6052
* Commit y position
6153
*/
62-
public y: number = 0;
54+
public y = 0;
6355
/**
6456
* Commit hash
6557
*/

packages/gitgraph-core/src/utils.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
2727
* @ref http://tycho01.github.io/typical/modules/_object_nonmatchingpropsnames_.html
2828
*/
2929
type NonMatchingPropNames<T, X> = {
30-
[K in keyof T]: T[K] extends X ? never : K
30+
[K in keyof T]: T[K] extends X ? never : K;
3131
}[keyof T];
3232

3333
/**
@@ -77,7 +77,11 @@ function debug<TNode = SVGElement>(
7777
): void {
7878
// tslint:disable-next-line:no-console
7979
console.log(
80-
JSON.stringify(commits.map((commit) => pick(commit, paths)), null, 2),
80+
JSON.stringify(
81+
commits.map((commit) => pick(commit, paths)),
82+
null,
83+
2,
84+
),
8185
);
8286
}
8387

@@ -95,7 +99,7 @@ function isUndefined(obj: any): obj is undefined {
9599
*
96100
* @param obj
97101
*/
98-
function withoutUndefinedKeys<T extends object>(
102+
function withoutUndefinedKeys<T>(
99103
obj: T = {} as T,
100104
): NonMatchingProp<T, undefined> {
101105
return (Object.keys(obj) as [keyof T]).reduce<T>(

packages/gitgraph-js/src/gitgraph.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,7 @@ function createGitgraph(
155155
commitYWithOffsets = orientedCommits.reduce<CommitYWithOffsets>(
156156
(newOffsets, commit) => {
157157
const commitY = parseInt(
158-
commit
159-
.getAttribute("transform")!
160-
.split(",")[1]
161-
.slice(0, -1),
158+
commit.getAttribute("transform")!.split(",")[1].slice(0, -1),
162159
10,
163160
);
164161

packages/gitgraph-node/src/compute-graph-map.test.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,10 @@ describe("compute cells colors", () => {
297297

298298
const graphMap = computeGraphMap(core);
299299

300-
expectGraphMapColors(graphMap).toEqual([["red", "red"], ["red", "red"]]);
300+
expectGraphMapColors(graphMap).toEqual([
301+
["red", "red"],
302+
["red", "red"],
303+
]);
301304
});
302305

303306
it("for commits on 2 branches", () => {

packages/gitgraph-node/src/compute-graph-map/connect-branch-commits.ts

+8-12
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,10 @@ function connectBranchCommits(branchColor: string, line: GraphLine): GraphLine {
1515
number[][]
1616
>(
1717
(cells) =>
18-
cells.reduce(
19-
(point, { value }, index) => {
20-
if (value === GraphSymbol.Commit) point.push(index);
21-
return point;
22-
},
23-
[] as number[],
24-
),
18+
cells.reduce((point, { value }, index) => {
19+
if (value === GraphSymbol.Commit) point.push(index);
20+
return point;
21+
}, [] as number[]),
2522
(points) =>
2623
points.map((point, index) => {
2724
// Duplicate inner points so we can build path chunks.
@@ -34,11 +31,10 @@ function connectBranchCommits(branchColor: string, line: GraphLine): GraphLine {
3431
(chunks) => chunks.filter((path) => path.length === 2),
3532
)(line);
3633

37-
return line.map(
38-
(cell, index) =>
39-
branchPaths.some(isInBranchPath(index))
40-
? { value: GraphSymbol.Branch, color: branchColor }
41-
: cell,
34+
return line.map((cell, index) =>
35+
branchPaths.some(isInBranchPath(index))
36+
? { value: GraphSymbol.Branch, color: branchColor }
37+
: cell,
4238
);
4339
}
4440

packages/gitgraph-react/src/Arrow.tsx

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import * as React from "react";
22
import { ReactSvgElement } from "./types";
3-
import {
4-
GitgraphCore,
5-
Commit,
6-
arrowSvgPath,
7-
} from "@gitgraph/core";
3+
import { GitgraphCore, Commit, arrowSvgPath } from "@gitgraph/core";
84

95
interface ArrowProps {
106
commits: Array<Commit<ReactSvgElement>>;
@@ -16,15 +12,17 @@ interface ArrowProps {
1612

1713
export class Arrow extends React.Component<ArrowProps> {
1814
public render() {
19-
const parent = this.props.commits.find(({ hash }) => hash === this.props.parentHash);
15+
const parent = this.props.commits.find(
16+
({ hash }) => hash === this.props.parentHash,
17+
);
2018
if (!parent) return null;
2119

2220
// Starting point, relative to commit
2321
const origin = this.props.gitgraph.reverseArrow
2422
? {
25-
x: this.props.commitRadius + (parent.x - this.props.commit.x),
26-
y: this.props.commitRadius + (parent.y - this.props.commit.y),
27-
}
23+
x: this.props.commitRadius + (parent.x - this.props.commit.x),
24+
y: this.props.commitRadius + (parent.y - this.props.commit.y),
25+
}
2826
: { x: this.props.commitRadius, y: this.props.commitRadius };
2927

3028
return (

0 commit comments

Comments
 (0)