Skip to content

Commit 2dbfdc6

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

50 files changed

Lines changed: 389 additions & 283 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
}

eslint.config.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,14 @@ export default defineConfig([
7272
'@typescript-eslint/no-non-null-assertion': 'off',
7373

7474
// downgraded to warn for historic reasons:
75-
'@typescript-eslint/restrict-template-expressions': 'warn',
75+
'@typescript-eslint/restrict-template-expressions': [
76+
'warn',
77+
{
78+
allowNumber: true,
79+
allowNullish: true,
80+
allowBoolean: true,
81+
},
82+
],
7683
'@typescript-eslint/restrict-plus-operands': 'warn',
7784
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
7885

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ 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
});

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ 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;
4746

4847
headingVal.textContent = heading;
4948
tiltVal.textContent = tilt;
@@ -68,7 +67,7 @@ async function initMap(): Promise<void> {
6867
lngSlider.value = lng;
6968
altitudeVal.textContent = alt;
7069

71-
codeElem.textContent = `<gmp-map-3d center="${lat},${lng},${alt}" mode="${mode}" tilt="${tilt}" range="${range}" heading="${heading}" fov="${fov}" roll="${roll}"></gmp-map-3d>`;
70+
codeElem.textContent = `<gmp-map-3d center="${lat},${lng},${alt}" tilt="${tilt}" range="${range}" heading="${heading}" fov="${fov}" roll="${roll}"></gmp-map-3d>`;
7271
}
7372
};
7473

@@ -124,8 +123,14 @@ async function initMap(): Promise<void> {
124123
map3DElement.tilt = Math.max(0, val);
125124
} else if (prop === 'fov') {
126125
map3DElement.fov = Math.min(80, Math.max(5, val));
126+
} else if (prop === 'heading') {
127+
map3DElement.heading = val;
128+
} else if (prop === 'range') {
129+
map3DElement.range = val;
130+
} else if (prop === 'roll') {
131+
map3DElement.roll = val;
127132
} else {
128-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
133+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
129134
(map3DElement as any)[prop] = val;
130135
}
131136
updateUI();

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: 5 additions & 4 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 google.maps.places.PlaceAutocompleteElement;
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: ${place.displayName}`
53+
);
5354
return;
5455
}
5556
void flyToPlace(place);
@@ -107,7 +108,7 @@ async function getElevationforPoint(
107108
locations: [location],
108109
});
109110

110-
if (!elevationResponse?.results.length) {
111+
if (!elevationResponse.results.length) {
111112
window.alert(
112113
`Insufficient elevation data for place: ${place.displayName}`
113114
);

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 ?? []) {

0 commit comments

Comments
 (0)