Skip to content

Commit 67e5de8

Browse files
authored
chore: add eslint and fix problems (#1045)
1 parent 3a37454 commit 67e5de8

Some content is hidden

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

54 files changed

+1659
-291
lines changed

.eslintignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
bazel-*
2+
coverage/
3+
dist/
4+
docs/
5+
lib/
6+
node_modules/
7+
public/

.eslintrc.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
3+
"parserOptions": {
4+
"ecmaVersion": 12,
5+
"sourceType": "module"
6+
},
7+
"plugins": ["jest"],
8+
"rules": {
9+
"no-var": 2,
10+
"prefer-arrow-callback": 2
11+
},
12+
"overrides": [
13+
{
14+
"files": ["*.ts", "*.tsx"],
15+
"parser": "@typescript-eslint/parser",
16+
"plugins": ["@typescript-eslint"],
17+
"extends": ["plugin:@typescript-eslint/recommended"],
18+
"rules": {
19+
"@typescript-eslint/ban-ts-comment": 0,
20+
"@typescript-eslint/ban-types": 1,
21+
"@typescript-eslint/no-empty-function": 1,
22+
"@typescript-eslint/no-var-requires": 0,
23+
"@typescript-eslint/member-ordering": 1
24+
}
25+
}
26+
],
27+
"env": {
28+
"browser": false,
29+
"node": true,
30+
"es6": true,
31+
"jest/globals": true
32+
},
33+
"globals": { "google": "readonly" }
34+
}

e2e/client.test.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { Client, defaultAxiosInstance, defaultHttpsAgent, type ElevationResponse } from "../src";
17+
import {
18+
Client,
19+
defaultAxiosInstance,
20+
defaultHttpsAgent,
21+
type ElevationResponse,
22+
} from "../src";
1823
import { AxiosError } from "axios";
1924

