Skip to content

Commit a34afcc

Browse files
authored
enable more eslint rules and more prettifying (#1410)
* reenable @typescript-eslint/no-redundant-type-constituents * fine-tune @typescript-eslint/no-namespace * reenable @typescript-eslint/no-explicit-any (disable in specific files as needed) * make output JS even prettier * normalize all root init() calls * enable no-shadow rule * add a type to innerMap vars * enable @typescript-eslint/no-deprecated * fix for "Type 'undefined' is not assignable to type 'LatLng | LatLngLiteral'." * Avoid '[,' in the code * fix newly introduced build failures
1 parent f6a00b4 commit a34afcc

108 files changed

Lines changed: 417 additions & 319 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.

dist/samples/deckgl-polygon/app/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,19 @@ let googleMapsOverlay: deck.GoogleMapsOverlay; // Declare googleMapsOverlay outs
1212
// Declare global namespace for Deck.gl to satisfy TypeScript compiler
1313
declare namespace deck {
1414
class PolygonLayer {
15+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1516
constructor(props: any);
17+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1618
props: any;
19+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1720
clone(props: any): PolygonLayer;
1821
pickable: boolean; // Added pickable property
1922
}
2023
class GoogleMapsOverlay {
24+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2125
constructor(props: any);
2226
setMap(map: google.maps.Map | null): void;
27+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2328
setProps(props: any): void;
2429
}
2530
// Add other Deck.gl types used globally if needed
@@ -71,8 +76,11 @@ async function initMap(): Promise<void> {
7176
id: 'PolygonLayer',
7277
data: 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf-zipcodes.json',
7378

79+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7480
getPolygon: (d: any) => d.contour, // Use 'any' for simplicity
81+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7582
getElevation: (d: any) => d.population / d.area / 10, // Use 'any' for simplicity
83+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7684
getFillColor: (d: any) => [d.population / d.area / 60, 140, 0], // Use 'any' for simplicity
7785
getLineColor: [255, 255, 255],
7886
getLineWidth: 20,
@@ -89,6 +97,7 @@ async function initMap(): Promise<void> {
8997
}, 100); // 100ms delay
9098
}
9199
},
100+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
92101
onHover: ({ object, x, y }: { object: any; x: number; y: number }) => {
93102
// Use 'any' for object for simplicity
94103
const tooltip = document.getElementById('tooltip');

dist/samples/deckgl-polygon/docs/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ async function initMap() {
5656
id: 'PolygonLayer',
5757
data: 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf-zipcodes.json',
5858

59+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5960
getPolygon: (d) => d.contour, // Use 'any' for simplicity
61+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6062
getElevation: (d) => d.population / d.area / 10, // Use 'any' for simplicity
63+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6164
getFillColor: (d) => [d.population / d.area / 60, 140, 0], // Use 'any' for simplicity
6265
getLineColor: [255, 255, 255],
6366
getLineWidth: 20,
@@ -74,6 +77,7 @@ async function initMap() {
7477
}, 100); // 100ms delay
7578
}
7679
},
80+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7781
onHover: ({ object, x, y }) => {
7882
// Use 'any' for object for simplicity
7983
const tooltip = document.getElementById('tooltip');

dist/samples/deckgl-polygon/docs/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,19 @@ let googleMapsOverlay: deck.GoogleMapsOverlay; // Declare googleMapsOverlay outs
1212
// Declare global namespace for Deck.gl to satisfy TypeScript compiler
1313
declare namespace deck {
1414
class PolygonLayer {
15+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1516
constructor(props: any);
17+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1618
props: any;
19+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1720
clone(props: any): PolygonLayer;
1821
pickable: boolean; // Added pickable property
1922
}
2023
class GoogleMapsOverlay {
24+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2125
constructor(props: any);
2226
setMap(map: google.maps.Map | null): void;
27+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2328
setProps(props: any): void;
2429
}
2530
// Add other Deck.gl types used globally if needed
@@ -71,8 +76,11 @@ async function initMap(): Promise<void> {
7176
id: 'PolygonLayer',
7277
data: 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf-zipcodes.json',
7378

79+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7480
getPolygon: (d: any) => d.contour, // Use 'any' for simplicity
81+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7582
getElevation: (d: any) => d.population / d.area / 10, // Use 'any' for simplicity
83+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7684
getFillColor: (d: any) => [d.population / d.area / 60, 140, 0], // Use 'any' for simplicity
7785
getLineColor: [255, 255, 255],
7886
getLineWidth: 20,
@@ -89,6 +97,7 @@ async function initMap(): Promise<void> {
8997
}, 100); // 100ms delay
9098
}
9199
},
100+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
92101
onHover: ({ object, x, y }: { object: any; x: number; y: number }) => {
93102
// Use 'any' for object for simplicity
94103
const tooltip = document.getElementById('tooltip');

dist/samples/deckgl-polygon/jsfiddle/demo.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ async function initMap() {
5656
id: 'PolygonLayer',
5757
data: 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf-zipcodes.json',
5858

59+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5960
getPolygon: (d) => d.contour, // Use 'any' for simplicity
61+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6062
getElevation: (d) => d.population / d.area / 10, // Use 'any' for simplicity
63+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6164
getFillColor: (d) => [d.population / d.area / 60, 140, 0], // Use 'any' for simplicity
6265
getLineColor: [255, 255, 255],
6366
getLineWidth: 20,
@@ -74,6 +77,7 @@ async function initMap() {
7477
}, 100); // 100ms delay
7578
}
7679
},
80+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7781
onHover: ({ object, x, y }) => {
7882
// Use 'any' for object for simplicity
7983
const tooltip = document.getElementById('tooltip');

eslint.config.mjs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default defineConfig([
2626
'no-undef': 'off', // handled better by TS
2727
'prefer-const': 'error',
2828
'spaced-comment': ['error', 'always'],
29+
'no-shadow': 'error',
2930

3031
// temporarily downgraded to warn for historic reasons:
3132
'no-prototype-builtins': 'warn',
@@ -40,6 +41,9 @@ export default defineConfig([
4041
},
4142
},
4243
rules: {
44+
'no-shadow': 'off', // required to enable @typescript-eslint/no-shadow
45+
'@typescript-eslint/no-shadow': 'error',
46+
'@typescript-eslint/no-deprecated': 'error',
4347
'@typescript-eslint/no-misused-promises': [
4448
'error',
4549
{
@@ -49,16 +53,17 @@ export default defineConfig([
4953
},
5054
},
5155
],
56+
'@typescript-eslint/no-namespace': [
57+
'error',
58+
{ allowDeclarations: true, allowDefinitionFiles: true },
59+
],
5260

5361
// temporarily downgraded to warn for historic reasons:
5462
'@typescript-eslint/no-unsafe-member-access': 'warn',
5563
'@typescript-eslint/no-unsafe-assignment': 'warn',
5664
'@typescript-eslint/no-unsafe-call': 'warn',
57-
'@typescript-eslint/no-explicit-any': 'warn',
58-
'@typescript-eslint/no-namespace': 'warn',
5965
'@typescript-eslint/no-unsafe-return': 'warn',
6066
'@typescript-eslint/no-unsafe-argument': 'warn',
61-
'@typescript-eslint/no-redundant-type-constituents': 'warn',
6267
},
6368
},
6469
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
// [START maps_3d_accessibility_features]
8-
async function initMap() {
8+
async function init() {
99
const [
1010
{ Map3DElement, Marker3DInteractiveElement, PopoverElement },
1111
{ PinElement },
@@ -82,5 +82,5 @@ async function initMap() {
8282
document.body.append(map);
8383
}
8484

85-
void initMap();
85+
void init();
8686
// [END maps_3d_accessibility_features]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
// [START maps_3d_camera_boundary]
8-
async function initMap() {
8+
async function init() {
99
const { Map3DElement } = await google.maps.importLibrary('maps3d');
1010

1111
const map = new Map3DElement({
@@ -19,5 +19,5 @@ async function initMap() {
1919
document.body.append(map);
2020
}
2121

22-
void initMap();
22+
void init();
2323
// [END maps_3d_camera_boundary]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
// [START maps_3d_camera_center]
8-
async function initMap(): Promise<void> {
8+
async function init(): Promise<void> {
99
// Import the needed libraries.
1010
await google.maps.importLibrary('maps3d');
1111

@@ -36,5 +36,5 @@ async function initMap(): Promise<void> {
3636
});
3737
}
3838

39-
void initMap();
39+
void init();
4040
// [END maps_3d_camera_center]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const layerStyle = {
1616
const mapElement = document.querySelector('gmp-map')!;
1717
const placeAutocomplete = document.querySelector('gmp-place-autocomplete')!;
1818

19-
async function initMap() {
19+
async function init() {
2020
// Request needed libraries.
2121
await Promise.all([
2222
google.maps.importLibrary('maps'),
@@ -53,5 +53,5 @@ async function initMap() {
5353
}
5454
);
5555
}
56-
void initMap();
56+
void init();
5757
// [END maps_3d_coverage_map]

samples/3d-localization/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
// [START maps_3d_localization]
8-
async function initMap() {
8+
async function init() {
99
const { Map3DElement } = await google.maps.importLibrary('maps3d');
1010

1111
const map = new Map3DElement({
@@ -26,5 +26,5 @@ async function initMap() {
2626
document.body.append(map);
2727
}
2828

29-
void initMap();
29+
void init();
3030
// [END maps_3d_localization]

0 commit comments

Comments
 (0)