Skip to content

Commit

Permalink
Add eslint rule named stylistic/semi (#5273)
Browse files Browse the repository at this point in the history
* Add eslint rule named `stylistic/semi`

* remove unnecessary eslintrc(json)
  • Loading branch information
kkokkojeong authored Dec 27, 2024
1 parent d32542a commit 58f3a82
Show file tree
Hide file tree
Showing 54 changed files with 121 additions and 128 deletions.
2 changes: 1 addition & 1 deletion build/generate-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type HtmlDoc = {
title: string;
description: string;
mdFileName: string;
}
};

function generateAPIIntroMarkdown(lines: string[]): string {
let intro = `# Intro
Expand Down
3 changes: 2 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import stylisticTs from '@stylistic/eslint-plugin-ts'
import stylisticTs from '@stylistic/eslint-plugin-ts';
import tsdoc from 'eslint-plugin-tsdoc';
import vitest from 'eslint-plugin-vitest';
import globals from 'globals';
Expand Down Expand Up @@ -96,6 +96,7 @@ export default [
'no-useless-escape': 'off',
indent: 'off',
'@stylistic/indent': ['error'],
'@stylistic/semi': ['error'],

'no-multiple-empty-lines': ['error', {
max: 1,
Expand Down
2 changes: 1 addition & 1 deletion src/data/bucket/fill_extrusion_bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type CentroidAccumulator = {
x: number;
y: number;
sampleCount: number;
}
};

export class FillExtrusionBucket implements Bucket {
index: number;
Expand Down
2 changes: 1 addition & 1 deletion src/data/dem_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {register} from '../util/web_worker_transfer';
/**
* The possible DEM encoding types
*/
export type DEMEncoding = 'mapbox' | 'terrarium' | 'custom'
export type DEMEncoding = 'mapbox' | 'terrarium' | 'custom';

/**
* DEMData is a data structure for decoding, backfilling, and storing elevation data for processing in the hillshade shaders
Expand Down
12 changes: 6 additions & 6 deletions src/geo/projection/camera_helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type MapControlsDeltas = {
pitchDelta: number;
rollDelta: number;
around: Point;
}
};

export type CameraForBoxAndBearingHandlerResult = {
center: LngLat;
Expand All @@ -35,13 +35,13 @@ export type EaseToHandlerOptions = {
center?: LngLatLike;
zoom?: number;
offset?: PointLike;
}
};

export type EaseToHandlerResult = {
easeFunc: (k: number) => void;
elevationCenter: LngLat;
isZooming: boolean;
}
};

export type FlyToHandlerOptions = {
bearing: number;
Expand All @@ -53,15 +53,15 @@ export type FlyToHandlerOptions = {
locationAtOffset: LngLat;
zoom?: number;
minZoom?: number;
}
};

export type FlyToHandlerResult = {
easeFunc: (k: number, scale: number, centerFactor: number, pointAtOffset: Point) => void;
scaleOfZoom: number;
scaleOfMinZoom?: number;
targetCenter: LngLat;
pixelPathLength: number;
}
};

export type UpdateRotationArgs = {
/**
Expand All @@ -88,7 +88,7 @@ export type UpdateRotationArgs = {
* If true, use spherical linear interpolation. If false, use linear interpolation of Euler angles.
*/
useSlerp: boolean;
}
};

/**
* @internal
Expand Down
4 changes: 2 additions & 2 deletions src/geo/projection/globe_projection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import {type Mesh} from '../../render/mesh';

type ProjectionProps = {
type: DataConstantProperty<ProjectionDefinition>;
}
};

type ProjectionPossiblyEvaluated = {
type: ProjectionDefinitionSpecification;
}
};

const properties: Properties<ProjectionProps> = new Properties({
'type': new DataConstantProperty(styleSpec.projection.type as StylePropertySpecification)
Expand Down
4 changes: 2 additions & 2 deletions src/geo/projection/globe_transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ export class GlobeTransform implements ITransform {
this._verticalPerspectiveTransform.apply(this, this._globeLatitudeErrorCorrectionRadians);
}

public get projectionMatrix(): mat4 { return this.currentTransform.projectionMatrix }
public get projectionMatrix(): mat4 { return this.currentTransform.projectionMatrix; }

public get modelViewProjectionMatrix(): mat4 { return this.currentTransform.modelViewProjectionMatrix }
public get modelViewProjectionMatrix(): mat4 { return this.currentTransform.modelViewProjectionMatrix; }

public get inverseProjectionMatrix(): mat4 { return this.currentTransform.inverseProjectionMatrix; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class MercatorCoveringTilesDetailsProvider implements CoveringTilesDetail
allowVariableZoom(transform: IReadonlyTransform, options: CoveringTilesOptions): boolean {
const zfov = transform.fov * (Math.abs(Math.cos(transform.rollInRadians)) * transform.height + Math.abs(Math.sin(transform.rollInRadians)) * transform.width) / transform.height;
const maxConstantZoomPitch = clamp(78.5 - zfov / 2, 0.0, 60.0);
return (!!options.terrain || transform.pitch > maxConstantZoomPitch || transform.padding.top >= 0.1)
return (!!options.terrain || transform.pitch > maxConstantZoomPitch || transform.padding.top >= 0.1);
}

allowWorldCopies(): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/geo/projection/mercator_transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ export class MercatorTransform implements ITransform {
const matrices = {
f64: tileMatrix,
f32: new Float32Array(tileMatrix), // Must have a 32 bit float version for WebGL, otherwise WebGL calls in Chrome get very slow.
}
};
cache.set(posMatrixKey, matrices);
// Make sure to return the correct precision
return useFloat32 ? matrices.f32 : matrices.f64;
Expand Down
4 changes: 2 additions & 2 deletions src/geo/projection/projection_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export type ProjectionData = {
* Uniform name: `u_projection_fallback_matrix`.
*/
fallbackMatrix: mat4;
}
};

/**
* Parameters object for the transform's `getProjectionData` function.
Expand All @@ -67,4 +67,4 @@ export type ProjectionDataParams = {
* Set to true if the globe matrix should be applied (i.e. when rendering globe)
*/
applyGlobeMatrix?: boolean;
}
};
2 changes: 1 addition & 1 deletion src/geo/projection/vertical_perspective_transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export class VerticalPerspectiveTransform implements ITransform {
clippingPlane: this._cachedClippingPlane as [number, number, number, number],
projectionTransition: applyGlobeMatrix ? 1 : 0,
fallbackMatrix: this._globeViewProjMatrix32f,
}
};
}

private _computeClippingPlane(globeRadiusPixels: number): vec4 {
Expand Down
2 changes: 1 addition & 1 deletion src/render/line_atlas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type DashEntry = {
y: number;
height: number;
width: number;
}
};

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion src/render/painter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type PainterOptions = {
export type RenderOptions = {
isRenderingToTexture: boolean;
isRenderingGlobe: boolean;
}
};

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion src/render/terrain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type TerrainData = {
texture: WebGLTexture;
depthTexture: WebGLTexture;
tile: Tile;
}
};

/**
* @internal
Expand Down
6 changes: 3 additions & 3 deletions src/source/geojson_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type GeoJSONSourceOptions = GeoJSONSourceSpecification & {
workerOptions?: GeoJSONWorkerOptions;
collectResourceTiming?: boolean;
data: GeoJSON.GeoJSON | string;
}
};

export type GeoJSONSourceInternalOptions = {
data?: GeoJSON.GeoJSON | string | undefined;
Expand All @@ -32,7 +32,7 @@ export type GeoJSONSourceInternalOptions = {
clusterRadius?: number;
clusterMinPoints?: number;
generateId?: boolean;
}
};

/**
* The cluster options to set
Expand All @@ -50,7 +50,7 @@ export type SetClusterOptions = {
* The cluster's radius
*/
clusterRadius?: number;
}
};

/**
* A source containing GeoJSON.
Expand Down
4 changes: 2 additions & 2 deletions src/source/geojson_source_diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type GeoJSONSourceDiff = {
* An array of update objects
*/
update?: Array<GeoJSONFeatureDiff>;
}
};

/**
* A geojson feature diff object
Expand All @@ -49,7 +49,7 @@ export type GeoJSONFeatureDiff = {
* The properties to add or update along side their values
*/
addOrUpdateProperties?: Array<{key: string; value: any}>;
}
};

export type UpdateableGeoJSON = GeoJSON.Feature | GeoJSON.FeatureCollection | undefined;

Expand Down
2 changes: 1 addition & 1 deletion src/source/geojson_worker_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type GeoJSONWorkerOptions = {
filter?: Array<unknown>;
promoteId?: string;
collectResourceTiming?: boolean;
}
};

/**
* Parameters needed to load a geojson to the worker
Expand Down
2 changes: 1 addition & 1 deletion src/source/image_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export type UpdateImageOptions = {
* The image coordinates
*/
coordinates?: Coordinates;
}
};

/**
* A data source containing an image.
Expand Down
2 changes: 1 addition & 1 deletion src/source/load_tilejson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type LoadTileJsonResponse = {
tileSize: number;
encoding: RasterDEMSourceSpecification['encoding'];
vectorLayerIds?: Array<string>;
}
};

export async function loadTileJson(
options: RasterSourceSpecification | RasterDEMSourceSpecification | VectorSourceSpecification,
Expand Down
4 changes: 2 additions & 2 deletions src/source/query_features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type QueryRenderedFeaturesOptions = {

export type QueryRenderedFeaturesOptionsStrict = Omit<QueryRenderedFeaturesOptions, 'layers'> & {
layers: Set<string> | null;
}
};

/**
* The options object related to the {@link Map#querySourceFeatures} method
Expand All @@ -53,7 +53,7 @@ export type QuerySourceFeatureOptions = {
* @defaultValue true
*/
validate?: boolean;
}
};

/*
* Returns a matrix that can be used to convert from tile coordinates to viewport pixel coordinates.
Expand Down
2 changes: 1 addition & 1 deletion src/source/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export interface Source {
*/
export type SourceClass = {
new (id: string, specification: SourceSpecification | CanvasSourceSpecification, dispatcher: Dispatcher, eventedParent: Evented): Source;
}
};

/**
* Creates a tiled data source instance given an options object.
Expand Down
2 changes: 1 addition & 1 deletion src/source/source_cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type TileResult = {
queryGeometry: Array<Point>;
cameraQueryGeometry: Array<Point>;
scale: number;
}
};

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion src/source/vector_tile_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {MessageType} from '../util/actor_messages';
export type VectorTileSourceOptions = VectorSourceSpecification & {
collectResourceTiming?: boolean;
tileSize?: number;
}
};

/**
* A source containing vector tiles in [Mapbox Vector Tile format](https://docs.mapbox.com/vector-tiles/reference/).
Expand Down
2 changes: 1 addition & 1 deletion src/source/vector_tile_worker_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type FetchingState = {
rawTileData: ArrayBuffer;
cacheControl: ExpiryData;
resourceTiming: any;
}
};

export type AbortVectorData = () => void;
export type LoadVectorData = (params: WorkerTileParameters, abortController: AbortController) => Promise<LoadVectorTileResult | null>;
Expand Down
4 changes: 2 additions & 2 deletions src/style/load_sprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type LoadSpriteResult = {
[spriteName: string]: {
[id: string]: StyleImage;
};
}
};

export function normalizeSpriteURL(url: string, format: string, extension: string): string {
try {
Expand All @@ -22,7 +22,7 @@ export function normalizeSpriteURL(url: string, format: string, extension: strin
return parsed.toString();
}
catch {
throw new Error(`Invalid sprite URL "${url}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)
throw new Error(`Invalid sprite URL "${url}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/style/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export type StyleSwapOptions = {
* that allows to modify a style after it is fetched but before it is committed to the map state. Refer to {@link TransformStyleFunction}.
*/
transformStyle?: TransformStyleFunction;
}
};

/**
* Specifies a layer to be added to a {@link Style}. In addition to a standard {@link LayerSpecification}
Expand Down
2 changes: 1 addition & 1 deletion src/style/style_image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type SpriteJSON = {[id: string]: StyleImageMetadata & {
height: number;
x: number;
y: number;
};}
};};

/**
* The sprite data
Expand Down
2 changes: 1 addition & 1 deletion src/style/style_layer/custom_style_layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export type CustomRenderMethodInput = {
* or more accurately for globe, elevation above the surface of the perfect sphere used to render the planet.
*/
defaultProjectionData: ProjectionData;
}
};

/**
* @param gl - The map's gl context.
Expand Down
2 changes: 1 addition & 1 deletion src/symbol/grid_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type QueryResult<T> = {
*/
export type GridKey = {
overlapMode?: OverlapMode;
}
};

function overlapAllowed(overlapA: OverlapMode, overlapB: OverlapMode): boolean {
let allowed = true;
Expand Down
4 changes: 2 additions & 2 deletions src/symbol/projection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ function requiresOrientationChange(writingMode, firstPoint, lastPoint, aspectRat

type GlyphLinePlacementResult = OrientationChangeType & {
notEnoughRoom?: boolean;
}
};

type GlyphLinePlacementArgs = {
projectionContext: SymbolProjectionContext;
Expand All @@ -412,7 +412,7 @@ type GlyphLinePlacementArgs = {
dynamicLayoutVertexArray: StructArray;
aspectRatio: number;
rotateToLine: boolean;
}
};

/*
* Place first and last glyph along the line projected to label plane, and if they fit
Expand Down
Loading

0 comments on commit 58f3a82

Please sign in to comment.