Skip to content

Commit e6b3935

Browse files
committed
fix: Fixes for eslint issues.
1 parent ab88b61 commit e6b3935

52 files changed

Lines changed: 402 additions & 305 deletions

File tree

Some content is hidden

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

e2e/samples.spec.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
/* eslint-disable @typescript-eslint/no-unsafe-return */
18-
1917
import { test, expect } from '@playwright/test';
2018
import fs from 'node:fs';
2119
import path from 'node:path';
@@ -138,7 +136,7 @@ foldersToTest.forEach((sampleFolder) => {
138136
test(`test ${sampleFolder}`, async ({ page }) => {
139137
// START run the preview
140138
// Get an available port
141-
const port = 8080;
139+
const port = '8080';
142140
const url = `http://localhost:${port}/`;
143141

144142
const viteProcess = childProcess.spawn(
@@ -205,8 +203,9 @@ foldersToTest.forEach((sampleFolder) => {
205203

206204
// Wait for Google Maps to load.
207205
await page.waitForFunction(
208-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
209-
() => (window as any).google?.maps,
206+
() =>
207+
(window as typeof window & { google?: { maps?: unknown } })
208+
.google?.maps,
210209
{ timeout: 500 }
211210
);
212211

@@ -216,12 +215,10 @@ foldersToTest.forEach((sampleFolder) => {
216215
// Assertions. These must be met or the test will fail.
217216
// The sample must load the Google Maps API.
218217
const hasGoogleMaps = await page.evaluate(() => {
219-
return (
220-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
221-
typeof (window as any).google !== 'undefined' &&
222-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
223-
typeof (window as any).google.maps !== 'undefined'
224-
);
218+
const w = window as typeof window & {
219+
google?: { maps?: unknown };
220+
};
221+
return typeof w.google?.maps !== 'undefined';
225222
});
226223
expect(hasGoogleMaps).toBeTruthy();
227224

@@ -240,7 +237,7 @@ foldersToTest.forEach((sampleFolder) => {
240237
process.kill(viteProcess.pid, 'SIGINT');
241238
} catch (error) {
242239
console.warn(
243-
`Failed to kill Vite process for ${sampleFolder} (PID: ${viteProcess.pid}):`,
240+
`Failed to kill Vite process for ${sampleFolder} (PID: ${String(viteProcess.pid)}):`,
244241
error
245242
);
246243
}

e2e/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ import process from 'node:process';
2323

2424
export async function waitForGoogleMapsToLoad(page: Page) {
2525
await page.waitForFunction(
26-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return
27-
() => (window as any).google?.maps
26+
() =>
27+
(window as typeof window & { google?: { maps?: unknown } }).google
28+
?.maps
2829
);
2930
await page.waitForTimeout(100);
3031
}

samples/3d-accessibility-features/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ async function init() {
5151

5252
tourStops.forEach(({ position, title }, i) => {
5353
const pin = new PinElement({
54-
glyphText: `${i + 1}`,
54+
glyphText: String(i + 1),
5555
scale: 1.5,
5656
glyphColor: '#FFFFFF',
5757
});
5858
const popover = new PopoverElement();
5959

60-
const content = `${i + 1}. ${title}`;
60+
const content = `${String(i + 1)}. ${title}`;
6161
const header = document.createElement('span');
6262
// Include the label for screen readers.
63-
header.ariaLabel = `This is marker ${i + 1}. ${title}`;
63+
header.ariaLabel = `This is marker ${String(i + 1)}. ${title}`;
6464
header.slot = 'header';
6565

6666
popover.append(header);

samples/3d-camera-position/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async function initMap(): Promise<void> {
4343
const fov = fovClamped.toString();
4444
const roll = map3DElement.roll?.toFixed(0) ?? '0';
4545
const center = map3DElement.center;
46-
const mode = map3DElement.mode;
46+
const mode = map3DElement.mode ?? '';
4747

4848
headingVal.textContent = heading;
4949
tiltVal.textContent = tilt;
@@ -124,9 +124,12 @@ async function initMap(): Promise<void> {
124124
map3DElement.tilt = Math.max(0, val);
125125
} else if (prop === 'fov') {
126126
map3DElement.fov = Math.min(80, Math.max(5, val));
127-
} else {
128-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
129-
(map3DElement as any)[prop] = val;
127+
} else if (prop === 'heading') {
128+
map3DElement.heading = val;
129+
} else if (prop === 'range') {
130+
map3DElement.range = val;
131+
} else if (prop === 'roll') {
132+
map3DElement.roll = val;
130133
}
131134
updateUI();
132135
});

samples/3d-clamp-mode/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
// [START maps_3d_clamp_mode]
8-
let polyline: google.maps.maps3d.Polyline3DElement;
8+
let polyline: google.maps.maps3d.Polyline3DElement | undefined;
99

1010
async function init() {
1111
const { Map3DElement, Polyline3DElement } =

samples/3d-coverage-map/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ async function init() {
4040
placeAutocomplete.addEventListener(
4141
'gmp-select',
4242
async ({ placePrediction }) => {
43-
if (!placePrediction) return;
4443
const place = placePrediction.toPlace();
4544
await place.fetchFields({
4645
fields: ['location'],

samples/3d-map-events/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async function init() {
1515
(i) => i.textContent
1616
);
1717
for (const event of events) {
18-
mapElement?.addEventListener(event, () => {
18+
mapElement.addEventListener(event, () => {
1919
const eventElement = document.querySelector(`#${event}`);
2020
eventElement?.classList.add('active');
2121
setTimeout(() => {

samples/3d-places-autocomplete/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
87
/* eslint-disable @typescript-eslint/no-unsafe-call */
98

109
// [START maps_3d_places_autocomplete]
@@ -33,7 +32,7 @@ async function initAutocomplete() {
3332
const { PlaceAutocompleteElement } =
3433
await google.maps.importLibrary('places');
3534

36-
const placeAutocomplete = new PlaceAutocompleteElement();
35+
const placeAutocomplete = new PlaceAutocompleteElement() as HTMLElement;
3736
placeAutocomplete.id = 'place-autocomplete-input';
3837
const card = document.getElementById('pac-container')!;
3938
card.appendChild(placeAutocomplete);
@@ -49,7 +48,9 @@ async function initAutocomplete() {
4948
});
5049
// If the place has a geometry, then present it on a map.
5150
if (!place.location) {
52-
window.alert('No viewport for input: ' + place.displayName);
51+
window.alert(
52+
`No viewport for input: ${String(place.displayName)}`
53+
);
5354
return;
5455
}
5556
void flyToPlace(place);
@@ -107,9 +108,9 @@ async function getElevationforPoint(
107108
locations: [location],
108109
});
109110

110-
if (!elevationResponse?.results.length) {
111+
if (!elevationResponse.results.length) {
111112
window.alert(
112-
`Insufficient elevation data for place: ${place.displayName}`
113+
`Insufficient elevation data for place: ${String(place.displayName)}`
113114
);
114115
return defaultElevation;
115116
}

samples/3d-places/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ async function init() {
2929

3030
// Display place details.
3131
document.getElementById('placeName')!.innerHTML =
32-
'<b>Name :</b><br>&nbsp;' + place.displayName;
32+
`<b>Name :</b><br>&nbsp;${place.displayName ?? ''}`;
3333
document.getElementById('placeId')!.innerHTML =
34-
'<b>Id :</b><br>&nbsp;' + place.id;
34+
`<b>Id :</b><br>&nbsp;${place.id}`;
3535
document.getElementById('placeType')!.innerHTML = '<b>Types :<b/>';
3636

3737
for (const type of place.types ?? []) {

samples/3d-polygon-click-event/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function randomizeHexColor(originalHexColor: string) {
5454
const g = Math.floor(Math.random() * 256);
5555
const b = Math.floor(Math.random() * 256);
5656

57-
console.log(r + ' ' + g + ' ' + b);
57+
console.log(`${String(r)} ${String(g)} ${String(b)}`);
5858

5959
// Convert decimal to 2-digit hex, padding with '0' if needed
6060
const rHex = ('0' + r.toString(16)).slice(-2);

0 commit comments

Comments
 (0)