2025
test("client should work with defaults", async () => {

e2e/compression.test.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test("server responds with compressed content", async () => {
2222
origin: "Seattle, WA",
2323
destination: "San Francisco, CA",
2424
waypoints: [{ lat: 40, lng: -120 }],
25-
key: process.env.GOOGLE_MAPS_API_KEY
25+
key: process.env.GOOGLE_MAPS_API_KEY,
2626
};
2727

2828
// Use of directions here is entirely arbitrary and any API that supports
@@ -36,9 +36,10 @@ test("server responds with compressed content", async () => {
3636
// that the server responds with a compressed response must be done via the
3737
// raw headers.
3838

39-
const {rawHeaders} = r.request.res;
40-
const contentEncodingIndex = rawHeaders
41-
.findIndex(i => i.toLowerCase() === "content-encoding");
39+
const { rawHeaders } = r.request.res;
40+
const contentEncodingIndex = rawHeaders.findIndex(
41+
(i) => i.toLowerCase() === "content-encoding"
42+
);
4243

4344
expect(contentEncodingIndex).not.toBe(-1);
4445
expect(rawHeaders[contentEncodingIndex + 1]).toBe("gzip");

e2e/elevation.test.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
import axios from "axios";
1817
import { elevation } from "../src/elevation";
1918

2019
test("elevation should return correct result", async () => {
2120
const location = { lat: 10, lng: 20 };
2221

2322
const params = {
2423
locations: [location, location],
25-
key: process.env.GOOGLE_MAPS_API_KEY
24+
key: process.env.GOOGLE_MAPS_API_KEY,
2625
};
2726

2827
const r = await elevation({ params: params });
@@ -33,13 +32,13 @@ test("elevation should return correct result", async () => {
3332
test("elevation should return correct result with path params", async () => {
3433
const path = [
3534
{ lat: 35, lng: -110 },
36-
{ lat: 45, lng: -110 }
35+
{ lat: 45, lng: -110 },
3736
];
3837

3938
const params = {
4039
path: path,
4140
samples: 10,
42-
key: process.env.GOOGLE_MAPS_API_KEY
41+
key: process.env.GOOGLE_MAPS_API_KEY,
4342
};
4443

4544
const r = await elevation({ params: params });

e2e/geocode/geocode.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { geocode, GeocodeRequest } from "../../src/geocode/geocode";
17+
import { geocode } from "../../src/geocode/geocode";
1818

1919
test("geocode should call axios correctly", async () => {
2020
const params = {
2121
address: "Seattle",
2222
components: { country: "us" },
2323
bounds: {
2424
northeast: { lat: 50, lng: -110 },
25-
southwest: { lat: 35, lng: -130 }
25+
southwest: { lat: 35, lng: -130 },
2626
},
27-
key: process.env.GOOGLE_MAPS_API_KEY
27+
key: process.env.GOOGLE_MAPS_API_KEY,
2828
};
2929

3030
const r = await geocode({ params: params });

e2e/geocode/reversegeocode.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ test("reverseGeocode should return correct response", async () => {
2020
const params = {
2121
latlng: {
2222
lat: 60.168997,
23-
lng: 24.9433353
23+
lng: 24.9433353,
2424
},
25-
key: process.env.GOOGLE_MAPS_API_KEY
25+
key: process.env.GOOGLE_MAPS_API_KEY,
2626
};
2727
const r = await reverseGeocode({ params: params });
2828
expect(r.data.results.length).toBeTruthy();
@@ -31,7 +31,7 @@ test("reverseGeocode should return correct response", async () => {
3131
test("reverseGeocode should return correct response using place_id", async () => {
3232
const params = {
3333
place_id: "ChIJKxDbe_lYwokRVf__s8CPn-o",
34-
key: process.env.GOOGLE_MAPS_API_KEY
34+
key: process.env.GOOGLE_MAPS_API_KEY,
3535
};
3636
const r = await reverseGeocode({ params: params });
3737
expect(r.data.results.length).toBeTruthy();

e2e/roads/nearestroads.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { LatLng } from "../../src/common";
2020
test("nearestRoads should return correct response", async () => {
2121
const params = {
2222
points: [[60.17088, 24.942795] as LatLng],
23-
key: process.env.GOOGLE_MAPS_API_KEY
23+
key: process.env.GOOGLE_MAPS_API_KEY,
2424
};
2525

2626
const r = await nearestRoads({ params: params });

e2e/roads/snaptoroads.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ test("snapToRoads should have corect result", async () => {
2222
path: [
2323
[60.17088, 24.942795] as LatLng,
2424
[60.170879, 24.942796] as LatLng,
25-
[60.170877, 24.942796] as LatLng
25+
[60.170877, 24.942796] as LatLng,
2626
],
2727
interpolate: false,
28-
key: process.env.GOOGLE_MAPS_API_KEY
28+
key: process.env.GOOGLE_MAPS_API_KEY,
2929
};
3030

3131
const r = await snapToRoads({ params: params });

e2e/timezone.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ test("elevation should get an ok response", async () => {
2323
location: "30, 50",
2424
timestamp: new Date(),
2525
language: Language.en,
26-
key: process.env.GOOGLE_MAPS_API_KEY
26+
key: process.env.GOOGLE_MAPS_API_KEY,
2727
};
2828
const r = await timezone({ params: params });
2929

jest.config.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ module.exports = {
1919
preset: "ts-jest/presets/js-with-ts",
2020
testEnvironment: "node",
2121
// some dependencies are esm and need to be compiled to work in jest
22-
transformIgnorePatterns: ['/node_modules/(?!(axios|retry-axios|query-string|decode-uri-component|split-on-first|filter-obj)/)'],
22+
transformIgnorePatterns: [
23+
"/node_modules/(?!(axios|retry-axios|query-string|decode-uri-component|split-on-first|filter-obj)/)",
24+
],
2325
collectCoverage: true,
24-
collectCoverageFrom: ["src/**/([a-zA-Z_]*).{js,ts}", "!**/*.test.{js,ts}"]
26+
collectCoverageFrom: ["src/**/([a-zA-Z_]*).{js,ts}", "!**/*.test.{js,ts}"],
2527
};

0 commit comments

Comments
 (0)