Skip to content

Commit e876ad6

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/eslint-10.2.0
2 parents 5c87660 + f40a683 commit e876ad6

File tree

68 files changed

+440
-205
lines changed

Some content is hidden

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

68 files changed

+440
-205
lines changed

.github/workflows/test-all.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
node-version-file: '.nvmrc'
2525
- run: npm ci
26-
- run: npm run lint
26+
- run: npm run lint -- --max-warnings 0
2727
if: '!cancelled()'
2828
- run: npm run lint-css
2929
if: '!cancelled()'

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
### ✨ Features and improvements
33
- _...Add new stuff here..._
44
- Add `touchZoomRotate.setZoomRate()` and `touchZoomRotate.setZoomThreshold()` to customize touch zoom speed and pinch sensitivity ([#7271](https://github.com/maplibre/maplibre-gl-js/issues/7271))
5+
- Improve ability to communicate with imported scripts in workers and use `makeRequest` in workres as well ([#7451](https://github.com/maplibre/maplibre-gl-js/issues/7451)) (by [@HarelM](https://github.com/HarelM))
6+
- Allow `opacity` and `opacityWhenCovered` in `Marker` and `MarkerOptions` to accept `number` in addition to `string`, and add `maplibregl-marker-covered` CSS class to `Marker` element when covered by 3D terrain or a globe ([#7433](https://github.com/maplibre/maplibre-gl-js/issues/7433)) (by [@YuChunTsao](https://github.com/YuChunTsao))
57

68
### 🐞 Bug fixes
79
- Fix polygon text label placement drifting far from center for convex polygons at high zoom due to coordinate rounding in geojson-vt ([#7380](https://github.com/maplibre/maplibre-gl-js/pull/7380)) (by [@CommanderStorm](https://github.com/CommanderStorm))
10+
- Ensure that a successful ArrayBuffer response from a custom protocol that is null/undefined is set to an empty ArrayBuffer ([#7427](https://github.com/maplibre/maplibre-gl-js/pull/7427)) (by [@neodescis](https://github.com/neodescis))
11+
- Fix error in `_contextRestored` when map was initialized without a style ([#7432](https://github.com/maplibre/maplibre-gl-js/issues/7432)) (by [@mvanhorn](https://github.com/mvanhorn))
12+
- Fix issue with the cache used for zoomLevelsToOverscale feature ([#7450](https://github.com/maplibre/maplibre-gl-js/issues/7450)) (by [@HarelM](https://github.com/HarelM))
813
- _...Add new stuff here..._
914

1015
## 5.22.0
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
export default {
2+
meta: {
3+
type: 'suggestion',
4+
docs: {
5+
description: 'Prefer type aliases over interfaces for plain data shapes (no methods, no inheritance)',
6+
},
7+
messages: {
8+
preferType: 'Use a type alias instead of an interface for plain data shapes.',
9+
},
10+
schema: [],
11+
},
12+
create(context) {
13+
return {
14+
TSInterfaceDeclaration(node) {
15+
if (node.extends && node.extends.length > 0) {
16+
return;
17+
}
18+
19+
const hasBehavior = node.body.body.some(
20+
(member) =>
21+
member.type === 'TSMethodSignature' ||
22+
member.type === 'TSCallSignatureDeclaration' ||
23+
member.type === 'TSConstructSignatureDeclaration' ||
24+
(member.type === 'TSPropertySignature' &&
25+
(member.typeAnnotation?.typeAnnotation?.type === 'TSFunctionType' ||
26+
member.typeAnnotation?.typeAnnotation?.type === 'TSTypeQuery'))
27+
);
28+
29+
if (!hasBehavior) {
30+
context.report({
31+
node: node.id,
32+
messageId: 'preferType',
33+
});
34+
}
35+
},
36+
};
37+
},
38+
};

eslint.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import globals from 'globals';
66
import tsParser from '@typescript-eslint/parser';
77
import react from 'eslint-plugin-react';
88
import html from 'eslint-plugin-html';
9+
import preferTypeForDataShapes from './build/eslint-rules/prefer-type-for-data-shapes.js';
910

1011
export default [
1112
{
12-
ignores: ['build/*.js', 'build/rollup/**', 'staging/**', 'coverage/**', 'node_modules/**', 'docs/**', 'dist/**']
13+
ignores: ['build/*.js', 'build/rollup/**', 'staging/**', 'coverage/**', 'node_modules/**', 'docs/**', 'dist/**', '**/*_generated.js']
1314
},
1415
{
1516
ignores: ['test/bench/**'],
@@ -19,6 +20,7 @@ export default [
1920
'@stylistic': stylisticTs,
2021
tsdoc,
2122
vitest,
23+
'local': {rules: {'prefer-type-for-data-shapes': preferTypeForDataShapes}},
2224
},
2325

2426
linterOptions: {
@@ -40,6 +42,7 @@ export default [
4042
projectService: {
4143
allowDefaultProject: [
4244
'build/generate-*.ts',
45+
'build/eslint-rules/*.js',
4346
'test/build/*.ts',
4447
'eslint.config.js',
4548
'postcss.config.js',
@@ -66,6 +69,7 @@ export default [
6669
'@typescript-eslint/prefer-includes': 'error',
6770
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
6871
'@typescript-eslint/array-type': ['error', {default: 'array-simple'}],
72+
'local/prefer-type-for-data-shapes': 'error',
6973

7074
'prefer-object-spread': 'error',
7175
'prefer-object-has-own': 'error',

package-lock.json

Lines changed: 17 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
"glob": "^13.0.6",
9393
"globals": "^17.4.0",
9494
"is-builtin-module": "^5.0.0",
95-
"jsdom": "^29.0.1",
95+
"jsdom": "^29.0.2",
9696
"junit-report-builder": "^5.1.1",
9797
"minimist": "^1.2.8",
9898
"mock-geolocation": "^1.0.11",

src/geo/bounds.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,44 @@ export interface ReadOnlyBounds {
99

1010
/**
1111
* Returns whether this bounding box contains a point
12-
*
12+
*
1313
* @param point - The point to check
1414
* @returns True if this bounding box contains point, false otherwise.
1515
*/
1616
contains(point: Point2D): boolean;
1717

1818
/**
1919
* Returns true if this bounding box contains no points
20-
*
20+
*
2121
* @returns True if this bounding box contains no points.
2222
*/
2323
empty(): boolean;
2424

2525
/**
2626
* Returns the width of this bounding box.
27-
*
27+
*
2828
* @returns `maxX - minX`.
2929
*/
3030
width(): number;
3131

3232
/**
3333
* Returns the height of this bounding box.
34-
*
34+
*
3535
* @returns `maxY - minY`.
3636
*/
3737
height(): number;
3838

3939
/**
4040
* Returns true if this bounding box completely covers `other`.
41-
*
41+
*
4242
* @param other - The other bounding box
4343
* @returns True if this bounding box completely encloses `other`
4444
*/
4545
covers(other: ReadOnlyBounds): boolean;
4646

4747
/**
4848
* Returns true if this bounding box touches any part of `other`.
49-
*
49+
*
5050
* @param other - The other bounding box
5151
* @returns True if this bounding box touches any part of `other`.
5252
*/
@@ -62,7 +62,7 @@ export class Bounds implements ReadOnlyBounds {
6262

6363
/**
6464
* Expands this bounding box to include point.
65-
*
65+
*
6666
* @param point - The point to include in this bounding box
6767
* @returns This mutated bounding box
6868
*/
@@ -76,7 +76,7 @@ export class Bounds implements ReadOnlyBounds {
7676

7777
/**
7878
* Expands this bounding box by a fixed amount in each direction.
79-
*
79+
*
8080
* @param amount - The amount to expand the box by, or contract if negative
8181
* @returns This mutated bounding box
8282
*/
@@ -97,7 +97,7 @@ export class Bounds implements ReadOnlyBounds {
9797

9898
/**
9999
* Shrinks this bounding box by a fixed amount in each direction.
100-
*
100+
*
101101
* @param amount - The amount to shrink the box by
102102
* @returns This mutated bounding box
103103
*/
@@ -108,11 +108,11 @@ export class Bounds implements ReadOnlyBounds {
108108
/**
109109
* Returns a new bounding box that contains all of the corners of this bounding
110110
* box with a transform applied. Does not modify this bounding box.
111-
*
111+
*
112112
* @param fn - The function to apply to each corner
113113
* @returns A new bounding box containing all of the mapped points.
114114
*/
115-
map(fn: (point: Point2D) => Point2D) {
115+
map(fn: (point: Point) => Point2D): Bounds {
116116
const result = new Bounds();
117117
result.extend(fn(new Point(this.minX, this.minY)));
118118
result.extend(fn(new Point(this.maxX, this.minY)));
@@ -123,7 +123,7 @@ export class Bounds implements ReadOnlyBounds {
123123

124124
/**
125125
* Creates a new bounding box that includes all points provided.
126-
*
126+
*
127127
* @param points - The points to include inside the bounding box
128128
* @returns The new bounding box
129129
*/

src/geo/projection/globe_covering_tiles_details_provider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type {CoveringTilesDetailsProvider} from './covering_tiles_details_provid
99
import {OverscaledTileID} from '../../tile/tile_id';
1010
import {earthRadius} from '../lng_lat';
1111
import {ConvexVolume} from '../../util/primitives/convex_volume';
12+
import type {IBoundingVolume} from '../../util/primitives/bounding_volume';
1213
import {threePlaneIntersection} from '../../util/util';
1314

1415
/**
@@ -57,7 +58,7 @@ export class GlobeCoveringTilesDetailsProvider implements CoveringTilesDetailsPr
5758
* Handles distances on a sphere correctly: X is wrapped when crossing the antimeridian,
5859
* when crossing the poles Y is mirrored and X is shifted by half world size.
5960
*/
60-
distanceToTile2d(pointX: number, pointY: number, tileID: {x: number; y: number; z: number}, _bv: ConvexVolume): number {
61+
distanceToTile2d(pointX: number, pointY: number, tileID: {x: number; y: number; z: number}, _bv: IBoundingVolume): number {
6162
const scale = 1 << tileID.z;
6263
const tileMercatorSize = 1.0 / scale;
6364
const tileCornerX = tileID.x / scale; // In range 0..1

src/geo/projection/mercator_covering_tiles_details_provider.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {OverscaledTileID} from '../../tile/tile_id';
22
import {Aabb} from '../../util/primitives/aabb';
3+
import type {IBoundingVolume} from '../../util/primitives/bounding_volume';
34
import {clamp} from '../../util/util';
45
import {type MercatorCoordinate} from '../mercator_coordinate';
56
import {type IReadonlyTransform} from '../transform_interface';
@@ -8,7 +9,8 @@ import {type CoveringTilesDetailsProvider} from './covering_tiles_details_provid
89

910
export class MercatorCoveringTilesDetailsProvider implements CoveringTilesDetailsProvider {
1011

11-
distanceToTile2d(pointX: number, pointY: number, _tileID: {x: number; y: number; z: number}, aabb: Aabb): number {
12+
distanceToTile2d(pointX: number, pointY: number, _tileID: {x: number; y: number; z: number}, boundingVolume: IBoundingVolume): number {
13+
const aabb = boundingVolume as Aabb;
1214
const distanceX = aabb.distanceX([pointX, pointY]);
1315
const distanceY = aabb.distanceY([pointX, pointY]);
1416
return Math.hypot(distanceX, distanceY);

src/geo/transform_helper.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ export type TransformHelperCallbacks = {
6565

6666
export type TransformOptions = {
6767
/**
68-
* The minimum zoom level of the map.
68+
* The minimum zoom level of the map. Users cannot zoom out beyond this level. (0–24)
69+
* @defaultValue 0
6970
*/
7071
minZoom?: number;
7172
/**
72-
* The maximum zoom level of the map.
73+
* The maximum zoom level of the map. Users cannot zoom in beyond this level. (0–24)
74+
* @defaultValue 22
7375
*/
7476
maxZoom?: number;
7577
/**

0 commit comments

Comments
 (0)