Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit acdd15d

Browse files
author
Cole J Calamos
committed
Updated code quality
1 parent a16ea8d commit acdd15d

File tree

8 files changed

+23
-27
lines changed

8 files changed

+23
-27
lines changed

.eslintrc.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,4 @@ module.exports = {
1313
"plugin:@typescript-eslint/recommended",
1414
"prettier/@typescript-eslint",
1515
],
16-
rules: {
17-
"@typescript-eslint/ban-types": 0
18-
},
1916
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@ccalamos/gatsby-source-googlemaps-static",
33
"description": "Gatsby source plugin for Google Maps Static API",
4-
"version": "2.0.0",
4+
"version": "2.0.1",
55
"author": "Cole Calamos <cole@colejcalamos.com>",
66
"bugs": {
77
"url": "https://github.com/ccalamos/gatsby-source-googlemaps-static/issues"

src/__tests__/path.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ describe("path", () => {
2424

2525
it("with config options filled", () => {
2626
const path = new Path({
27-
points: ["40.737102,-73.990318", "40.749825,-73.987963"],
2827
color: "0x00000000",
2928
fillColor: "0xFFFF0033",
3029
geoDesic: true,
30+
points: ["40.737102,-73.990318", "40.749825,-73.987963"],
3131
weight: "5",
3232
});
3333

src/cache-file.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ abstract class CacheFile {
1212
private axiosClient: AxiosInstance;
1313
private cache: NodePluginArgs["cache"];
1414

15-
private _hash = "";
15+
private hash = "";
1616
private guid = "";
1717
private cacheId = "";
1818
private isCached = false;
1919

2020
protected constructor(cache: NodePluginArgs["cache"], hash: string) {
2121
this.cache = cache;
22-
this.hash = hash;
23-
22+
this.setHash(hash);
2423
this.checkCache();
2524

2625
this.axiosClient = Axios.create({
@@ -48,7 +47,7 @@ abstract class CacheFile {
4847
return new Promise((resolve) =>
4948
resolve(
5049
this.path
51-
? { path: this.path, hash: this._hash }
50+
? { path: this.path, hash: this.hash }
5251
: this.downloadFile(url, store, ext),
5352
),
5453
);
@@ -73,8 +72,8 @@ abstract class CacheFile {
7372
.then((path: string) => this.setCache(path));
7473
}
7574

76-
private set hash(newHash: string) {
77-
this._hash = newHash;
75+
private setHash(newHash: string) {
76+
this.hash = newHash;
7877
this.guid = this.generateGUID();
7978
this.cacheId = `google-maps-static-cache-${this.guid}`;
8079
}
@@ -91,7 +90,7 @@ abstract class CacheFile {
9190
private async setCache(path: string): Promise<CachePath> {
9291
return this.cache.set(this.cacheId, path).then(() => {
9392
this.path = path;
94-
return { path: this.path, hash: this._hash };
93+
return { path: this.path, hash: this.hash };
9594
});
9695
}
9796

@@ -100,7 +99,7 @@ abstract class CacheFile {
10099
}
101100

102101
private generateGUID(): string {
103-
return crypto.createHash("sha256").update(this._hash).digest("hex");
102+
return crypto.createHash("sha256").update(this.hash).digest("hex");
104103
}
105104
}
106105

src/marker.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ class Marker {
1515
}
1616
}
1717

18+
public toString(): string {
19+
return this.options ?? "";
20+
}
21+
1822
private encodeOptions(color?: string, size?: string, label?: string): string {
1923
return (
2024
this.generateEncoding("color", color) +
@@ -42,10 +46,6 @@ class Marker {
4246
value,
4347
)}${encodeURIComponent("|")}`;
4448
}
45-
46-
public toString(): string {
47-
return this.options ?? "";
48-
}
4949
}
5050

5151
export default Marker;

src/path.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ class Path {
1313
this.points = options.points.map((point) => encodeURIComponent(point));
1414
}
1515

16+
public toString(): string {
17+
return this.generateParams();
18+
}
19+
1620
private newOption(key: string, value: string | boolean | undefined): string {
1721
return value ? `${key}:${value}${encodeURIComponent("|")}` : "";
1822
}
@@ -26,10 +30,6 @@ class Path {
2630
this.points.join(encodeURIComponent("|"))
2731
);
2832
}
29-
30-
public toString(): string {
31-
return this.generateParams();
32-
}
3333
}
3434

3535
export default Path;

src/static-map.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class StaticMap
2525
private paths?: Path[];
2626
private markers?: Marker[];
2727
private styles?: Style[];
28-
private visible?: String[];
28+
private visible?: Stringable[];
2929

3030
public constructor(
3131
options: ConfigOptions,
@@ -120,7 +120,7 @@ class StaticMap
120120
);
121121
}
122122

123-
private getWayPoints(): (String | Path | Marker)[] {
123+
private getWayPoints(): Stringable[] {
124124
return [...(this.markers ?? this.visible ?? this.paths ?? [])];
125125
}
126126
}

src/style.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ class Style {
1111
);
1212
}
1313

14+
public toString(): string {
15+
return this.generateParams();
16+
}
17+
1418
private newOption(key: string, value: string | undefined): string {
1519
return value ? `${key}:${value}${encodeURIComponent("|")}` : "";
1620
}
@@ -28,10 +32,6 @@ class Style {
2832
ruleStr
2933
);
3034
}
31-
32-
public toString(): string {
33-
return this.generateParams();
34-
}
3535
}
3636

3737
export default Style;

0 commit comments

Comments
 (0)