diff --git a/.eslintrc b/.eslintrc index efa361ace23..863b8d6ab5d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -51,7 +51,7 @@ }], "no-unused-vars": ["error", {"argsIgnorePattern": "^_$"}], "no-warning-comments": "error", - "object-curly-spacing": "off", + "object-curly-spacing": ["error", "never"], "prefer-arrow-callback": "error", "prefer-const": ["error", {"destructuring": "all"}], "prefer-template": "error", diff --git a/bench/benchmarks/expressions.js b/bench/benchmarks/expressions.js index 8f2a780de79..d81c5aa85f4 100644 --- a/bench/benchmarks/expressions.js +++ b/bench/benchmarks/expressions.js @@ -4,8 +4,8 @@ import Benchmark from '../lib/benchmark'; import spec from '../../src/style-spec/reference/latest'; import convertFunction from '../../src/style-spec/function/convert'; -import { isFunction, createFunction } from '../../src/style-spec/function'; -import { createPropertyExpression } from '../../src/style-spec/expression'; +import {isFunction, createFunction} from '../../src/style-spec/function'; +import {createPropertyExpression} from '../../src/style-spec/expression'; import fetchStyle from '../lib/fetch_style'; import type {StyleSpecification} from '../../src/style-spec/types'; diff --git a/bench/benchmarks/filter_evaluate.js b/bench/benchmarks/filter_evaluate.js index 041470c0fa7..40ca85af21b 100644 --- a/bench/benchmarks/filter_evaluate.js +++ b/bench/benchmarks/filter_evaluate.js @@ -1,6 +1,6 @@ import Benchmark from '../lib/benchmark'; -import { VectorTile } from '@mapbox/vector-tile'; +import {VectorTile} from '@mapbox/vector-tile'; import Pbf from 'pbf'; import createFilter from '../../src/style-spec/feature_filter'; import filters from '../data/filters.json'; @@ -30,7 +30,7 @@ export default class FilterEvaluate extends Benchmark { } } - this.layers.push({ features, filters: layerFilters }); + this.layers.push({features, filters: layerFilters}); } }); } diff --git a/bench/benchmarks/layout.js b/bench/benchmarks/layout.js index debd61d8663..fc363ff71f5 100644 --- a/bench/benchmarks/layout.js +++ b/bench/benchmarks/layout.js @@ -4,7 +4,7 @@ import type {StyleSpecification} from '../../src/style-spec/types'; import Benchmark from '../lib/benchmark'; import fetchStyle from '../lib/fetch_style'; import TileParser from '../lib/tile_parser'; -import { OverscaledTileID } from '../../src/source/tile_id'; +import {OverscaledTileID} from '../../src/source/tile_id'; export default class Layout extends Benchmark { tiles: Array<{tileID: OverscaledTileID, buffer: ArrayBuffer}>; diff --git a/bench/benchmarks/layout_dds.js b/bench/benchmarks/layout_dds.js index 27979d4e36f..f4dffbd5821 100644 --- a/bench/benchmarks/layout_dds.js +++ b/bench/benchmarks/layout_dds.js @@ -2,7 +2,7 @@ import Benchmark from '../lib/benchmark'; import TileParser from '../lib/tile_parser'; -import { OverscaledTileID } from '../../src/source/tile_id'; +import {OverscaledTileID} from '../../src/source/tile_id'; const LAYER_COUNT = 2; @@ -18,7 +18,7 @@ export default class LayoutDDS extends Benchmark { const styleJSON = { "version": 8, "sources": { - "mapbox": { "type": "vector", "url": "mapbox://mapbox.mapbox-streets-v7" } + "mapbox": {"type": "vector", "url": "mapbox://mapbox.mapbox-streets-v7"} }, "layers": [] }; diff --git a/bench/benchmarks/paint_states.js b/bench/benchmarks/paint_states.js index c377412812a..0a0a136011e 100644 --- a/bench/benchmarks/paint_states.js +++ b/bench/benchmarks/paint_states.js @@ -62,7 +62,7 @@ export default class PaintStates extends Benchmark { this.map._sourcesDirty = true; this.map._render(); for (let i = 0; i < this.numFeatures; i += 50) { - this.map.setFeatureState({ source: 'land', id: i }, { bench: true }); + this.map.setFeatureState({source: 'land', id: i}, {bench: true}); } this.map._render(); } diff --git a/bench/benchmarks/remove_paint_state.js b/bench/benchmarks/remove_paint_state.js index 191bf243f6c..8fe38cd6eb0 100644 --- a/bench/benchmarks/remove_paint_state.js +++ b/bench/benchmarks/remove_paint_state.js @@ -72,10 +72,10 @@ export class PropertyLevelRemove extends RemovePaintState { bench() { for (let i = 0; i < this.numFeatures; i += 50) { - this.map.setFeatureState({ source: 'land', id: i }, { bench: true }); + this.map.setFeatureState({source: 'land', id: i}, {bench: true}); } for (let i = 0; i < this.numFeatures; i += 50) { - this.map.removeFeatureState({ source: 'land', id: i }, 'bench'); + this.map.removeFeatureState({source: 'land', id: i}, 'bench'); } this.map._render(); @@ -86,10 +86,10 @@ export class FeatureLevelRemove extends RemovePaintState { bench() { for (let i = 0; i < this.numFeatures; i += 50) { - this.map.setFeatureState({ source: 'land', id: i }, { bench: true }); + this.map.setFeatureState({source: 'land', id: i}, {bench: true}); } for (let i = 0; i < this.numFeatures; i += 50) { - this.map.removeFeatureState({ source: 'land', id: i }); + this.map.removeFeatureState({source: 'land', id: i}); } this.map._render(); @@ -100,10 +100,10 @@ export class SourceLevelRemove extends RemovePaintState { bench() { for (let i = 0; i < this.numFeatures; i += 50) { - this.map.setFeatureState({ source: 'land', id: i }, { bench: true }); + this.map.setFeatureState({source: 'land', id: i}, {bench: true}); } for (let i = 0; i < this.numFeatures; i += 50) { - this.map.removeFeatureState({ source: 'land', id: i }); + this.map.removeFeatureState({source: 'land', id: i}); } this.map._render(); diff --git a/bench/benchmarks/symbol_layout.js b/bench/benchmarks/symbol_layout.js index cf40af6a641..98f26854313 100644 --- a/bench/benchmarks/symbol_layout.js +++ b/bench/benchmarks/symbol_layout.js @@ -2,8 +2,8 @@ import Layout from './layout'; import SymbolBucket from '../../src/data/bucket/symbol_bucket'; -import { performSymbolLayout } from '../../src/symbol/symbol_layout'; -import { OverscaledTileID } from '../../src/source/tile_id'; +import {performSymbolLayout} from '../../src/symbol/symbol_layout'; +import {OverscaledTileID} from '../../src/source/tile_id'; export default class SymbolLayout extends Layout { parsedTiles: Array; diff --git a/bench/benchmarks/worker_transfer.js b/bench/benchmarks/worker_transfer.js index e1245ca6808..2c5c37872d1 100644 --- a/bench/benchmarks/worker_transfer.js +++ b/bench/benchmarks/worker_transfer.js @@ -4,9 +4,9 @@ import type {StyleSpecification} from '../../src/style-spec/types'; import Benchmark from '../lib/benchmark'; import fetchStyle from '../lib/fetch_style'; import TileParser from '../lib/tile_parser'; -import { OverscaledTileID } from '../../src/source/tile_id'; -import { serialize, deserialize } from '../../src/util/web_worker_transfer'; -import { values } from '../../src/util/util'; +import {OverscaledTileID} from '../../src/source/tile_id'; +import {serialize, deserialize} from '../../src/util/web_worker_transfer'; +import {values} from '../../src/util/util'; export default class WorkerTransfer extends Benchmark { parser: TileParser; diff --git a/bench/benchmarks_view.js b/bench/benchmarks_view.js index b6ce6a080c8..4644a14df22 100644 --- a/bench/benchmarks_view.js +++ b/bench/benchmarks_view.js @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import * as d3 from 'd3'; -import { kde, probabilitiesOfSuperiority, summaryStatistics, regression } from './lib/statistics'; +import {kde, probabilitiesOfSuperiority, summaryStatistics, regression} from './lib/statistics'; const versionColor = d3.scaleOrdinal(['#1b9e77', '#7570b3', '#d95f02']); const formatSample = d3.format(".3r"); @@ -224,12 +224,12 @@ class StatisticsPlot extends React.Component { strokeWidth={bandwidth} strokeOpacity={1} /> = tMax ? 'translate(-10, 0)' : `translate(-5, ${t(mean)}) rotate(90)`} x={0} y={0} /> @@ -275,7 +275,7 @@ class StatisticsPlot extends React.Component { } componentDidMount() { - this.setState({ width: this.ref.clientWidth }); + this.setState({width: this.ref.clientWidth}); } } @@ -342,7 +342,7 @@ class RegressionPlot extends React.Component { } componentDidMount() { - this.setState({ width: this.ref.clientWidth }); + this.setState({width: this.ref.clientWidth}); } } diff --git a/bench/lib/fetch_style.js b/bench/lib/fetch_style.js index 316cfd84588..e7c1ff4cb54 100644 --- a/bench/lib/fetch_style.js +++ b/bench/lib/fetch_style.js @@ -1,7 +1,7 @@ // @flow import type {StyleSpecification} from '../../src/style-spec/types'; -import { RequestManager } from '../../src/util/mapbox'; +import {RequestManager} from '../../src/util/mapbox'; const requestManager = new RequestManager(); diff --git a/bench/lib/locations_with_tile_id.js b/bench/lib/locations_with_tile_id.js index b0788e2e0ef..b6086c2466c 100644 --- a/bench/lib/locations_with_tile_id.js +++ b/bench/lib/locations_with_tile_id.js @@ -1,11 +1,11 @@ import MercatorCoordinate from '../../src/geo/mercator_coordinate'; -import { OverscaledTileID } from '../../src/source/tile_id'; +import {OverscaledTileID} from '../../src/source/tile_id'; export default function locationsWithTileID(locations) { return locations.map(feature => { - const { coordinates } = feature.geometry; - const { zoom } = feature.properties; - const { x, y } = MercatorCoordinate.fromLngLat({ + const {coordinates} = feature.geometry; + const {zoom} = feature.properties; + const {x, y} = MercatorCoordinate.fromLngLat({ lng: coordinates[0], lat: coordinates[1] }); diff --git a/bench/lib/statistics.js b/bench/lib/statistics.js index f2efdb29ffb..77b45d5ef7d 100644 --- a/bench/lib/statistics.js +++ b/bench/lib/statistics.js @@ -87,7 +87,7 @@ function leastSquaresRegression(data) { const slope = covariance / varianceX; const intercept = meanY - slope * meanX; - return { correlation, slope, intercept, data }; + return {correlation, slope, intercept, data}; } export function kde(samples, summary, ticks) { diff --git a/bench/lib/tile_parser.js b/bench/lib/tile_parser.js index 3be9eb95b16..a30fbbb27d2 100644 --- a/bench/lib/tile_parser.js +++ b/bench/lib/tile_parser.js @@ -6,15 +6,15 @@ import assert from 'assert'; import deref from '../../src/style-spec/deref'; import Style from '../../src/style/style'; -import { Evented } from '../../src/util/evented'; -import { RequestManager } from '../../src/util/mapbox'; +import {Evented} from '../../src/util/evented'; +import {RequestManager} from '../../src/util/mapbox'; import WorkerTile from '../../src/source/worker_tile'; import StyleLayerIndex from '../../src/style/style_layer_index'; -import type { StyleSpecification } from '../../src/style-spec/types'; -import type { WorkerTileResult } from '../../src/source/worker_source'; -import type { OverscaledTileID } from '../../src/source/tile_id'; -import type { TileJSON } from '../../src/types/tilejson'; +import type {StyleSpecification} from '../../src/style-spec/types'; +import type {WorkerTileResult} from '../../src/source/worker_source'; +import type {OverscaledTileID} from '../../src/source/tile_id'; +import type {TileJSON} from '../../src/types/tilejson'; class StubMap extends Evented { _requestManager: RequestManager; diff --git a/debug/7438.html b/debug/7438.html index 2faa4c86f88..70d4380c9fc 100644 --- a/debug/7438.html +++ b/debug/7438.html @@ -27,7 +27,7 @@ hash: true }); -map.addControl(new mapboxgl.ScaleControl({ unit: 'nautical' })); +map.addControl(new mapboxgl.ScaleControl({unit: 'nautical'})); diff --git a/debug/extrusion-query.html b/debug/extrusion-query.html index 442c74fbb3c..b99a589a220 100644 --- a/debug/extrusion-query.html +++ b/debug/extrusion-query.html @@ -52,7 +52,7 @@ window.addEventListener('mousemove', function(e) { e.point = new mapboxgl.Point(e.clientX, e.clientY); console.time('query'); - const features = map.queryRenderedFeatures(e.point, { layers: ['3d-buildings'] }); + const features = map.queryRenderedFeatures(e.point, {layers: ['3d-buildings']}); console.timeEnd('query'); for (const feature of hovered) { diff --git a/debug/multiple.html b/debug/multiple.html index 98fd63992f1..ad340bd7c23 100644 --- a/debug/multiple.html +++ b/debug/multiple.html @@ -49,7 +49,7 @@ "type": "line", "source": "streets", "source-layer": "road", - "paint": { "line-color": "rgb(55,89,144)", "line-width": 4 } + "paint": {"line-color": "rgb(55,89,144)", "line-width": 4} }] }; diff --git a/debug/query_features.html b/debug/query_features.html index 6fbd5ca9998..481cfa28b1f 100644 --- a/debug/query_features.html +++ b/debug/query_features.html @@ -28,10 +28,10 @@ map.addControl(new mapboxgl.NavigationControl()); -var emptyFc = { type: 'FeatureCollection', features: [] }; +var emptyFc = {type: 'FeatureCollection', features: []}; map.on('style.load', function() { - map.addSource('queried', { type: 'geojson', data: emptyFc }); + map.addSource('queried', {type: 'geojson', data: emptyFc}); map.addLayer({ "id": "query", "type": "line", @@ -42,7 +42,7 @@ } }, 'country-label-sm'); - map.addSource('boxsource', { type: 'geojson', data: emptyFc }); + map.addSource('boxsource', {type: 'geojson', data: emptyFc}); map.addLayer({ "id": "box", "type": "fill", diff --git a/debug/textsize.html b/debug/textsize.html index cfec9fc1215..5af38a53cdc 100644 --- a/debug/textsize.html +++ b/debug/textsize.html @@ -76,7 +76,7 @@ "features": [ { "type": "Feature", - "properties": { "x": 0 }, + "properties": {"x": 0}, "geometry": { "type": "LineString", "coordinates": [ diff --git a/debug/threejs.html b/debug/threejs.html index cab28a8b1ee..c9c4e550938 100644 --- a/debug/threejs.html +++ b/debug/threejs.html @@ -45,7 +45,7 @@ this.scene = new THREE.Scene(); var geometry = new THREE.BoxGeometry(1, 1, 1); - var material = new THREE.MeshPhongMaterial({ color: 0xeeeeff }); + var material = new THREE.MeshPhongMaterial({color: 0xeeeeff}); this.cube = new THREE.Mesh(geometry, material); this.scene.add(this.cube); diff --git a/debug/update_image.html b/debug/update_image.html index 3523c42fef7..415b078062f 100644 --- a/debug/update_image.html +++ b/debug/update_image.html @@ -59,7 +59,7 @@ setInterval(() => { currentImage = (currentImage + 1) % frameCount; - map.getSource("radar").updateImage({ url: getPath() }); + map.getSource("radar").updateImage({url: getPath()}); }, 200); }); diff --git a/src/data/bucket/circle_attributes.js b/src/data/bucket/circle_attributes.js index 224721709b5..e2334a28e50 100644 --- a/src/data/bucket/circle_attributes.js +++ b/src/data/bucket/circle_attributes.js @@ -1,5 +1,5 @@ // @flow -import { createLayout } from '../../util/struct_array'; +import {createLayout} from '../../util/struct_array'; const layout = createLayout([ {name: 'a_pos', components: 2, type: 'Int16'} diff --git a/src/data/bucket/circle_bucket.js b/src/data/bucket/circle_bucket.js index e7d9fff3d0e..2ee8ade034b 100644 --- a/src/data/bucket/circle_bucket.js +++ b/src/data/bucket/circle_bucket.js @@ -1,14 +1,14 @@ // @flow -import { CircleLayoutArray } from '../array_types'; +import {CircleLayoutArray} from '../array_types'; -import { members as layoutAttributes } from './circle_attributes'; +import {members as layoutAttributes} from './circle_attributes'; import SegmentVector from '../segment'; -import { ProgramConfigurationSet } from '../program_configuration'; -import { TriangleIndexArray } from '../index_array_type'; +import {ProgramConfigurationSet} from '../program_configuration'; +import {TriangleIndexArray} from '../index_array_type'; import loadGeometry from '../load_geometry'; import EXTENT from '../extent'; -import { register } from '../../util/web_worker_transfer'; +import {register} from '../../util/web_worker_transfer'; import EvaluationParameters from '../../style/evaluation_parameters'; import type { diff --git a/src/data/bucket/fill_attributes.js b/src/data/bucket/fill_attributes.js index 224721709b5..e2334a28e50 100644 --- a/src/data/bucket/fill_attributes.js +++ b/src/data/bucket/fill_attributes.js @@ -1,5 +1,5 @@ // @flow -import { createLayout } from '../../util/struct_array'; +import {createLayout} from '../../util/struct_array'; const layout = createLayout([ {name: 'a_pos', components: 2, type: 'Int16'} diff --git a/src/data/bucket/fill_bucket.js b/src/data/bucket/fill_bucket.js index 35a6486ff8b..f2fa38fa149 100644 --- a/src/data/bucket/fill_bucket.js +++ b/src/data/bucket/fill_bucket.js @@ -1,16 +1,16 @@ // @flow -import { FillLayoutArray } from '../array_types'; +import {FillLayoutArray} from '../array_types'; -import { members as layoutAttributes } from './fill_attributes'; +import {members as layoutAttributes} from './fill_attributes'; import SegmentVector from '../segment'; -import { ProgramConfigurationSet } from '../program_configuration'; -import { LineIndexArray, TriangleIndexArray } from '../index_array_type'; +import {ProgramConfigurationSet} from '../program_configuration'; +import {LineIndexArray, TriangleIndexArray} from '../index_array_type'; import earcut from 'earcut'; import classifyRings from '../../util/classify_rings'; import assert from 'assert'; const EARCUT_MAX_RINGS = 500; -import { register } from '../../util/web_worker_transfer'; +import {register} from '../../util/web_worker_transfer'; import {hasPattern, addPatternDependencies} from './pattern_bucket_features'; import loadGeometry from '../load_geometry'; import EvaluationParameters from '../../style/evaluation_parameters'; diff --git a/src/data/bucket/fill_extrusion_attributes.js b/src/data/bucket/fill_extrusion_attributes.js index 52f3cdc264e..f8c6d70afd0 100644 --- a/src/data/bucket/fill_extrusion_attributes.js +++ b/src/data/bucket/fill_extrusion_attributes.js @@ -1,5 +1,5 @@ // @flow -import { createLayout } from '../../util/struct_array'; +import {createLayout} from '../../util/struct_array'; const layout = createLayout([ {name: 'a_pos', components: 2, type: 'Int16'}, diff --git a/src/data/bucket/fill_extrusion_bucket.js b/src/data/bucket/fill_extrusion_bucket.js index 7ba9e27c03a..4f8632dc384 100644 --- a/src/data/bucket/fill_extrusion_bucket.js +++ b/src/data/bucket/fill_extrusion_bucket.js @@ -1,11 +1,11 @@ // @flow -import { FillExtrusionLayoutArray } from '../array_types'; +import {FillExtrusionLayoutArray} from '../array_types'; -import { members as layoutAttributes } from './fill_extrusion_attributes'; +import {members as layoutAttributes} from './fill_extrusion_attributes'; import SegmentVector from '../segment'; -import { ProgramConfigurationSet } from '../program_configuration'; -import { TriangleIndexArray } from '../index_array_type'; +import {ProgramConfigurationSet} from '../program_configuration'; +import {TriangleIndexArray} from '../index_array_type'; import EXTENT from '../extent'; import earcut from 'earcut'; import mvt from '@mapbox/vector-tile'; @@ -13,7 +13,7 @@ const vectorTileFeatureTypes = mvt.VectorTileFeature.types; import classifyRings from '../../util/classify_rings'; import assert from 'assert'; const EARCUT_MAX_RINGS = 500; -import { register } from '../../util/web_worker_transfer'; +import {register} from '../../util/web_worker_transfer'; import {hasPattern, addPatternDependencies} from './pattern_bucket_features'; import loadGeometry from '../load_geometry'; import EvaluationParameters from '../../style/evaluation_parameters'; diff --git a/src/data/bucket/heatmap_bucket.js b/src/data/bucket/heatmap_bucket.js index 2c77b85635e..2ac11756e7d 100644 --- a/src/data/bucket/heatmap_bucket.js +++ b/src/data/bucket/heatmap_bucket.js @@ -2,7 +2,7 @@ import CircleBucket from './circle_bucket'; -import { register } from '../../util/web_worker_transfer'; +import {register} from '../../util/web_worker_transfer'; import type HeatmapStyleLayer from '../../style/style_layer/heatmap_style_layer'; diff --git a/src/data/bucket/line_attributes.js b/src/data/bucket/line_attributes.js index 55eed22e95a..51678b408e1 100644 --- a/src/data/bucket/line_attributes.js +++ b/src/data/bucket/line_attributes.js @@ -1,5 +1,5 @@ // @flow -import { createLayout } from '../../util/struct_array'; +import {createLayout} from '../../util/struct_array'; const lineLayoutAttributes = createLayout([ {name: 'a_pos_normal', components: 2, type: 'Int16'}, diff --git a/src/data/bucket/line_bucket.js b/src/data/bucket/line_bucket.js index 83f4ab846c8..4e1f31c65d7 100644 --- a/src/data/bucket/line_bucket.js +++ b/src/data/bucket/line_bucket.js @@ -1,15 +1,15 @@ // @flow -import { LineLayoutArray } from '../array_types'; +import {LineLayoutArray} from '../array_types'; -import { members as layoutAttributes } from './line_attributes'; +import {members as layoutAttributes} from './line_attributes'; import SegmentVector from '../segment'; -import { ProgramConfigurationSet } from '../program_configuration'; -import { TriangleIndexArray } from '../index_array_type'; +import {ProgramConfigurationSet} from '../program_configuration'; +import {TriangleIndexArray} from '../index_array_type'; import EXTENT from '../extent'; import mvt from '@mapbox/vector-tile'; const vectorTileFeatureTypes = mvt.VectorTileFeature.types; -import { register } from '../../util/web_worker_transfer'; +import {register} from '../../util/web_worker_transfer'; import {hasPattern, addPatternDependencies} from './pattern_bucket_features'; import loadGeometry from '../load_geometry'; import EvaluationParameters from '../../style/evaluation_parameters'; diff --git a/src/data/bucket/pattern_attributes.js b/src/data/bucket/pattern_attributes.js index 584d8a4c875..a46d42cc057 100644 --- a/src/data/bucket/pattern_attributes.js +++ b/src/data/bucket/pattern_attributes.js @@ -1,5 +1,5 @@ // @flow -import { createLayout } from '../../util/struct_array'; +import {createLayout} from '../../util/struct_array'; export default createLayout([ // [tl.x, tl.y, br.x, br.y] diff --git a/src/data/bucket/pattern_bucket_features.js b/src/data/bucket/pattern_bucket_features.js index 900cffaf88c..ada1a7aeec5 100644 --- a/src/data/bucket/pattern_bucket_features.js +++ b/src/data/bucket/pattern_bucket_features.js @@ -50,7 +50,7 @@ export function addPatternDependencies(type: string, layers: PatternStyleLayers, patterns[max] = true; // save for layout - patternFeature.patterns[layer.id] = { min, mid, max }; + patternFeature.patterns[layer.id] = {min, mid, max}; } } return patternFeature; diff --git a/src/data/bucket/symbol_attributes.js b/src/data/bucket/symbol_attributes.js index 0700270077f..d93a011e0a0 100644 --- a/src/data/bucket/symbol_attributes.js +++ b/src/data/bucket/symbol_attributes.js @@ -1,6 +1,6 @@ // @flow -import { createLayout } from '../../util/struct_array'; +import {createLayout} from '../../util/struct_array'; export const symbolLayoutAttributes = createLayout([ {name: 'a_pos_offset', components: 4, type: 'Int16'}, @@ -8,41 +8,41 @@ export const symbolLayoutAttributes = createLayout([ ]); export const dynamicLayoutAttributes = createLayout([ - { name: 'a_projected_pos', components: 3, type: 'Float32' } + {name: 'a_projected_pos', components: 3, type: 'Float32'} ], 4); export const placementOpacityAttributes = createLayout([ - { name: 'a_fade_opacity', components: 1, type: 'Uint32' } + {name: 'a_fade_opacity', components: 1, type: 'Uint32'} ], 4); export const collisionVertexAttributes = createLayout([ - { name: 'a_placed', components: 2, type: 'Uint8' }, - { name: 'a_shift', components: 2, type: 'Float32'} + {name: 'a_placed', components: 2, type: 'Uint8'}, + {name: 'a_shift', components: 2, type: 'Float32'} ]); export const collisionBox = createLayout([ // the box is centered around the anchor point - { type: 'Int16', name: 'anchorPointX' }, - { type: 'Int16', name: 'anchorPointY' }, + {type: 'Int16', name: 'anchorPointX'}, + {type: 'Int16', name: 'anchorPointY'}, // distances to the edges from the anchor - { type: 'Int16', name: 'x1' }, - { type: 'Int16', name: 'y1' }, - { type: 'Int16', name: 'x2' }, - { type: 'Int16', name: 'y2' }, + {type: 'Int16', name: 'x1'}, + {type: 'Int16', name: 'y1'}, + {type: 'Int16', name: 'x2'}, + {type: 'Int16', name: 'y2'}, // the index of the feature in the original vectortile - { type: 'Uint32', name: 'featureIndex' }, + {type: 'Uint32', name: 'featureIndex'}, // the source layer the feature appears in - { type: 'Uint16', name: 'sourceLayerIndex' }, + {type: 'Uint16', name: 'sourceLayerIndex'}, // the bucket the feature appears in - { type: 'Uint16', name: 'bucketIndex' }, + {type: 'Uint16', name: 'bucketIndex'}, // collision circles for lines store their distance to the anchor in tile units // so that they can be ignored if the projected label doesn't extend into // the box area - { type: 'Int16', name: 'radius' }, - { type: 'Int16', name: 'signedDistanceFromAnchor' } + {type: 'Int16', name: 'radius'}, + {type: 'Int16', name: 'signedDistanceFromAnchor'} ]); export const collisionBoxLayout = createLayout([ // used to render collision boxes for debugging purposes @@ -58,53 +58,53 @@ export const collisionCircleLayout = createLayout([ // used to render collision ], 4); export const placement = createLayout([ - { type: 'Int16', name: 'anchorX' }, - { type: 'Int16', name: 'anchorY' }, - { type: 'Uint16', name: 'glyphStartIndex' }, - { type: 'Uint16', name: 'numGlyphs' }, - { type: 'Uint32', name: 'vertexStartIndex' }, - { type: 'Uint32', name: 'lineStartIndex' }, - { type: 'Uint32', name: 'lineLength' }, - { type: 'Uint16', name: 'segment' }, - { type: 'Uint16', name: 'lowerSize' }, - { type: 'Uint16', name: 'upperSize' }, - { type: 'Float32', name: 'lineOffsetX' }, - { type: 'Float32', name: 'lineOffsetY' }, - { type: 'Uint8', name: 'writingMode' }, - { type: 'Uint8', name: 'placedOrientation' }, - { type: 'Uint8', name: 'hidden' }, - { type: 'Uint32', name: 'crossTileID'} + {type: 'Int16', name: 'anchorX'}, + {type: 'Int16', name: 'anchorY'}, + {type: 'Uint16', name: 'glyphStartIndex'}, + {type: 'Uint16', name: 'numGlyphs'}, + {type: 'Uint32', name: 'vertexStartIndex'}, + {type: 'Uint32', name: 'lineStartIndex'}, + {type: 'Uint32', name: 'lineLength'}, + {type: 'Uint16', name: 'segment'}, + {type: 'Uint16', name: 'lowerSize'}, + {type: 'Uint16', name: 'upperSize'}, + {type: 'Float32', name: 'lineOffsetX'}, + {type: 'Float32', name: 'lineOffsetY'}, + {type: 'Uint8', name: 'writingMode'}, + {type: 'Uint8', name: 'placedOrientation'}, + {type: 'Uint8', name: 'hidden'}, + {type: 'Uint32', name: 'crossTileID'} ]); export const symbolInstance = createLayout([ - { type: 'Int16', name: 'anchorX' }, - { type: 'Int16', name: 'anchorY' }, - { type: 'Int16', name: 'rightJustifiedTextSymbolIndex' }, - { type: 'Int16', name: 'centerJustifiedTextSymbolIndex' }, - { type: 'Int16', name: 'leftJustifiedTextSymbolIndex' }, - { type: 'Int16', name: 'verticalPlacedTextSymbolIndex' }, - { type: 'Uint16', name: 'key' }, - { type: 'Uint16', name: 'textBoxStartIndex' }, - { type: 'Uint16', name: 'textBoxEndIndex' }, - { type: 'Uint16', name: 'verticalTextBoxStartIndex' }, - { type: 'Uint16', name: 'verticalTextBoxEndIndex' }, - { type: 'Uint16', name: 'iconBoxStartIndex' }, - { type: 'Uint16', name: 'iconBoxEndIndex' }, - { type: 'Uint16', name: 'featureIndex' }, - { type: 'Uint16', name: 'numHorizontalGlyphVertices' }, - { type: 'Uint16', name: 'numVerticalGlyphVertices' }, - { type: 'Uint16', name: 'numIconVertices' }, - { type: 'Uint32', name: 'crossTileID' }, - { type: 'Float32', name: 'textBoxScale'}, - { type: 'Float32', name: 'radialTextOffset'} + {type: 'Int16', name: 'anchorX'}, + {type: 'Int16', name: 'anchorY'}, + {type: 'Int16', name: 'rightJustifiedTextSymbolIndex'}, + {type: 'Int16', name: 'centerJustifiedTextSymbolIndex'}, + {type: 'Int16', name: 'leftJustifiedTextSymbolIndex'}, + {type: 'Int16', name: 'verticalPlacedTextSymbolIndex'}, + {type: 'Uint16', name: 'key'}, + {type: 'Uint16', name: 'textBoxStartIndex'}, + {type: 'Uint16', name: 'textBoxEndIndex'}, + {type: 'Uint16', name: 'verticalTextBoxStartIndex'}, + {type: 'Uint16', name: 'verticalTextBoxEndIndex'}, + {type: 'Uint16', name: 'iconBoxStartIndex'}, + {type: 'Uint16', name: 'iconBoxEndIndex'}, + {type: 'Uint16', name: 'featureIndex'}, + {type: 'Uint16', name: 'numHorizontalGlyphVertices'}, + {type: 'Uint16', name: 'numVerticalGlyphVertices'}, + {type: 'Uint16', name: 'numIconVertices'}, + {type: 'Uint32', name: 'crossTileID'}, + {type: 'Float32', name: 'textBoxScale'}, + {type: 'Float32', name: 'radialTextOffset'} ]); export const glyphOffset = createLayout([ - { type: 'Float32', name: 'offsetX' } + {type: 'Float32', name: 'offsetX'} ]); export const lineVertex = createLayout([ - { type: 'Int16', name: 'x' }, - { type: 'Int16', name: 'y' }, - { type: 'Int16', name: 'tileUnitDistanceFromAnchor' } + {type: 'Int16', name: 'x'}, + {type: 'Int16', name: 'y'}, + {type: 'Int16', name: 'tileUnitDistanceFromAnchor'} ]); diff --git a/src/data/bucket/symbol_bucket.js b/src/data/bucket/symbol_bucket.js index 06cf8b9b029..91a7b0aff06 100644 --- a/src/data/bucket/symbol_bucket.js +++ b/src/data/bucket/symbol_bucket.js @@ -1,13 +1,13 @@ // @flow -import { symbolLayoutAttributes, +import {symbolLayoutAttributes, collisionVertexAttributes, collisionBoxLayout, collisionCircleLayout, dynamicLayoutAttributes } from './symbol_attributes'; -import { SymbolLayoutArray, +import {SymbolLayoutArray, SymbolDynamicLayoutArray, SymbolOpacityArray, CollisionBoxLayoutArray, @@ -21,19 +21,19 @@ import { SymbolLayoutArray, import Point from '@mapbox/point-geometry'; import SegmentVector from '../segment'; -import { ProgramConfigurationSet } from '../program_configuration'; -import { TriangleIndexArray, LineIndexArray } from '../index_array_type'; +import {ProgramConfigurationSet} from '../program_configuration'; +import {TriangleIndexArray, LineIndexArray} from '../index_array_type'; import transformText from '../../symbol/transform_text'; import mergeLines from '../../symbol/mergelines'; import {allowsVerticalWritingMode} from '../../util/script_detection'; -import { WritingMode } from '../../symbol/shaping'; +import {WritingMode} from '../../symbol/shaping'; import loadGeometry from '../load_geometry'; import mvt from '@mapbox/vector-tile'; const vectorTileFeatureTypes = mvt.VectorTileFeature.types; import {verticalizedCharacterMap} from '../../util/verticalize_punctuation'; import Anchor from '../../symbol/anchor'; -import { getSizeData } from '../../symbol/symbol_size'; -import { register } from '../../util/web_worker_transfer'; +import {getSizeData} from '../../symbol/symbol_size'; +import {register} from '../../util/web_worker_transfer'; import EvaluationParameters from '../../style/evaluation_parameters'; import Formatted from '../../style-spec/expression/types/formatted'; @@ -44,7 +44,7 @@ import type { PopulateParameters } from '../bucket'; import type {CollisionBoxArray, CollisionBox, SymbolInstance} from '../array_types'; -import type { StructArray, StructArrayMember } from '../../util/struct_array'; +import type {StructArray, StructArrayMember} from '../../util/struct_array'; import SymbolStyleLayer from '../../style/style_layer/symbol_style_layer'; import type Context from '../../gl/context'; import type IndexBuffer from '../../gl/index_buffer'; @@ -94,7 +94,7 @@ export type SymbolFeature = {| // { name: 'a_fade_opacity', components: 1, type: 'Uint32' } // ]; const shaderOpacityAttributes = [ - { name: 'a_fade_opacity', components: 1, type: 'Uint8', offset: 0 } + {name: 'a_fade_opacity', components: 1, type: 'Uint8', offset: 0} ]; function addVertex(array, anchorX, anchorY, ox, oy, tx, ty, sizeVertex) { @@ -508,13 +508,13 @@ class SymbolBucket implements Bucket { let sumBackwardLength = anchor.dist(line[anchor.segment]); const vertices = {}; for (let i = anchor.segment + 1; i < line.length; i++) { - vertices[i] = { x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumForwardLength }; + vertices[i] = {x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumForwardLength}; if (i < line.length - 1) { sumForwardLength += line[i + 1].dist(line[i]); } } for (let i = anchor.segment || 0; i >= 0; i--) { - vertices[i] = { x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumBackwardLength }; + vertices[i] = {x: line[i].x, y: line[i].y, tileUnitDistanceFromAnchor: sumBackwardLength}; if (i > 0) { sumBackwardLength += line[i - 1].dist(line[i]); } @@ -702,7 +702,7 @@ class SymbolBucket implements Bucket { for (let k = textStartIndex; k < textEndIndex; k++) { const box: CollisionBox = (collisionBoxArray.get(k): any); if (box.radius === 0) { - collisionArrays.textBox = { x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY }; + collisionArrays.textBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY}; collisionArrays.textFeatureIndex = box.featureIndex; break; // Only one box allowed per instance } else { @@ -717,7 +717,7 @@ class SymbolBucket implements Bucket { for (let k = verticalTextStartIndex; k < verticalTextEndIndex; k++) { const box: CollisionBox = (collisionBoxArray.get(k): any); if (box.radius === 0) { - collisionArrays.verticalTextBox = { x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY }; + collisionArrays.verticalTextBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY}; collisionArrays.verticalTextFeatureIndex = box.featureIndex; break; // Only one box allowed per instance } @@ -726,7 +726,7 @@ class SymbolBucket implements Bucket { // An icon can only have one box now, so this indexing is a bit vestigial... const box: CollisionBox = (collisionBoxArray.get(k): any); if (box.radius === 0) { - collisionArrays.iconBox = { x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY }; + collisionArrays.iconBox = {x1: box.x1, y1: box.y1, x2: box.x2, y2: box.y2, anchorPointX: box.anchorPointX, anchorPointY: box.anchorPointY}; collisionArrays.iconFeatureIndex = box.featureIndex; break; // Only one box allowed per instance } @@ -879,4 +879,4 @@ SymbolBucket.MAX_GLYPHS = 65535; SymbolBucket.addDynamicAttributes = addDynamicAttributes; export default SymbolBucket; -export { addDynamicAttributes }; +export {addDynamicAttributes}; diff --git a/src/data/dem_data.js b/src/data/dem_data.js index d5ddf2b4c31..fcbf98ad830 100644 --- a/src/data/dem_data.js +++ b/src/data/dem_data.js @@ -1,8 +1,8 @@ // @flow -import { RGBAImage } from '../util/image'; +import {RGBAImage} from '../util/image'; -import { warnOnce } from '../util/util'; -import { register } from '../util/web_worker_transfer'; +import {warnOnce} from '../util/util'; +import {register} from '../util/web_worker_transfer'; // DEMData is a data structure for decoding, backfilling, and storing elevation data for processing in the hillshade shaders // data can be populated either from a pngraw image tile or from serliazed data sent back from a worker. When data is initially diff --git a/src/data/feature_index.js b/src/data/feature_index.js index f6fc671fe0a..157717014a5 100644 --- a/src/data/feature_index.js +++ b/src/data/feature_index.js @@ -10,9 +10,9 @@ import DictionaryCoder from '../util/dictionary_coder'; import vt from '@mapbox/vector-tile'; import Protobuf from 'pbf'; import GeoJSONFeature from '../util/vectortile_to_geojson'; -import { arraysIntersect } from '../util/util'; -import { OverscaledTileID } from '../source/tile_id'; -import { register } from '../util/web_worker_transfer'; +import {arraysIntersect} from '../util/util'; +import {OverscaledTileID} from '../source/tile_id'; +import {register} from '../util/web_worker_transfer'; import EvaluationParameters from '../style/evaluation_parameters'; import SourceFeatureState from '../source/source_state'; import {polygonIntersectsBox} from '../util/intersection_tests'; @@ -22,7 +22,7 @@ import type {FeatureFilter} from '../style-spec/feature_filter'; import type Transform from '../geo/transform'; import type {FilterSpecification} from '../style-spec/types'; -import { FeatureIndexArray } from './array_types'; +import {FeatureIndexArray} from './array_types'; type QueryParameters = { scale: number, @@ -206,7 +206,7 @@ class FeatureIndex { if (layerResult === undefined) { layerResult = result[layerID] = []; } - layerResult.push({ featureIndex, feature: geojsonFeature, intersectionZ }); + layerResult.push({featureIndex, feature: geojsonFeature, intersectionZ}); } } @@ -252,7 +252,7 @@ class FeatureIndex { register( 'FeatureIndex', FeatureIndex, - { omit: ['rawTileData', 'sourceLayerCoder'] } + {omit: ['rawTileData', 'sourceLayerCoder']} ); export default FeatureIndex; @@ -268,7 +268,7 @@ function getBounds(geometry: Array) { maxX = Math.max(maxX, p.x); maxY = Math.max(maxY, p.y); } - return { minX, minY, maxX, maxY }; + return {minX, minY, maxX, maxY}; } function topDownFeatureComparator(a, b) { diff --git a/src/data/feature_position_map.js b/src/data/feature_position_map.js index a8c5c9bb586..1724ba5c015 100644 --- a/src/data/feature_position_map.js +++ b/src/data/feature_position_map.js @@ -1,6 +1,6 @@ // @flow -import { register } from '../util/web_worker_transfer'; +import {register} from '../util/web_worker_transfer'; import assert from 'assert'; type SerializedFeaturePositionMap = { diff --git a/src/data/load_geometry.js b/src/data/load_geometry.js index 4116e6ee5fb..5a094fa1f81 100644 --- a/src/data/load_geometry.js +++ b/src/data/load_geometry.js @@ -1,6 +1,6 @@ // @flow -import { warnOnce, clamp } from '../util/util'; +import {warnOnce, clamp} from '../util/util'; import EXTENT from './extent'; diff --git a/src/data/pos_attributes.js b/src/data/pos_attributes.js index d1175a274e3..7306b3925d5 100644 --- a/src/data/pos_attributes.js +++ b/src/data/pos_attributes.js @@ -1,6 +1,6 @@ // @flow -import { createLayout } from '../util/struct_array'; +import {createLayout} from '../util/struct_array'; export default createLayout([ - { name: 'a_pos', type: 'Int16', components: 2 } + {name: 'a_pos', type: 'Int16', components: 2} ]); diff --git a/src/data/program_configuration.js b/src/data/program_configuration.js index dfa1cac5df5..a056a8bb95f 100644 --- a/src/data/program_configuration.js +++ b/src/data/program_configuration.js @@ -1,11 +1,11 @@ // @flow -import { packUint8ToFloat } from '../shaders/encode_attribute'; +import {packUint8ToFloat} from '../shaders/encode_attribute'; import Color from '../style-spec/util/color'; -import { supportsPropertyExpression } from '../style-spec/util/properties'; -import { register, serialize, deserialize } from '../util/web_worker_transfer'; -import { PossiblyEvaluatedPropertyValue } from '../style/properties'; -import { StructArrayLayout1f4, StructArrayLayout2f8, StructArrayLayout4f16, PatternLayoutArray } from './array_types'; +import {supportsPropertyExpression} from '../style-spec/util/properties'; +import {register, serialize, deserialize} from '../util/web_worker_transfer'; +import {PossiblyEvaluatedPropertyValue} from '../style/properties'; +import {StructArrayLayout1f4, StructArrayLayout2f8, StructArrayLayout4f16, PatternLayoutArray} from './array_types'; import EvaluationParameters from '../style/evaluation_parameters'; import FeaturePositionMap from './feature_position_map'; @@ -346,7 +346,7 @@ class CompositeExpressionBinder implements Binder { updatePaintArray(start: number, end: number, feature: Feature, featureState: FeatureState) { const paintArray = this.paintVertexArray; - const min = this.expression.evaluate({zoom: this.zoom }, feature, featureState); + const min = this.expression.evaluate({zoom: this.zoom}, feature, featureState); const max = this.expression.evaluate({zoom: this.zoom + 1}, feature, featureState); if (this.type === 'color') { @@ -450,14 +450,14 @@ class CrossFadedCompositeBinder implements Binder { const zoomInArray = this.zoomInPaintVertexArray; const zoomOutArray = this.zoomOutPaintVertexArray; - const { layerId } = this; + const {layerId} = this; const start = zoomInArray.length; zoomInArray.reserve(length); zoomOutArray.reserve(length); if (imagePositions && feature.patterns && feature.patterns[layerId]) { - const { min, mid, max } = feature.patterns[layerId]; + const {min, mid, max} = feature.patterns[layerId]; const imageMin = imagePositions[min]; const imageMid = imagePositions[mid]; @@ -486,7 +486,7 @@ class CrossFadedCompositeBinder implements Binder { const zoomInArray = this.zoomInPaintVertexArray; const zoomOutArray = this.zoomOutPaintVertexArray; - const { layerId } = this; + const {layerId} = this; if (imagePositions && feature.patterns && feature.patterns[layerId]) { const {min, mid, max} = feature.patterns[layerId]; diff --git a/src/data/raster_bounds_attributes.js b/src/data/raster_bounds_attributes.js index 8c7ca0bba99..6d13fe538be 100644 --- a/src/data/raster_bounds_attributes.js +++ b/src/data/raster_bounds_attributes.js @@ -1,7 +1,7 @@ // @flow -import { createLayout } from '../util/struct_array'; +import {createLayout} from '../util/struct_array'; export default createLayout([ - { name: 'a_pos', type: 'Int16', components: 2 }, - { name: 'a_texture_pos', type: 'Int16', components: 2 } + {name: 'a_pos', type: 'Int16', components: 2}, + {name: 'a_texture_pos', type: 'Int16', components: 2} ]); diff --git a/src/data/segment.js b/src/data/segment.js index 9d3335923a7..664cf2df6ee 100644 --- a/src/data/segment.js +++ b/src/data/segment.js @@ -1,8 +1,8 @@ // @flow -import { warnOnce } from '../util/util'; +import {warnOnce} from '../util/util'; -import { register } from '../util/web_worker_transfer'; +import {register} from '../util/web_worker_transfer'; import type VertexArrayObject from '../render/vertex_array_object'; import type {StructArray} from '../util/struct_array'; diff --git a/src/geo/lng_lat.js b/src/geo/lng_lat.js index 2a561be76a9..eb5ec5f3831 100644 --- a/src/geo/lng_lat.js +++ b/src/geo/lng_lat.js @@ -1,6 +1,6 @@ // @flow -import { wrap } from '../util/util'; +import {wrap} from '../util/util'; import LngLatBounds from './lng_lat_bounds'; /** diff --git a/src/geo/transform.js b/src/geo/transform.js index 06b0fd86126..9d73c0af302 100644 --- a/src/geo/transform.js +++ b/src/geo/transform.js @@ -4,14 +4,14 @@ import LngLat from './lng_lat'; import LngLatBounds from './lng_lat_bounds'; import MercatorCoordinate, {mercatorXfromLng, mercatorYfromLat, mercatorZfromAltitude} from './mercator_coordinate'; import Point from '@mapbox/point-geometry'; -import { wrap, clamp } from '../util/util'; +import {wrap, clamp} from '../util/util'; import {number as interpolate} from '../style-spec/util/interpolate'; import tileCover from '../util/tile_cover'; -import { UnwrappedTileID } from '../source/tile_id'; +import {UnwrappedTileID} from '../source/tile_id'; import EXTENT from '../data/extent'; -import { vec4, mat4, mat2 } from 'gl-matrix'; +import {vec4, mat4, mat2} from 'gl-matrix'; -import type { OverscaledTileID, CanonicalTileID } from '../source/tile_id'; +import type {OverscaledTileID, CanonicalTileID} from '../source/tile_id'; /** * A single transform, generally used for a single tile to be diff --git a/src/gl/context.js b/src/gl/context.js index 71062d46065..a5cac49d7bb 100644 --- a/src/gl/context.js +++ b/src/gl/context.js @@ -7,8 +7,8 @@ import DepthMode from './depth_mode'; import StencilMode from './stencil_mode'; import ColorMode from './color_mode'; import CullFaceMode from './cull_face_mode'; -import { deepEqual } from '../util/util'; -import { ClearColor, ClearDepth, ClearStencil, ColorMask, DepthMask, StencilMask, StencilFunc, StencilOp, StencilTest, DepthRange, DepthTest, DepthFunc, Blend, BlendFunc, BlendColor, BlendEquation, CullFace, CullFaceSide, FrontFace, Program, ActiveTextureUnit, Viewport, BindFramebuffer, BindRenderbuffer, BindTexture, BindVertexBuffer, BindElementBuffer, BindVertexArrayOES, PixelStoreUnpack, PixelStoreUnpackPremultiplyAlpha, PixelStoreUnpackFlipY } from './value'; +import {deepEqual} from '../util/util'; +import {ClearColor, ClearDepth, ClearStencil, ColorMask, DepthMask, StencilMask, StencilFunc, StencilOp, StencilTest, DepthRange, DepthTest, DepthFunc, Blend, BlendFunc, BlendColor, BlendEquation, CullFace, CullFaceSide, FrontFace, Program, ActiveTextureUnit, Viewport, BindFramebuffer, BindRenderbuffer, BindTexture, BindVertexBuffer, BindElementBuffer, BindVertexArrayOES, PixelStoreUnpack, PixelStoreUnpackPremultiplyAlpha, PixelStoreUnpackFlipY} from './value'; import type {TriangleIndexArray, LineIndexArray, LineStripIndexArray} from '../data/index_array_type'; import type { diff --git a/src/gl/depth_mode.js b/src/gl/depth_mode.js index c3ad66f93ed..e2483faeac4 100644 --- a/src/gl/depth_mode.js +++ b/src/gl/depth_mode.js @@ -1,5 +1,5 @@ // @flow -import type { DepthFuncType, DepthMaskType, DepthRangeType } from './types'; +import type {DepthFuncType, DepthMaskType, DepthRangeType} from './types'; const ALWAYS = 0x0207; diff --git a/src/gl/framebuffer.js b/src/gl/framebuffer.js index 15376dfa92b..7353efec8b8 100644 --- a/src/gl/framebuffer.js +++ b/src/gl/framebuffer.js @@ -1,5 +1,5 @@ // @flow -import { ColorAttachment, DepthAttachment } from './value'; +import {ColorAttachment, DepthAttachment} from './value'; import type Context from './context'; diff --git a/src/gl/stencil_mode.js b/src/gl/stencil_mode.js index 37ba57cb09e..b878e1d81fc 100644 --- a/src/gl/stencil_mode.js +++ b/src/gl/stencil_mode.js @@ -1,5 +1,5 @@ // @flow -import type { StencilOpConstant, StencilTest } from './types'; +import type {StencilOpConstant, StencilTest} from './types'; const ALWAYS = 0x0207; const KEEP = 0x1E00; @@ -25,6 +25,6 @@ class StencilMode { static disabled: $ReadOnly; } -StencilMode.disabled = new StencilMode({ func: ALWAYS, mask: 0 }, 0, 0, KEEP, KEEP, KEEP); +StencilMode.disabled = new StencilMode({func: ALWAYS, mask: 0}, 0, 0, KEEP, KEEP, KEEP); export default StencilMode; diff --git a/src/index.js b/src/index.js index b8169dc3504..21baf999762 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,7 @@ import assert from 'assert'; import supported from '@mapbox/mapbox-gl-supported'; -import { version } from '../package.json'; +import {version} from '../package.json'; import Map from './ui/map'; import NavigationControl from './ui/control/navigation_control'; import GeolocateControl from './ui/control/geolocate_control'; diff --git a/src/render/draw_circle.js b/src/render/draw_circle.js index 8231959514f..6b11ca12971 100644 --- a/src/render/draw_circle.js +++ b/src/render/draw_circle.js @@ -4,9 +4,9 @@ import StencilMode from '../gl/stencil_mode'; import DepthMode from '../gl/depth_mode'; import CullFaceMode from '../gl/cull_face_mode'; import Program from './program'; -import { circleUniformValues } from './program/circle_program'; +import {circleUniformValues} from './program/circle_program'; import SegmentVector from '../data/segment'; -import { OverscaledTileID } from '../source/tile_id'; +import {OverscaledTileID} from '../source/tile_id'; import type Painter from './painter'; import type SourceCache from '../source/source_cache'; diff --git a/src/render/draw_collision_debug.js b/src/render/draw_collision_debug.js index beb4d1d5e40..47369dd63ec 100644 --- a/src/render/draw_collision_debug.js +++ b/src/render/draw_collision_debug.js @@ -8,7 +8,7 @@ import type SymbolBucket from '../data/bucket/symbol_bucket'; import DepthMode from '../gl/depth_mode'; import StencilMode from '../gl/stencil_mode'; import CullFaceMode from '../gl/cull_face_mode'; -import { collisionUniformValues } from './program/collision_program'; +import {collisionUniformValues} from './program/collision_program'; export default drawCollisionDebug; diff --git a/src/render/draw_debug.js b/src/render/draw_debug.js index 3b157fdf788..37d0f332bfa 100644 --- a/src/render/draw_debug.js +++ b/src/render/draw_debug.js @@ -1,15 +1,15 @@ // @flow -import { mat4 } from 'gl-matrix'; +import {mat4} from 'gl-matrix'; import EXTENT from '../data/extent'; -import { PosArray } from '../data/array_types'; -import { LineIndexArray } from '../data/index_array_type'; +import {PosArray} from '../data/array_types'; +import {LineIndexArray} from '../data/index_array_type'; import posAttributes from '../data/pos_attributes'; import SegmentVector from '../data/segment'; import DepthMode from '../gl/depth_mode'; import StencilMode from '../gl/stencil_mode'; import CullFaceMode from '../gl/cull_face_mode'; -import { debugUniformValues } from './program/debug_program'; +import {debugUniformValues} from './program/debug_program'; import Color from '../style-spec/util/color'; import type Painter from './painter'; diff --git a/src/render/draw_heatmap.js b/src/render/draw_heatmap.js index df9475e97b1..17bac89b455 100644 --- a/src/render/draw_heatmap.js +++ b/src/render/draw_heatmap.js @@ -37,7 +37,7 @@ function drawHeatmap(painter: Painter, sourceCache: SourceCache, layer: HeatmapS bindFramebuffer(context, painter, layer); - context.clear({ color: Color.transparent }); + context.clear({color: Color.transparent}); for (let i = 0; i < coords.length; i++) { const coord = coords[i]; diff --git a/src/render/draw_hillshade.js b/src/render/draw_hillshade.js index 2c548522a16..ae30f19bebf 100644 --- a/src/render/draw_hillshade.js +++ b/src/render/draw_hillshade.js @@ -80,10 +80,10 @@ function prepareHillshade(painter, tile, layer, sourceMaxZoom, depthMode, stenci tile.demTexture = tile.demTexture || painter.getTileTexture(textureStride); if (tile.demTexture) { const demTexture = tile.demTexture; - demTexture.update(pixelData, { premultiply: false }); + demTexture.update(pixelData, {premultiply: false}); demTexture.bind(gl.NEAREST, gl.CLAMP_TO_EDGE); } else { - tile.demTexture = new Texture(context, pixelData, gl.RGBA, { premultiply: false }); + tile.demTexture = new Texture(context, pixelData, gl.RGBA, {premultiply: false}); tile.demTexture.bind(gl.NEAREST, gl.CLAMP_TO_EDGE); } diff --git a/src/render/draw_raster.js b/src/render/draw_raster.js index 6047ba73145..ad9598308a4 100644 --- a/src/render/draw_raster.js +++ b/src/render/draw_raster.js @@ -1,13 +1,13 @@ // @flow -import { clamp } from '../util/util'; +import {clamp} from '../util/util'; import ImageSource from '../source/image_source'; import browser from '../util/browser'; import StencilMode from '../gl/stencil_mode'; import DepthMode from '../gl/depth_mode'; import CullFaceMode from '../gl/cull_face_mode'; -import { rasterUniformValues } from './program/raster_program'; +import {rasterUniformValues} from './program/raster_program'; import type Painter from './painter'; import type SourceCache from '../source/source_cache'; diff --git a/src/render/draw_symbol.js b/src/render/draw_symbol.js index 7a6141743a3..96618fd5863 100644 --- a/src/render/draw_symbol.js +++ b/src/render/draw_symbol.js @@ -7,16 +7,16 @@ import SegmentVector from '../data/segment'; import pixelsToTileUnits from '../source/pixels_to_tile_units'; import * as symbolProjection from '../symbol/projection'; import * as symbolSize from '../symbol/symbol_size'; -import { mat4 } from 'gl-matrix'; +import {mat4} from 'gl-matrix'; const identityMat4 = mat4.identity(new Float32Array(16)); import StencilMode from '../gl/stencil_mode'; import DepthMode from '../gl/depth_mode'; import CullFaceMode from '../gl/cull_face_mode'; import {addDynamicAttributes} from '../data/bucket/symbol_bucket'; -import { getAnchorAlignment, WritingMode } from '../symbol/shaping'; +import {getAnchorAlignment, WritingMode} from '../symbol/shaping'; import ONE_EM from '../symbol/one_em'; -import { evaluateRadialOffset } from '../symbol/symbol_layout'; +import {evaluateRadialOffset} from '../symbol/symbol_layout'; import { symbolIconUniformValues, @@ -31,7 +31,7 @@ import type Texture from '../render/texture'; import type {OverscaledTileID} from '../source/tile_id'; import type {UniformValues} from './uniform_binding'; import type {SymbolSDFUniformsType} from '../render/program/symbol_program'; -import type { CrossTileID, VariableOffset } from '../symbol/placement'; +import type {CrossTileID, VariableOffset} from '../symbol/placement'; export default drawSymbols; @@ -120,7 +120,7 @@ function updateVariableAnchors(bucket, rotateWithMap, pitchWithMap, variableOffs renderTextSize *= bucket.tilePixelRatio / tileScale; } - const { width, height, radialOffset, textBoxScale } = variableOffset; + const {width, height, radialOffset, textBoxScale} = variableOffset; const shift = calculateVariableRenderShift( variableOffset.anchor, width, height, radialOffset, textBoxScale, renderTextSize); diff --git a/src/render/glyph_atlas.js b/src/render/glyph_atlas.js index 8a715f7cd79..584b8816fbd 100644 --- a/src/render/glyph_atlas.js +++ b/src/render/glyph_atlas.js @@ -1,7 +1,7 @@ // @flow -import { AlphaImage } from '../util/image'; -import { register } from '../util/web_worker_transfer'; +import {AlphaImage} from '../util/image'; +import {register} from '../util/web_worker_transfer'; import potpack from 'potpack'; import type {GlyphMetrics, StyleGlyph} from '../style/style_glyph'; diff --git a/src/render/glyph_manager.js b/src/render/glyph_manager.js index 2dab0d3e26d..7a8079dda6e 100644 --- a/src/render/glyph_manager.js +++ b/src/render/glyph_manager.js @@ -4,8 +4,8 @@ import loadGlyphRange from '../style/load_glyph_range'; import TinySDF from '@mapbox/tiny-sdf'; import isChar from '../util/is_char_in_unicode_block'; -import { asyncAll } from '../util/util'; -import { AlphaImage } from '../util/image'; +import {asyncAll} from '../util/util'; +import {AlphaImage} from '../util/image'; import type {StyleGlyph} from '../style/style_glyph'; import type {RequestManager} from '../util/mapbox'; diff --git a/src/render/image_atlas.js b/src/render/image_atlas.js index fa2be7ecab9..18a32928da0 100644 --- a/src/render/image_atlas.js +++ b/src/render/image_atlas.js @@ -1,7 +1,7 @@ // @flow -import { RGBAImage } from '../util/image'; -import { register } from '../util/web_worker_transfer'; +import {RGBAImage} from '../util/image'; +import {register} from '../util/web_worker_transfer'; import potpack from 'potpack'; import type {StyleImage} from '../style/style_image'; @@ -89,10 +89,10 @@ export default class ImageAtlas { RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x, y}, src.data); // Add 1 pixel wrapped padding on each side of the image. - RGBAImage.copy(src.data, image, { x: 0, y: h - 1 }, { x, y: y - 1 }, { width: w, height: 1 }); // T - RGBAImage.copy(src.data, image, { x: 0, y: 0 }, { x, y: y + h }, { width: w, height: 1 }); // B - RGBAImage.copy(src.data, image, { x: w - 1, y: 0 }, { x: x - 1, y }, { width: 1, height: h }); // L - RGBAImage.copy(src.data, image, { x: 0, y: 0 }, { x: x + w, y }, { width: 1, height: h }); // R + RGBAImage.copy(src.data, image, {x: 0, y: h - 1}, {x, y: y - 1}, {width: w, height: 1}); // T + RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x, y: y + h}, {width: w, height: 1}); // B + RGBAImage.copy(src.data, image, {x: w - 1, y: 0}, {x: x - 1, y}, {width: 1, height: h}); // L + RGBAImage.copy(src.data, image, {x: 0, y: 0}, {x: x + w, y}, {width: 1, height: h}); // R } this.image = image; diff --git a/src/render/image_manager.js b/src/render/image_manager.js index dbb63aaa63d..eb2e1e9e10d 100644 --- a/src/render/image_manager.js +++ b/src/render/image_manager.js @@ -2,13 +2,13 @@ import potpack from 'potpack'; -import { Event, Evented } from '../util/evented'; -import { RGBAImage } from '../util/image'; -import { ImagePosition } from './image_atlas'; +import {Event, Evented} from '../util/evented'; +import {RGBAImage} from '../util/image'; +import {ImagePosition} from './image_atlas'; import Texture from './texture'; import assert from 'assert'; import {renderStyleImage} from '../style/style_image'; -import { warnOnce } from '../util/util'; +import {warnOnce} from '../util/util'; import type {StyleImage} from '../style/style_image'; import type Context from '../gl/context'; @@ -140,7 +140,7 @@ class ImageManager extends Evented { for (const id of ids) { if (!this.images[id]) { - this.fire(new Event('styleimagemissing', { id })); + this.fire(new Event('styleimagemissing', {id})); } const image = this.images[id]; if (image) { @@ -225,13 +225,13 @@ class ImageManager extends Evented { const w = src.width; const h = src.height; - RGBAImage.copy(src, dst, { x: 0, y: 0 }, { x, y }, { width: w, height: h }); + RGBAImage.copy(src, dst, {x: 0, y: 0}, {x, y}, {width: w, height: h}); // Add 1 pixel wrapped padding on each side of the image. - RGBAImage.copy(src, dst, { x: 0, y: h - 1 }, { x, y: y - 1 }, { width: w, height: 1 }); // T - RGBAImage.copy(src, dst, { x: 0, y: 0 }, { x, y: y + h }, { width: w, height: 1 }); // B - RGBAImage.copy(src, dst, { x: w - 1, y: 0 }, { x: x - 1, y }, { width: 1, height: h }); // L - RGBAImage.copy(src, dst, { x: 0, y: 0 }, { x: x + w, y }, { width: 1, height: h }); // R + RGBAImage.copy(src, dst, {x: 0, y: h - 1}, {x, y: y - 1}, {width: w, height: 1}); // T + RGBAImage.copy(src, dst, {x: 0, y: 0}, {x, y: y + h}, {width: w, height: 1}); // B + RGBAImage.copy(src, dst, {x: w - 1, y: 0}, {x: x - 1, y}, {width: 1, height: h}); // L + RGBAImage.copy(src, dst, {x: 0, y: 0}, {x: x + w, y}, {width: 1, height: h}); // R } this.dirty = true; diff --git a/src/render/line_atlas.js b/src/render/line_atlas.js index 2e870134370..d3208e9bac4 100644 --- a/src/render/line_atlas.js +++ b/src/render/line_atlas.js @@ -1,6 +1,6 @@ // @flow -import { warnOnce } from '../util/util'; +import {warnOnce} from '../util/util'; import type Context from '../gl/context'; diff --git a/src/render/painter.js b/src/render/painter.js index 9ad85b4179a..056fbccfac8 100644 --- a/src/render/painter.js +++ b/src/render/painter.js @@ -2,19 +2,19 @@ import browser from '../util/browser'; -import { mat4 } from 'gl-matrix'; +import {mat4} from 'gl-matrix'; import SourceCache from '../source/source_cache'; import EXTENT from '../data/extent'; import pixelsToTileUnits from '../source/pixels_to_tile_units'; import SegmentVector from '../data/segment'; -import { RasterBoundsArray, PosArray, TriangleIndexArray, LineStripIndexArray } from '../data/array_types'; +import {RasterBoundsArray, PosArray, TriangleIndexArray, LineStripIndexArray} from '../data/array_types'; import rasterBoundsAttributes from '../data/raster_bounds_attributes'; import posAttributes from '../data/pos_attributes'; import ProgramConfiguration from '../data/program_configuration'; import CrossTileSymbolIndex from '../symbol/cross_tile_symbol_index'; import * as shaders from '../shaders'; import Program from './program'; -import { programUniforms } from './program/program_uniforms'; +import {programUniforms} from './program/program_uniforms'; import Context from '../gl/context'; import DepthMode from '../gl/depth_mode'; import StencilMode from '../gl/stencil_mode'; @@ -22,7 +22,7 @@ import ColorMode from '../gl/color_mode'; import CullFaceMode from '../gl/cull_face_mode'; import Texture from './texture'; import updateTileMasks from './tile_mask'; -import { clippingMaskUniformValues } from './program/clipping_mask_program'; +import {clippingMaskUniformValues} from './program/clipping_mask_program'; import Color from '../style-spec/util/color'; import symbol from './draw_symbol'; import circle from './draw_circle'; @@ -211,7 +211,7 @@ class Painter { this.quadTriangleIndexBuffer = context.createIndexBuffer(quadTriangleIndices); const gl = this.context.gl; - this.stencilClearMode = new StencilMode({ func: gl.ALWAYS, mask: 0 }, 0x0, 0xFF, gl.ZERO, gl.ZERO, gl.ZERO); + this.stencilClearMode = new StencilMode({func: gl.ALWAYS, mask: 0}, 0x0, 0xFF, gl.ZERO, gl.ZERO, gl.ZERO); } /* @@ -266,7 +266,7 @@ class Painter { program.draw(context, gl.TRIANGLES, DepthMode.disabled, // Tests will always pass, and ref value will be written to stencil buffer. - new StencilMode({ func: gl.ALWAYS, mask: 0 }, id, 0xFF, gl.KEEP, gl.KEEP, gl.REPLACE), + new StencilMode({func: gl.ALWAYS, mask: 0}, id, 0xFF, gl.KEEP, gl.KEEP, gl.REPLACE), ColorMode.disabled, CullFaceMode.disabled, clippingMaskUniformValues(tileID.posMatrix), '$clipping', this.tileExtentBuffer, this.quadTriangleIndexBuffer, this.tileExtentSegments); @@ -282,12 +282,12 @@ class Painter { const id = this.nextStencilID++; const gl = this.context.gl; - return new StencilMode({ func: gl.NOTEQUAL, mask: 0xFF }, id, 0xFF, gl.KEEP, gl.KEEP, gl.REPLACE); + return new StencilMode({func: gl.NOTEQUAL, mask: 0xFF}, id, 0xFF, gl.KEEP, gl.KEEP, gl.REPLACE); } stencilModeForClipping(tileID: OverscaledTileID): StencilMode { const gl = this.context.gl; - return new StencilMode({ func: gl.EQUAL, mask: 0xFF }, this._tileClippingMaskIDs[tileID.key], 0x00, gl.KEEP, gl.KEEP, gl.REPLACE); + return new StencilMode({func: gl.EQUAL, mask: 0xFF}, this._tileClippingMaskIDs[tileID.key], 0x00, gl.KEEP, gl.KEEP, gl.REPLACE); } colorModeForRenderPass(): $ReadOnly { @@ -393,7 +393,7 @@ class Painter { this.context.bindFramebuffer.set(null); // Clear buffers in preparation for drawing to the main framebuffer - this.context.clear({ color: options.showOverdrawInspector ? Color.black : Color.transparent, depth: 1 }); + this.context.clear({color: options.showOverdrawInspector ? Color.black : Color.transparent, depth: 1}); this.clearStencil(); this._showOverdrawInspector = options.showOverdrawInspector; diff --git a/src/render/program/background_program.js b/src/render/program/background_program.js index 429ec1e8993..4399ac58f8d 100644 --- a/src/render/program/background_program.js +++ b/src/render/program/background_program.js @@ -1,6 +1,6 @@ // @flow -import { bgPatternUniformValues } from './pattern'; +import {bgPatternUniformValues} from './pattern'; import { Uniform1i, Uniform1f, @@ -8,7 +8,7 @@ import { UniformColor, UniformMatrix4f } from '../uniform_binding'; -import { extend } from '../../util/util'; +import {extend} from '../../util/util'; import type Painter from '../painter'; import type {UniformValues, UniformLocations} from '../uniform_binding'; diff --git a/src/render/program/circle_program.js b/src/render/program/circle_program.js index 9b77c53725b..afde54051ee 100644 --- a/src/render/program/circle_program.js +++ b/src/render/program/circle_program.js @@ -66,4 +66,4 @@ const circleUniformValues = ( }; }; -export { circleUniforms, circleUniformValues }; +export {circleUniforms, circleUniformValues}; diff --git a/src/render/program/clipping_mask_program.js b/src/render/program/clipping_mask_program.js index f1cbea38b26..71f4a67cd4b 100644 --- a/src/render/program/clipping_mask_program.js +++ b/src/render/program/clipping_mask_program.js @@ -1,6 +1,6 @@ // @flow -import { UniformMatrix4f } from '../uniform_binding'; +import {UniformMatrix4f} from '../uniform_binding'; import type Context from '../../gl/context'; import type {UniformValues, UniformLocations} from '../uniform_binding'; @@ -17,4 +17,4 @@ const clippingMaskUniformValues = (matrix: Float32Array): UniformValues, crossfade: CrossfadeP 'u_pixel_coord_lower': [pixelX & 0xFFFF, pixelY & 0xFFFF] }; } -export { bgPatternUniformValues, patternUniformValues }; +export {bgPatternUniformValues, patternUniformValues}; diff --git a/src/render/program/program_uniforms.js b/src/render/program/program_uniforms.js index 34fafaa4993..b44bd7d802b 100644 --- a/src/render/program/program_uniforms.js +++ b/src/render/program/program_uniforms.js @@ -1,17 +1,17 @@ // @flow -import { fillExtrusionUniforms, fillExtrusionPatternUniforms } from './fill_extrusion_program'; -import { fillUniforms, fillPatternUniforms, fillOutlineUniforms, fillOutlinePatternUniforms } from './fill_program'; -import { circleUniforms } from './circle_program'; -import { collisionUniforms } from './collision_program'; -import { debugUniforms } from './debug_program'; -import { clippingMaskUniforms } from './clipping_mask_program'; -import { heatmapUniforms, heatmapTextureUniforms } from './heatmap_program'; -import { hillshadeUniforms, hillshadePrepareUniforms } from './hillshade_program'; -import { lineUniforms, lineGradientUniforms, linePatternUniforms, lineSDFUniforms } from './line_program'; -import { rasterUniforms } from './raster_program'; -import { symbolIconUniforms, symbolSDFUniforms } from './symbol_program'; -import { backgroundUniforms, backgroundPatternUniforms } from './background_program'; +import {fillExtrusionUniforms, fillExtrusionPatternUniforms} from './fill_extrusion_program'; +import {fillUniforms, fillPatternUniforms, fillOutlineUniforms, fillOutlinePatternUniforms} from './fill_program'; +import {circleUniforms} from './circle_program'; +import {collisionUniforms} from './collision_program'; +import {debugUniforms} from './debug_program'; +import {clippingMaskUniforms} from './clipping_mask_program'; +import {heatmapUniforms, heatmapTextureUniforms} from './heatmap_program'; +import {hillshadeUniforms, hillshadePrepareUniforms} from './hillshade_program'; +import {lineUniforms, lineGradientUniforms, linePatternUniforms, lineSDFUniforms} from './line_program'; +import {rasterUniforms} from './raster_program'; +import {symbolIconUniforms, symbolSDFUniforms} from './symbol_program'; +import {backgroundUniforms, backgroundPatternUniforms} from './background_program'; export const programUniforms = { fillExtrusion: fillExtrusionUniforms, diff --git a/src/render/program/raster_program.js b/src/render/program/raster_program.js index 857651f9d6d..caa477a1995 100644 --- a/src/render/program/raster_program.js +++ b/src/render/program/raster_program.js @@ -89,4 +89,4 @@ function saturationFactor(saturation) { -saturation; } -export { rasterUniforms, rasterUniformValues }; +export {rasterUniforms, rasterUniformValues}; diff --git a/src/render/program/symbol_program.js b/src/render/program/symbol_program.js index 0b0ffff8239..273a261d706 100644 --- a/src/render/program/symbol_program.js +++ b/src/render/program/symbol_program.js @@ -6,7 +6,7 @@ import { Uniform2f, UniformMatrix4f } from '../uniform_binding'; -import { extend } from '../../util/util'; +import {extend} from '../../util/util'; import browser from '../../util/browser'; import type Context from '../../gl/context'; @@ -153,4 +153,4 @@ const symbolSDFUniformValues = ( }); }; -export { symbolIconUniforms, symbolSDFUniforms, symbolIconUniformValues, symbolSDFUniformValues }; +export {symbolIconUniforms, symbolSDFUniforms, symbolIconUniformValues, symbolSDFUniformValues}; diff --git a/src/render/texture.js b/src/render/texture.js index ef71a1a519a..efd5ad7af36 100644 --- a/src/render/texture.js +++ b/src/render/texture.js @@ -1,7 +1,7 @@ // @flow import window from '../util/window'; -const { HTMLImageElement, HTMLCanvasElement, HTMLVideoElement, ImageData } = window; +const {HTMLImageElement, HTMLCanvasElement, HTMLVideoElement, ImageData} = window; import type Context from '../gl/context'; import type {RGBAImage, AlphaImage} from '../util/image'; @@ -72,7 +72,7 @@ class Texture { } } else { - const {x, y} = position || { x: 0, y: 0}; + const {x, y} = position || {x: 0, y: 0}; if (image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof HTMLVideoElement || image instanceof ImageData) { gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, gl.RGBA, gl.UNSIGNED_BYTE, image); } else { diff --git a/src/render/tile_mask.js b/src/render/tile_mask.js index 6ddae9e7046..a88238a3105 100644 --- a/src/render/tile_mask.js +++ b/src/render/tile_mask.js @@ -1,6 +1,6 @@ // @flow -import { OverscaledTileID, CanonicalTileID } from '../source/tile_id'; +import {OverscaledTileID, CanonicalTileID} from '../source/tile_id'; import type Tile from './../source/tile'; import type Context from '../gl/context'; diff --git a/src/shaders/encode_attribute.js b/src/shaders/encode_attribute.js index ff13c6672c7..7e09dd696d2 100644 --- a/src/shaders/encode_attribute.js +++ b/src/shaders/encode_attribute.js @@ -1,6 +1,6 @@ // @flow -import { clamp } from '../util/util'; +import {clamp} from '../util/util'; /** * Packs two numbers, interpreted as 8-bit unsigned integers, into a single diff --git a/src/source/canvas_source.js b/src/source/canvas_source.js index 992fa15632b..54b65ce2454 100644 --- a/src/source/canvas_source.js +++ b/src/source/canvas_source.js @@ -6,7 +6,7 @@ import window from '../util/window'; import rasterBoundsAttributes from '../data/raster_bounds_attributes'; import SegmentVector from '../data/segment'; import Texture from '../render/texture'; -import { ErrorEvent } from '../util/evented'; +import {ErrorEvent} from '../util/evented'; import ValidationError from '../style-spec/error/validation_error'; import type Map from '../ui/map'; @@ -202,9 +202,9 @@ class CanvasSource extends ImageSource { } if (!this.texture) { - this.texture = new Texture(context, this.canvas, gl.RGBA, { premultiply: true }); + this.texture = new Texture(context, this.canvas, gl.RGBA, {premultiply: true}); } else if (resize || this._playing) { - this.texture.update(this.canvas, { premultiply: true }); + this.texture.update(this.canvas, {premultiply: true}); } for (const w in this.tiles) { diff --git a/src/source/geojson_source.js b/src/source/geojson_source.js index 0ab32d56352..ffc1071c0da 100644 --- a/src/source/geojson_source.js +++ b/src/source/geojson_source.js @@ -1,10 +1,10 @@ // @flow -import { Event, ErrorEvent, Evented } from '../util/evented'; +import {Event, ErrorEvent, Evented} from '../util/evented'; -import { extend } from '../util/util'; +import {extend} from '../util/util'; import EXTENT from '../data/extent'; -import { ResourceType } from '../util/ajax'; +import {ResourceType} from '../util/ajax'; import browser from '../util/browser'; import type {Source} from './source'; @@ -152,7 +152,7 @@ class GeoJSONSource extends Evented implements Source { return; } - const data: Object = { dataType: 'source', sourceDataType: 'metadata' }; + const data: Object = {dataType: 'source', sourceDataType: 'metadata'}; if (this._collectResourceTiming && this._resourceTiming && (this._resourceTiming.length > 0)) { data.resourceTiming = this._resourceTiming; this._resourceTiming = []; @@ -184,7 +184,7 @@ class GeoJSONSource extends Evented implements Source { return; } - const data: Object = { dataType: 'source', sourceDataType: 'content' }; + const data: Object = {dataType: 'source', sourceDataType: 'content'}; if (this._collectResourceTiming && this._resourceTiming && (this._resourceTiming.length > 0)) { data.resourceTiming = this._resourceTiming; this._resourceTiming = []; @@ -203,7 +203,7 @@ class GeoJSONSource extends Evented implements Source { * @returns {GeoJSONSource} this */ getClusterExpansionZoom(clusterId: number, callback: Callback) { - this.actor.send('geojson.getClusterExpansionZoom', { clusterId, source: this.id }, callback); + this.actor.send('geojson.getClusterExpansionZoom', {clusterId, source: this.id}, callback); return this; } @@ -215,7 +215,7 @@ class GeoJSONSource extends Evented implements Source { * @returns {GeoJSONSource} this */ getClusterChildren(clusterId: number, callback: Callback>) { - this.actor.send('geojson.getClusterChildren', { clusterId, source: this.id }, callback); + this.actor.send('geojson.getClusterChildren', {clusterId, source: this.id}, callback); return this; } @@ -273,7 +273,7 @@ class GeoJSONSource extends Evented implements Source { // message queue. Waiting instead for the 'coalesce' to round-trip // through the foreground just means we're throttling the worker // to run at a little less than full-throttle. - this.actor.send(`${this.type}.coalesce`, { source: options.source }, null); + this.actor.send(`${this.type}.coalesce`, {source: options.source}, null); callback(err); }); } @@ -325,12 +325,12 @@ class GeoJSONSource extends Evented implements Source { unloadTile(tile: Tile) { tile.unloadVectorData(); - this.actor.send('removeTile', { uid: tile.uid, type: this.type, source: this.id }); + this.actor.send('removeTile', {uid: tile.uid, type: this.type, source: this.id}); } onRemove() { this._removed = true; - this.actor.send('removeSource', { type: this.type, source: this.id }); + this.actor.send('removeSource', {type: this.type, source: this.id}); } serialize() { diff --git a/src/source/geojson_worker_source.js b/src/source/geojson_worker_source.js index 00fc790efa8..dfa681f9ede 100644 --- a/src/source/geojson_worker_source.js +++ b/src/source/geojson_worker_source.js @@ -1,6 +1,6 @@ // @flow -import { getJSON } from '../util/ajax'; +import {getJSON} from '../util/ajax'; import performance from '../util/performance'; import rewind from '@mapbox/geojson-rewind'; @@ -10,7 +10,7 @@ import Supercluster from 'supercluster'; import geojsonvt from 'geojson-vt'; import assert from 'assert'; import VectorTileWorkerSource from './vector_tile_worker_source'; -import { createExpression } from '../style-spec/expression'; +import {createExpression} from '../style-spec/expression'; import type { WorkerTileParameters, @@ -21,8 +21,8 @@ import type Actor from '../util/actor'; import type StyleLayerIndex from '../style/style_layer_index'; import type {LoadVectorDataCallback} from './vector_tile_worker_source'; -import type { RequestParameters, ResponseCallback } from '../util/ajax'; -import type { Callback } from '../types/callback'; +import type {RequestParameters, ResponseCallback} from '../util/ajax'; +import type {Callback} from '../types/callback'; import type {GeoJSONFeature} from '@mapbox/geojson-types'; export type LoadGeoJSONParameters = { @@ -132,7 +132,7 @@ class GeoJSONWorkerSource extends VectorTileWorkerSource { abandoned?: boolean }>) { if (this._pendingCallback) { // Tell the foreground the previous call has been abandoned - this._pendingCallback(null, { abandoned: true }); + this._pendingCallback(null, {abandoned: true}); } this._pendingCallback = callback; this._pendingLoadDataParams = params; @@ -277,7 +277,7 @@ class GeoJSONWorkerSource extends VectorTileWorkerSource { removeSource(params: {source: string}, callback: Callback) { if (this._pendingCallback) { // Don't leak callbacks - this._pendingCallback(null, { abandoned: true }); + this._pendingCallback(null, {abandoned: true}); } callback(); } diff --git a/src/source/geojson_wrapper.js b/src/source/geojson_wrapper.js index c621f80de6b..40e44f22278 100644 --- a/src/source/geojson_wrapper.js +++ b/src/source/geojson_wrapper.js @@ -79,7 +79,7 @@ class GeoJSONWrapper implements VectorTile, VectorTileLayer { _features: Array; constructor(features: Array) { - this.layers = { '_geojsonTileLayer': this }; + this.layers = {'_geojsonTileLayer': this}; this.name = '_geojsonTileLayer'; this.extent = EXTENT; this.length = features.length; diff --git a/src/source/image_source.js b/src/source/image_source.js index 71a60fc75b2..40d1dbc11e9 100644 --- a/src/source/image_source.js +++ b/src/source/image_source.js @@ -1,10 +1,10 @@ // @flow -import { CanonicalTileID } from './tile_id'; -import { Event, ErrorEvent, Evented } from '../util/evented'; -import { getImage, ResourceType } from '../util/ajax'; +import {CanonicalTileID} from './tile_id'; +import {Event, ErrorEvent, Evented} from '../util/evented'; +import {getImage, ResourceType} from '../util/ajax'; import EXTENT from '../data/extent'; -import { RasterBoundsArray } from '../data/array_types'; +import {RasterBoundsArray} from '../data/array_types'; import rasterBoundsAttributes from '../data/raster_bounds_attributes'; import SegmentVector from '../data/segment'; import Texture from '../render/texture'; diff --git a/src/source/load_tilejson.js b/src/source/load_tilejson.js index f26816d1b49..725c670eac0 100644 --- a/src/source/load_tilejson.js +++ b/src/source/load_tilejson.js @@ -1,8 +1,8 @@ // @flow -import { pick, extend } from '../util/util'; +import {pick, extend} from '../util/util'; -import { getJSON, ResourceType } from '../util/ajax'; +import {getJSON, ResourceType} from '../util/ajax'; import browser from '../util/browser'; import type {RequestManager} from '../util/mapbox'; diff --git a/src/source/query_features.js b/src/source/query_features.js index fa0cb9891d8..038690e0cdf 100644 --- a/src/source/query_features.js +++ b/src/source/query_features.js @@ -4,10 +4,10 @@ import type SourceCache from './source_cache'; import type StyleLayer from '../style/style_layer'; import type CollisionIndex from '../symbol/collision_index'; import type Transform from '../geo/transform'; -import type { RetainedQueryData } from '../symbol/placement'; +import type {RetainedQueryData} from '../symbol/placement'; import type {FilterSpecification} from '../style-spec/types'; import assert from 'assert'; -import { mat4 } from 'gl-matrix'; +import {mat4} from 'gl-matrix'; /* * Returns a matrix that can be used to convert from tile coordinates to viewport pixel coordinates. diff --git a/src/source/raster_dem_tile_source.js b/src/source/raster_dem_tile_source.js index 57e2ff61ebf..cfd735330e2 100644 --- a/src/source/raster_dem_tile_source.js +++ b/src/source/raster_dem_tile_source.js @@ -1,10 +1,10 @@ // @flow -import { getImage, ResourceType } from '../util/ajax'; -import { extend } from '../util/util'; -import { Evented } from '../util/evented'; +import {getImage, ResourceType} from '../util/ajax'; +import {extend} from '../util/util'; +import {Evented} from '../util/evented'; import browser from '../util/browser'; -import { OverscaledTileID } from './tile_id'; +import {OverscaledTileID} from './tile_id'; import RasterTileSource from './raster_tile_source'; // ensure DEMData is registered for worker transfer on main thread: import '../data/dem_data'; @@ -22,7 +22,7 @@ class RasterDEMTileSource extends RasterTileSource implements Source { super(id, options, dispatcher, eventedParent); this.type = 'raster-dem'; this.maxzoom = 22; - this._options = extend({ type: 'raster-dem' }, options); + this._options = extend({type: 'raster-dem'}, options); this.encoding = options.encoding || "mapbox"; } @@ -126,7 +126,7 @@ class RasterDEMTileSource extends RasterTileSource implements Source { tile.state = 'unloaded'; if (tile.actor) { - tile.actor.send('removeDEMTile', { uid: tile.uid, source: this.id }); + tile.actor.send('removeDEMTile', {uid: tile.uid, source: this.id}); } } diff --git a/src/source/raster_tile_source.js b/src/source/raster_tile_source.js index 564b46bc7c7..fa55b14722f 100644 --- a/src/source/raster_tile_source.js +++ b/src/source/raster_tile_source.js @@ -1,15 +1,15 @@ // @flow -import { extend, pick } from '../util/util'; +import {extend, pick} from '../util/util'; -import { getImage, ResourceType } from '../util/ajax'; -import { Event, ErrorEvent, Evented } from '../util/evented'; +import {getImage, ResourceType} from '../util/ajax'; +import {Event, ErrorEvent, Evented} from '../util/evented'; import loadTileJSON from './load_tilejson'; -import { postTurnstileEvent, postMapLoadEvent } from '../util/mapbox'; +import {postTurnstileEvent, postMapLoadEvent} from '../util/mapbox'; import TileBounds from './tile_bounds'; import Texture from '../render/texture'; -import { cacheEntryPossiblyAdded } from '../util/tile_request_cache'; +import {cacheEntryPossiblyAdded} from '../util/tile_request_cache'; import type {Source} from './source'; import type {OverscaledTileID} from './tile_id'; @@ -57,7 +57,7 @@ class RasterTileSource extends Evented implements Source { this.tileSize = 512; this._loaded = false; - this._options = extend({ type: 'raster' }, options); + this._options = extend({type: 'raster'}, options); extend(this, pick(options, ['url', 'scheme', 'tileSize'])); } @@ -129,9 +129,9 @@ class RasterTileSource extends Evented implements Source { const gl = context.gl; tile.texture = this.map.painter.getTileTexture(img.width); if (tile.texture) { - tile.texture.update(img, { useMipmap: true }); + tile.texture.update(img, {useMipmap: true}); } else { - tile.texture = new Texture(context, img, gl.RGBA, { useMipmap: true }); + tile.texture = new Texture(context, img, gl.RGBA, {useMipmap: true}); tile.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST); if (context.extTextureFilterAnisotropic) { diff --git a/src/source/rtl_text_plugin.js b/src/source/rtl_text_plugin.js index 66b53b31a0b..e2838ae37b4 100644 --- a/src/source/rtl_text_plugin.js +++ b/src/source/rtl_text_plugin.js @@ -1,6 +1,6 @@ // @flow -import { Event, Evented } from '../util/evented'; +import {Event, Evented} from '../util/evented'; import browser from '../util/browser'; let pluginRequested = false; @@ -18,7 +18,7 @@ export const registerForPluginAvailability = function( callback: (args: {pluginURL: string, completionCallback: CompletionCallback}) => void ) { if (pluginURL) { - callback({ pluginURL, completionCallback: _completionCallback}); + callback({pluginURL, completionCallback: _completionCallback}); } else { evented.once('pluginAvailable', callback); } @@ -48,7 +48,7 @@ export const setRTLTextPlugin = function(url: string, callback: ErrorCallback) { foregroundLoadComplete = true; } }; - evented.fire(new Event('pluginAvailable', { pluginURL, completionCallback: _completionCallback })); + evented.fire(new Event('pluginAvailable', {pluginURL, completionCallback: _completionCallback})); }; export const plugin: { diff --git a/src/source/source.js b/src/source/source.js index bea035c108e..92f2279ee42 100644 --- a/src/source/source.js +++ b/src/source/source.js @@ -1,6 +1,6 @@ // @flow -import { bindAll } from '../util/util'; +import {bindAll} from '../util/util'; import type Dispatcher from '../util/dispatcher'; import type {Event, Evented} from '../util/evented'; diff --git a/src/source/source_cache.js b/src/source/source_cache.js index a8b5af3b597..5ff70bdc4a5 100644 --- a/src/source/source_cache.js +++ b/src/source/source_cache.js @@ -1,17 +1,17 @@ // @flow -import { create as createSource } from './source'; +import {create as createSource} from './source'; import Tile from './tile'; -import { Event, ErrorEvent, Evented } from '../util/evented'; +import {Event, ErrorEvent, Evented} from '../util/evented'; import TileCache from './tile_cache'; import MercatorCoordinate from '../geo/mercator_coordinate'; -import { keysDifference } from '../util/util'; +import {keysDifference} from '../util/util'; import EXTENT from '../data/extent'; import Context from '../gl/context'; import Point from '@mapbox/point-geometry'; import browser from '../util/browser'; -import { OverscaledTileID } from './tile_id'; +import {OverscaledTileID} from './tile_id'; import assert from 'assert'; import SourceFeatureState from './source_state'; diff --git a/src/source/source_state.js b/src/source/source_state.js index 934dfacd046..e20851f5ad3 100644 --- a/src/source/source_state.js +++ b/src/source/source_state.js @@ -1,6 +1,6 @@ // @flow -import { extend } from '../util/util'; +import {extend} from '../util/util'; import Tile from './tile'; import type {FeatureState} from '../style-spec/expression'; diff --git a/src/source/tile.js b/src/source/tile.js index 2471331e70b..25075d29b61 100644 --- a/src/source/tile.js +++ b/src/source/tile.js @@ -1,18 +1,18 @@ // @flow -import { uniqueId, deepEqual, parseCacheControl } from '../util/util'; -import { deserialize as deserializeBucket } from '../data/bucket'; +import {uniqueId, deepEqual, parseCacheControl} from '../util/util'; +import {deserialize as deserializeBucket} from '../data/bucket'; import FeatureIndex from '../data/feature_index'; import GeoJSONFeature from '../util/vectortile_to_geojson'; import featureFilter from '../style-spec/feature_filter'; import SymbolBucket from '../data/bucket/symbol_bucket'; -import { RasterBoundsArray, CollisionBoxArray } from '../data/array_types'; +import {RasterBoundsArray, CollisionBoxArray} from '../data/array_types'; import rasterBoundsAttributes from '../data/raster_bounds_attributes'; import EXTENT from '../data/extent'; import Point from '@mapbox/point-geometry'; import Texture from '../render/texture'; import SegmentVector from '../data/segment'; -import { TriangleIndexArray } from '../data/index_array_type'; +import {TriangleIndexArray} from '../data/index_array_type'; import browser from '../util/browser'; import EvaluationParameters from '../style/evaluation_parameters'; import SourceFeatureState from '../source/source_state'; diff --git a/src/source/tile_cache.js b/src/source/tile_cache.js index 97d3b2de4c8..678105fa1f3 100644 --- a/src/source/tile_cache.js +++ b/src/source/tile_cache.js @@ -1,6 +1,6 @@ // @flow -import { OverscaledTileID } from './tile_id'; +import {OverscaledTileID} from './tile_id'; import type Tile from './tile'; /** diff --git a/src/source/tile_id.js b/src/source/tile_id.js index 824cbb4c258..16d06f97254 100644 --- a/src/source/tile_id.js +++ b/src/source/tile_id.js @@ -6,7 +6,7 @@ import Point from '@mapbox/point-geometry'; import MercatorCoordinate from '../geo/mercator_coordinate'; import assert from 'assert'; -import { register } from '../util/web_worker_transfer'; +import {register} from '../util/web_worker_transfer'; export class CanonicalTileID { z: number; diff --git a/src/source/vector_tile_source.js b/src/source/vector_tile_source.js index db0a3b49192..72af100985b 100644 --- a/src/source/vector_tile_source.js +++ b/src/source/vector_tile_source.js @@ -1,14 +1,14 @@ // @flow -import { Event, ErrorEvent, Evented } from '../util/evented'; +import {Event, ErrorEvent, Evented} from '../util/evented'; -import { extend, pick } from '../util/util'; +import {extend, pick} from '../util/util'; import loadTileJSON from './load_tilejson'; -import { postTurnstileEvent, postMapLoadEvent } from '../util/mapbox'; +import {postTurnstileEvent, postMapLoadEvent} from '../util/mapbox'; import TileBounds from './tile_bounds'; -import { ResourceType } from '../util/ajax'; +import {ResourceType} from '../util/ajax'; import browser from '../util/browser'; -import { cacheEntryPossiblyAdded } from '../util/tile_request_cache'; +import {cacheEntryPossiblyAdded} from '../util/tile_request_cache'; import type {Source} from './source'; import type {OverscaledTileID} from './tile_id'; @@ -55,7 +55,7 @@ class VectorTileSource extends Evented implements Source { this._loaded = false; extend(this, pick(options, ['url', 'scheme', 'tileSize'])); - this._options = extend({ type: 'vector' }, options); + this._options = extend({type: 'vector'}, options); this._collectResourceTiming = options.collectResourceTiming; @@ -171,14 +171,14 @@ class VectorTileSource extends Evented implements Source { delete tile.request; } if (tile.actor) { - tile.actor.send('abortTile', { uid: tile.uid, type: this.type, source: this.id }, undefined); + tile.actor.send('abortTile', {uid: tile.uid, type: this.type, source: this.id}, undefined); } } unloadTile(tile: Tile) { tile.unloadVectorData(); if (tile.actor) { - tile.actor.send('removeTile', { uid: tile.uid, type: this.type, source: this.id }, undefined); + tile.actor.send('removeTile', {uid: tile.uid, type: this.type, source: this.id}, undefined); } } diff --git a/src/source/vector_tile_worker_source.js b/src/source/vector_tile_worker_source.js index e49f6488449..dacec5b78c8 100644 --- a/src/source/vector_tile_worker_source.js +++ b/src/source/vector_tile_worker_source.js @@ -1,11 +1,11 @@ // @flow -import { getArrayBuffer } from '../util/ajax'; +import {getArrayBuffer} from '../util/ajax'; import vt from '@mapbox/vector-tile'; import Protobuf from 'pbf'; import WorkerTile from './worker_tile'; -import { extend } from '../util/util'; +import {extend} from '../util/util'; import performance from '../util/performance'; import type { diff --git a/src/source/video_source.js b/src/source/video_source.js index 7bf0e04be88..a6222fe8a3f 100644 --- a/src/source/video_source.js +++ b/src/source/video_source.js @@ -1,12 +1,12 @@ // @flow -import { getVideo, ResourceType } from '../util/ajax'; +import {getVideo, ResourceType} from '../util/ajax'; import ImageSource from './image_source'; import rasterBoundsAttributes from '../data/raster_bounds_attributes'; import SegmentVector from '../data/segment'; import Texture from '../render/texture'; -import { ErrorEvent } from '../util/evented'; +import {ErrorEvent} from '../util/evented'; import ValidationError from '../style-spec/error/validation_error'; import type Map from '../ui/map'; diff --git a/src/source/worker.js b/src/source/worker.js index f9951e283f2..310a30f6546 100644 --- a/src/source/worker.js +++ b/src/source/worker.js @@ -7,8 +7,8 @@ import VectorTileWorkerSource from './vector_tile_worker_source'; import RasterDEMTileWorkerSource from './raster_dem_tile_worker_source'; import GeoJSONWorkerSource from './geojson_worker_source'; import assert from 'assert'; -import { plugin as globalRTLTextPlugin } from './rtl_text_plugin'; -import { enforceCacheSizeLimit } from '../util/tile_request_cache'; +import {plugin as globalRTLTextPlugin} from './rtl_text_plugin'; +import {enforceCacheSizeLimit} from '../util/tile_request_cache'; import type { WorkerSource, diff --git a/src/source/worker_source.js b/src/source/worker_source.js index 8d44390eb53..c0b26deee20 100644 --- a/src/source/worker_source.js +++ b/src/source/worker_source.js @@ -2,15 +2,15 @@ import type {RequestParameters} from '../util/ajax'; import type {RGBAImage, AlphaImage} from '../util/image'; -import type { GlyphPositions } from '../render/glyph_atlas'; +import type {GlyphPositions} from '../render/glyph_atlas'; import type ImageAtlas from '../render/image_atlas'; import type {OverscaledTileID} from './tile_id'; import type {Bucket} from '../data/bucket'; import type FeatureIndex from '../data/feature_index'; import type {CollisionBoxArray} from '../data/array_types'; import type DEMData from '../data/dem_data'; -import type { StyleGlyph } from '../style/style_glyph'; -import type { StyleImage } from '../style/style_image'; +import type {StyleGlyph} from '../style/style_glyph'; +import type {StyleImage} from '../style/style_image'; export type TileParameters = { source: string, diff --git a/src/source/worker_tile.js b/src/source/worker_tile.js index cdd417897b7..c06fef5062b 100644 --- a/src/source/worker_tile.js +++ b/src/source/worker_tile.js @@ -2,19 +2,19 @@ import FeatureIndex from '../data/feature_index'; -import { performSymbolLayout } from '../symbol/symbol_layout'; -import { CollisionBoxArray } from '../data/array_types'; +import {performSymbolLayout} from '../symbol/symbol_layout'; +import {CollisionBoxArray} from '../data/array_types'; import DictionaryCoder from '../util/dictionary_coder'; import SymbolBucket from '../data/bucket/symbol_bucket'; import LineBucket from '../data/bucket/line_bucket'; import FillBucket from '../data/bucket/fill_bucket'; import FillExtrusionBucket from '../data/bucket/fill_extrusion_bucket'; -import { warnOnce, mapObject, values } from '../util/util'; +import {warnOnce, mapObject, values} from '../util/util'; import assert from 'assert'; import ImageAtlas from '../render/image_atlas'; import GlyphAtlas from '../render/glyph_atlas'; import EvaluationParameters from '../style/evaluation_parameters'; -import { OverscaledTileID } from './tile_id'; +import {OverscaledTileID} from './tile_id'; import type {Bucket} from '../data/bucket'; import type Actor from '../util/actor'; @@ -95,7 +95,7 @@ class WorkerTile { const features = []; for (let index = 0; index < sourceLayer.length; index++) { const feature = sourceLayer.feature(index); - features.push({ feature, index, sourceLayerIndex }); + features.push({feature, index, sourceLayerIndex}); } for (const family of layerFamilies[sourceLayerId]) { diff --git a/src/style-spec/diff.js b/src/style-spec/diff.js index ee036be6e0e..9228552e4b0 100644 --- a/src/style-spec/diff.js +++ b/src/style-spec/diff.js @@ -101,11 +101,11 @@ const operations = { }; function addSource(sourceId, after, commands) { - commands.push({ command: operations.addSource, args: [sourceId, after[sourceId]] }); + commands.push({command: operations.addSource, args: [sourceId, after[sourceId]]}); } function removeSource(sourceId, commands, sourcesRemoved) { - commands.push({ command: operations.removeSource, args: [sourceId] }); + commands.push({command: operations.removeSource, args: [sourceId]}); sourcesRemoved[sourceId] = true; } @@ -152,7 +152,7 @@ function diffSources(before, after, commands, sourcesRemoved) { addSource(sourceId, after, commands); } else if (!isEqual(before[sourceId], after[sourceId])) { if (before[sourceId].type === 'geojson' && after[sourceId].type === 'geojson' && canUpdateGeoJSON(before, after, sourceId)) { - commands.push({ command: operations.setGeoJSONSourceData, args: [sourceId, after[sourceId].data] }); + commands.push({command: operations.setGeoJSONSourceData, args: [sourceId, after[sourceId].data]}); } else { // no update command, must remove then add updateSource(sourceId, after, commands, sourcesRemoved); @@ -170,13 +170,13 @@ function diffLayerPropertyChanges(before, after, commands, layerId, klass, comma for (prop in before) { if (!before.hasOwnProperty(prop)) continue; if (!isEqual(before[prop], after[prop])) { - commands.push({ command, args: [layerId, prop, after[prop], klass] }); + commands.push({command, args: [layerId, prop, after[prop], klass]}); } } for (prop in after) { if (!after.hasOwnProperty(prop) || before.hasOwnProperty(prop)) continue; if (!isEqual(before[prop], after[prop])) { - commands.push({ command, args: [layerId, prop, after[prop], klass] }); + commands.push({command, args: [layerId, prop, after[prop], klass]}); } } } @@ -213,7 +213,7 @@ function diffLayers(before, after, commands) { for (i = 0, d = 0; i < beforeOrder.length; i++) { layerId = beforeOrder[i]; if (!afterIndex.hasOwnProperty(layerId)) { - commands.push({ command: operations.removeLayer, args: [layerId] }); + commands.push({command: operations.removeLayer, args: [layerId]}); tracker.splice(tracker.indexOf(layerId, d), 1); } else { // limit where in tracker we need to look for a match @@ -230,7 +230,7 @@ function diffLayers(before, after, commands) { if (beforeIndex.hasOwnProperty(layerId)) { // remove the layer before we insert at the correct position - commands.push({ command: operations.removeLayer, args: [layerId] }); + commands.push({command: operations.removeLayer, args: [layerId]}); tracker.splice(tracker.lastIndexOf(layerId, tracker.length - d), 1); } else { // limit where in tracker we need to look for a match @@ -239,7 +239,7 @@ function diffLayers(before, after, commands) { // add layer at correct position insertBeforeLayerId = tracker[tracker.length - i]; - commands.push({ command: operations.addLayer, args: [afterIndex[layerId], insertBeforeLayerId] }); + commands.push({command: operations.addLayer, args: [afterIndex[layerId], insertBeforeLayerId]}); tracker.splice(tracker.length - i, 0, layerId); clean[layerId] = true; } @@ -256,11 +256,11 @@ function diffLayers(before, after, commands) { // If source, source-layer, or type have changes, then remove the layer // and add it back 'from scratch'. if (!isEqual(beforeLayer.source, afterLayer.source) || !isEqual(beforeLayer['source-layer'], afterLayer['source-layer']) || !isEqual(beforeLayer.type, afterLayer.type)) { - commands.push({ command: operations.removeLayer, args: [layerId] }); + commands.push({command: operations.removeLayer, args: [layerId]}); // we add the layer back at the same position it was already in, so // there's no need to update the `tracker` insertBeforeLayerId = tracker[tracker.lastIndexOf(layerId) + 1]; - commands.push({ command: operations.addLayer, args: [afterLayer, insertBeforeLayerId] }); + commands.push({command: operations.addLayer, args: [afterLayer, insertBeforeLayerId]}); continue; } @@ -268,10 +268,10 @@ function diffLayers(before, after, commands) { diffLayerPropertyChanges(beforeLayer.layout, afterLayer.layout, commands, layerId, null, operations.setLayoutProperty); diffLayerPropertyChanges(beforeLayer.paint, afterLayer.paint, commands, layerId, null, operations.setPaintProperty); if (!isEqual(beforeLayer.filter, afterLayer.filter)) { - commands.push({ command: operations.setFilter, args: [layerId, afterLayer.filter] }); + commands.push({command: operations.setFilter, args: [layerId, afterLayer.filter]}); } if (!isEqual(beforeLayer.minzoom, afterLayer.minzoom) || !isEqual(beforeLayer.maxzoom, afterLayer.maxzoom)) { - commands.push({ command: operations.setLayerZoomRange, args: [layerId, afterLayer.minzoom, afterLayer.maxzoom] }); + commands.push({command: operations.setLayerZoomRange, args: [layerId, afterLayer.minzoom, afterLayer.maxzoom]}); } // handle all other layer props, including paint.* @@ -282,7 +282,7 @@ function diffLayers(before, after, commands) { if (prop.indexOf('paint.') === 0) { diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), operations.setPaintProperty); } else if (!isEqual(beforeLayer[prop], afterLayer[prop])) { - commands.push({ command: operations.setLayerProperty, args: [layerId, prop, afterLayer[prop]] }); + commands.push({command: operations.setLayerProperty, args: [layerId, prop, afterLayer[prop]]}); } } for (prop in afterLayer) { @@ -292,7 +292,7 @@ function diffLayers(before, after, commands) { if (prop.indexOf('paint.') === 0) { diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), operations.setPaintProperty); } else if (!isEqual(beforeLayer[prop], afterLayer[prop])) { - commands.push({ command: operations.setLayerProperty, args: [layerId, prop, afterLayer[prop]] }); + commands.push({command: operations.setLayerProperty, args: [layerId, prop, afterLayer[prop]]}); } } } @@ -317,38 +317,38 @@ function diffLayers(before, after, commands) { * @returns Array list of changes */ function diffStyles(before, after) { - if (!before) return [{ command: operations.setStyle, args: [after] }]; + if (!before) return [{command: operations.setStyle, args: [after]}]; let commands = []; try { // Handle changes to top-level properties if (!isEqual(before.version, after.version)) { - return [{ command: operations.setStyle, args: [after] }]; + return [{command: operations.setStyle, args: [after]}]; } if (!isEqual(before.center, after.center)) { - commands.push({ command: operations.setCenter, args: [after.center] }); + commands.push({command: operations.setCenter, args: [after.center]}); } if (!isEqual(before.zoom, after.zoom)) { - commands.push({ command: operations.setZoom, args: [after.zoom] }); + commands.push({command: operations.setZoom, args: [after.zoom]}); } if (!isEqual(before.bearing, after.bearing)) { - commands.push({ command: operations.setBearing, args: [after.bearing] }); + commands.push({command: operations.setBearing, args: [after.bearing]}); } if (!isEqual(before.pitch, after.pitch)) { - commands.push({ command: operations.setPitch, args: [after.pitch] }); + commands.push({command: operations.setPitch, args: [after.pitch]}); } if (!isEqual(before.sprite, after.sprite)) { - commands.push({ command: operations.setSprite, args: [after.sprite] }); + commands.push({command: operations.setSprite, args: [after.sprite]}); } if (!isEqual(before.glyphs, after.glyphs)) { - commands.push({ command: operations.setGlyphs, args: [after.glyphs] }); + commands.push({command: operations.setGlyphs, args: [after.glyphs]}); } if (!isEqual(before.transition, after.transition)) { - commands.push({ command: operations.setTransition, args: [after.transition] }); + commands.push({command: operations.setTransition, args: [after.transition]}); } if (!isEqual(before.light, after.light)) { - commands.push({ command: operations.setLight, args: [after.light] }); + commands.push({command: operations.setLight, args: [after.light]}); } // Handle changes to `sources` @@ -369,7 +369,7 @@ function diffStyles(before, after) { if (before.layers) { before.layers.forEach((layer) => { if (sourcesRemoved[layer.source]) { - commands.push({ command: operations.removeLayer, args: [layer.id] }); + commands.push({command: operations.removeLayer, args: [layer.id]}); } else { beforeLayers.push(layer); } @@ -383,11 +383,11 @@ function diffStyles(before, after) { } catch (e) { // fall back to setStyle console.warn('Unable to compute style diff:', e); - commands = [{ command: operations.setStyle, args: [after] }]; + commands = [{command: operations.setStyle, args: [after]}]; } return commands; } export default diffStyles; -export { operations }; +export {operations}; diff --git a/src/style-spec/expression/compound_expression.js b/src/style-spec/expression/compound_expression.js index a952c159942..5240cba251e 100644 --- a/src/style-spec/expression/compound_expression.js +++ b/src/style-spec/expression/compound_expression.js @@ -1,14 +1,14 @@ // @flow -import { toString } from './types'; +import {toString} from './types'; import ParsingContext from './parsing_context'; import EvaluationContext from './evaluation_context'; import assert from 'assert'; -import type { Expression, ExpressionRegistry } from './expression'; -import type { Type } from './types'; -import type { Value } from './values'; +import type {Expression, ExpressionRegistry} from './expression'; +import type {Type} from './types'; +import type {Value} from './values'; export type Varargs = {| type: Type |}; type Signature = Array | Varargs; diff --git a/src/style-spec/expression/definitions/assertion.js b/src/style-spec/expression/definitions/assertion.js index 9e4cf05b90d..4e413597a57 100644 --- a/src/style-spec/expression/definitions/assertion.js +++ b/src/style-spec/expression/definitions/assertion.js @@ -13,13 +13,13 @@ import { array } from '../types'; import RuntimeError from '../runtime_error'; -import { typeOf } from '../values'; +import {typeOf} from '../values'; -import type { Expression } from '../expression'; +import type {Expression} from '../expression'; import type ParsingContext from '../parsing_context'; import type EvaluationContext from '../evaluation_context'; -import type { Value } from '../values'; -import type { Type } from '../types'; +import type {Value} from '../values'; +import type {Type} from '../types'; const types = { string: StringType, diff --git a/src/style-spec/expression/definitions/at.js b/src/style-spec/expression/definitions/at.js index a3dc12f8cd3..8a31b1fa88a 100644 --- a/src/style-spec/expression/definitions/at.js +++ b/src/style-spec/expression/definitions/at.js @@ -1,14 +1,14 @@ // @flow -import { array, ValueType, NumberType } from '../types'; +import {array, ValueType, NumberType} from '../types'; import RuntimeError from '../runtime_error'; -import type { Expression } from '../expression'; +import type {Expression} from '../expression'; import type ParsingContext from '../parsing_context'; import type EvaluationContext from '../evaluation_context'; -import type { Type, ArrayType } from '../types'; -import type { Value } from '../values'; +import type {Type, ArrayType} from '../types'; +import type {Value} from '../values'; class At implements Expression { type: Type; diff --git a/src/style-spec/expression/definitions/case.js b/src/style-spec/expression/definitions/case.js index 0ba66d88a5a..f952e828306 100644 --- a/src/style-spec/expression/definitions/case.js +++ b/src/style-spec/expression/definitions/case.js @@ -2,13 +2,13 @@ import assert from 'assert'; -import { BooleanType } from '../types'; +import {BooleanType} from '../types'; -import type { Expression } from '../expression'; +import type {Expression} from '../expression'; import type ParsingContext from '../parsing_context'; import type EvaluationContext from '../evaluation_context'; -import type { Value } from '../values'; -import type { Type } from '../types'; +import type {Value} from '../values'; +import type {Type} from '../types'; type Branches = Array<[Expression, Expression]>; diff --git a/src/style-spec/expression/definitions/coalesce.js b/src/style-spec/expression/definitions/coalesce.js index bec8bce86fa..5d0c82cf3dd 100644 --- a/src/style-spec/expression/definitions/coalesce.js +++ b/src/style-spec/expression/definitions/coalesce.js @@ -2,13 +2,13 @@ import assert from 'assert'; -import { checkSubtype, ValueType } from '../types'; +import {checkSubtype, ValueType} from '../types'; -import type { Expression } from '../expression'; +import type {Expression} from '../expression'; import type ParsingContext from '../parsing_context'; import type EvaluationContext from '../evaluation_context'; -import type { Value } from '../values'; -import type { Type } from '../types'; +import type {Value} from '../values'; +import type {Type} from '../types'; class Coalesce implements Expression { type: Type; diff --git a/src/style-spec/expression/definitions/coercion.js b/src/style-spec/expression/definitions/coercion.js index 6065194900d..e6c2e9f81e7 100644 --- a/src/style-spec/expression/definitions/coercion.js +++ b/src/style-spec/expression/definitions/coercion.js @@ -8,11 +8,11 @@ import RuntimeError from '../runtime_error'; import Formatted from '../types/formatted'; import FormatExpression from '../definitions/format'; -import type { Expression } from '../expression'; +import type {Expression} from '../expression'; import type ParsingContext from '../parsing_context'; import type EvaluationContext from '../evaluation_context'; -import type { Value } from '../values'; -import type { Type } from '../types'; +import type {Value} from '../values'; +import type {Type} from '../types'; const types = { 'to-boolean': BooleanType, diff --git a/src/style-spec/expression/definitions/collator.js b/src/style-spec/expression/definitions/collator.js index 6cbeb2b0df3..0dde79f2088 100644 --- a/src/style-spec/expression/definitions/collator.js +++ b/src/style-spec/expression/definitions/collator.js @@ -1,12 +1,12 @@ // @flow -import { StringType, BooleanType, CollatorType } from '../types'; +import {StringType, BooleanType, CollatorType} from '../types'; import Collator from '../types/collator'; -import type { Expression } from '../expression'; +import type {Expression} from '../expression'; import type EvaluationContext from '../evaluation_context'; import type ParsingContext from '../parsing_context'; -import type { Type } from '../types'; +import type {Type} from '../types'; export default class CollatorExpression implements Expression { type: Type; diff --git a/src/style-spec/expression/definitions/comparison.js b/src/style-spec/expression/definitions/comparison.js index e7c2460e54b..89524278ffb 100644 --- a/src/style-spec/expression/definitions/comparison.js +++ b/src/style-spec/expression/definitions/comparison.js @@ -1,14 +1,14 @@ // @flow -import { toString, ValueType, BooleanType, CollatorType } from '../types'; +import {toString, ValueType, BooleanType, CollatorType} from '../types'; import Assertion from './assertion'; -import { typeOf } from '../values'; +import {typeOf} from '../values'; import RuntimeError from '../runtime_error'; -import type { Expression } from '../expression'; +import type {Expression} from '../expression'; import type EvaluationContext from '../evaluation_context'; import type ParsingContext from '../parsing_context'; -import type { Type } from '../types'; +import type {Type} from '../types'; type ComparisonOperator = '==' | '!=' | '<' | '>' | '<=' | '>=' ; diff --git a/src/style-spec/expression/definitions/format.js b/src/style-spec/expression/definitions/format.js index 4feece22ac7..6d9694cbe21 100644 --- a/src/style-spec/expression/definitions/format.js +++ b/src/style-spec/expression/definitions/format.js @@ -1,13 +1,13 @@ // @flow -import { NumberType, ValueType, FormattedType, array, StringType, ColorType } from '../types'; -import Formatted, { FormattedSection } from '../types/formatted'; -import { toString } from '../values'; +import {NumberType, ValueType, FormattedType, array, StringType, ColorType} from '../types'; +import Formatted, {FormattedSection} from '../types/formatted'; +import {toString} from '../values'; -import type { Expression } from '../expression'; +import type {Expression} from '../expression'; import type EvaluationContext from '../evaluation_context'; import type ParsingContext from '../parsing_context'; -import type { Type } from '../types'; +import type {Type} from '../types'; type FormattedSectionExpression = { text: Expression, diff --git a/src/style-spec/expression/definitions/format_section_override.js b/src/style-spec/expression/definitions/format_section_override.js index 3efd155d2fe..489389cbb03 100644 --- a/src/style-spec/expression/definitions/format_section_override.js +++ b/src/style-spec/expression/definitions/format_section_override.js @@ -1,14 +1,14 @@ // @flow import assert from 'assert'; -import type { Expression } from '../expression'; +import type {Expression} from '../expression'; import type EvaluationContext from '../evaluation_context'; -import type { Value } from '../values'; -import type { Type } from '../types'; -import type { ZoomConstantExpression } from '../../expression'; -import { NullType } from '../types'; -import { PossiblyEvaluatedPropertyValue } from '../../../style/properties'; -import { register } from '../../../util/web_worker_transfer'; +import type {Value} from '../values'; +import type {Type} from '../types'; +import type {ZoomConstantExpression} from '../../expression'; +import {NullType} from '../types'; +import {PossiblyEvaluatedPropertyValue} from '../../../style/properties'; +import {register} from '../../../util/web_worker_transfer'; export default class FormatSectionOverride implements Expression { type: Type; diff --git a/src/style-spec/expression/definitions/index.js b/src/style-spec/expression/definitions/index.js index af32c11d37f..455d00d55f9 100644 --- a/src/style-spec/expression/definitions/index.js +++ b/src/style-spec/expression/definitions/index.js @@ -14,7 +14,7 @@ import { toString as typeToString } from '../types'; -import { typeOf, Color, validateRGBA, toString as valueToString } from '../values'; +import {typeOf, Color, validateRGBA, toString as valueToString} from '../values'; import CompoundExpression from '../compound_expression'; import RuntimeError from '../runtime_error'; import Let from './let'; @@ -41,8 +41,8 @@ import NumberFormat from './number_format'; import FormatExpression from './format'; import Length from './length'; -import type { Varargs } from '../compound_expression'; -import type { ExpressionRegistry } from '../expression'; +import type {Varargs} from '../compound_expression'; +import type {ExpressionRegistry} from '../expression'; const expressions: ExpressionRegistry = { // special forms @@ -111,7 +111,7 @@ function binarySearch(v, a, i, j) { } function varargs(type: Type): Varargs { - return { type }; + return {type}; } CompoundExpression.register(expressions, { diff --git a/src/style-spec/expression/definitions/interpolate.js b/src/style-spec/expression/definitions/interpolate.js index 88a10d74845..53c23d8d135 100644 --- a/src/style-spec/expression/definitions/interpolate.js +++ b/src/style-spec/expression/definitions/interpolate.js @@ -3,16 +3,16 @@ import UnitBezier from '@mapbox/unitbezier'; import * as interpolate from '../../util/interpolate'; -import { toString, NumberType, ColorType } from '../types'; -import { findStopLessThanOrEqualTo } from '../stops'; -import { hcl, lab } from '../../util/color_spaces'; +import {toString, NumberType, ColorType} from '../types'; +import {findStopLessThanOrEqualTo} from '../stops'; +import {hcl, lab} from '../../util/color_spaces'; -import type { Stops } from '../stops'; -import type { Expression } from '../expression'; +import type {Stops} from '../stops'; +import type {Expression} from '../expression'; import type ParsingContext from '../parsing_context'; import type EvaluationContext from '../evaluation_context'; -import type { Value } from '../values'; -import type { Type } from '../types'; +import type {Value} from '../values'; +import type {Type} from '../types'; export type InterpolationType = { name: 'linear' } | @@ -64,7 +64,7 @@ class Interpolate implements Expression { } if (interpolation[0] === 'linear') { - interpolation = { name: 'linear' }; + interpolation = {name: 'linear'}; } else if (interpolation[0] === 'exponential') { const base = interpolation[1]; if (typeof base !== 'number') diff --git a/src/style-spec/expression/definitions/length.js b/src/style-spec/expression/definitions/length.js index 1079fff7ed3..c06325d3b8a 100644 --- a/src/style-spec/expression/definitions/length.js +++ b/src/style-spec/expression/definitions/length.js @@ -1,14 +1,14 @@ // @flow -import { NumberType, toString } from '../types'; +import {NumberType, toString} from '../types'; -import { typeOf } from '../values'; +import {typeOf} from '../values'; import RuntimeError from '../runtime_error'; -import type { Expression } from '../expression'; +import type {Expression} from '../expression'; import type ParsingContext from '../parsing_context'; import type EvaluationContext from '../evaluation_context'; -import type { Type } from '../types'; +import type {Type} from '../types'; class Length implements Expression { type: Type; diff --git a/src/style-spec/expression/definitions/let.js b/src/style-spec/expression/definitions/let.js index d34c325e673..fc50cac8281 100644 --- a/src/style-spec/expression/definitions/let.js +++ b/src/style-spec/expression/definitions/let.js @@ -1,7 +1,7 @@ // @flow -import type { Type } from '../types'; -import type { Expression } from '../expression'; +import type {Type} from '../types'; +import type {Expression} from '../expression'; import type ParsingContext from '../parsing_context'; import type EvaluationContext from '../evaluation_context'; diff --git a/src/style-spec/expression/definitions/literal.js b/src/style-spec/expression/definitions/literal.js index dc8db151c7b..5bc9578aee5 100644 --- a/src/style-spec/expression/definitions/literal.js +++ b/src/style-spec/expression/definitions/literal.js @@ -1,12 +1,12 @@ // @flow import assert from 'assert'; -import { isValue, typeOf, Color } from '../values'; +import {isValue, typeOf, Color} from '../values'; import Formatted from '../types/formatted'; -import type { Type } from '../types'; -import type { Value } from '../values'; -import type { Expression } from '../expression'; +import type {Type} from '../types'; +import type {Value} from '../values'; +import type {Expression} from '../expression'; import type ParsingContext from '../parsing_context'; class Literal implements Expression { diff --git a/src/style-spec/expression/definitions/match.js b/src/style-spec/expression/definitions/match.js index 7d78b671ad9..9a3474ad4d0 100644 --- a/src/style-spec/expression/definitions/match.js +++ b/src/style-spec/expression/definitions/match.js @@ -2,13 +2,13 @@ import assert from 'assert'; -import { typeOf } from '../values'; -import { ValueType, type Type } from '../types'; +import {typeOf} from '../values'; +import {ValueType, type Type} from '../types'; -import type { Expression } from '../expression'; +import type {Expression} from '../expression'; import type ParsingContext from '../parsing_context'; import type EvaluationContext from '../evaluation_context'; -import type { Value } from '../values'; +import type {Value} from '../values'; // Map input label values to output expression index type Cases = {[number | string]: number}; diff --git a/src/style-spec/expression/definitions/number_format.js b/src/style-spec/expression/definitions/number_format.js index 0579a921858..747c556ef9f 100644 --- a/src/style-spec/expression/definitions/number_format.js +++ b/src/style-spec/expression/definitions/number_format.js @@ -1,11 +1,11 @@ // @flow -import { StringType, NumberType } from '../types'; +import {StringType, NumberType} from '../types'; -import type { Expression } from '../expression'; +import type {Expression} from '../expression'; import type EvaluationContext from '../evaluation_context'; import type ParsingContext from '../parsing_context'; -import type { Type } from '../types'; +import type {Type} from '../types'; declare var Intl: { NumberFormat: Class diff --git a/src/style-spec/expression/definitions/step.js b/src/style-spec/expression/definitions/step.js index afc5b226323..a077ae364ee 100644 --- a/src/style-spec/expression/definitions/step.js +++ b/src/style-spec/expression/definitions/step.js @@ -1,15 +1,15 @@ // @flow -import { NumberType } from '../types'; +import {NumberType} from '../types'; -import { findStopLessThanOrEqualTo } from '../stops'; +import {findStopLessThanOrEqualTo} from '../stops'; -import type { Stops } from '../stops'; -import type { Expression } from '../expression'; +import type {Stops} from '../stops'; +import type {Expression} from '../expression'; import type ParsingContext from '../parsing_context'; import type EvaluationContext from '../evaluation_context'; -import type { Value } from '../values'; -import type { Type } from '../types'; +import type {Value} from '../values'; +import type {Type} from '../types'; class Step implements Expression { type: Type; diff --git a/src/style-spec/expression/definitions/var.js b/src/style-spec/expression/definitions/var.js index 0c601adb28a..a06760631a6 100644 --- a/src/style-spec/expression/definitions/var.js +++ b/src/style-spec/expression/definitions/var.js @@ -1,7 +1,7 @@ // @flow -import type { Type } from '../types'; -import type { Expression } from '../expression'; +import type {Type} from '../types'; +import type {Expression} from '../expression'; import type ParsingContext from '../parsing_context'; import type EvaluationContext from '../evaluation_context'; diff --git a/src/style-spec/expression/evaluation_context.js b/src/style-spec/expression/evaluation_context.js index 4b1bfc39a86..a37478c71c0 100644 --- a/src/style-spec/expression/evaluation_context.js +++ b/src/style-spec/expression/evaluation_context.js @@ -1,8 +1,8 @@ // @flow -import { Color } from './values'; -import type { FormattedSection } from './types/formatted'; -import type { GlobalProperties, Feature, FeatureState } from './index'; +import {Color} from './values'; +import type {FormattedSection} from './types/formatted'; +import type {GlobalProperties, Feature, FeatureState} from './index'; const geometryTypes = ['Unknown', 'Point', 'LineString', 'Polygon']; diff --git a/src/style-spec/expression/index.js b/src/style-spec/expression/index.js index 591e62f8d72..9c203d22cc1 100644 --- a/src/style-spec/expression/index.js +++ b/src/style-spec/expression/index.js @@ -14,8 +14,8 @@ import Let from './definitions/let'; import definitions from './definitions'; import * as isConstant from './is_constant'; import RuntimeError from './runtime_error'; -import { success, error } from '../util/result'; -import { supportsPropertyExpression, supportsZoomExpression, supportsInterpolation } from '../util/properties'; +import {success, error} from '../util/result'; +import {supportsPropertyExpression, supportsZoomExpression, supportsInterpolation} from '../util/properties'; import type {Type, EvaluationKind} from './types'; import type {Value} from './values'; @@ -251,8 +251,8 @@ export function createPropertyExpression(expression: mixed, propertySpec: StyleP (new ZoomDependentExpression('composite', expression.value, zoomCurve.labels, interpolationType): CompositeExpression)); } -import { isFunction, createFunction } from '../function'; -import { Color } from './values'; +import {isFunction, createFunction} from '../function'; +import {Color} from './values'; // serialization wrapper for old-style stop functions normalized to the // expression interface @@ -348,7 +348,7 @@ function findZoomCurve(expression: Expression): Step | Interpolate | ParsingErro return result; } -import { ColorType, StringType, NumberType, BooleanType, ValueType, FormattedType, array } from './types'; +import {ColorType, StringType, NumberType, BooleanType, ValueType, FormattedType, array} from './types'; function getExpectedType(spec: StylePropertySpecification): Type { const types = { diff --git a/src/style-spec/expression/is_constant.js b/src/style-spec/expression/is_constant.js index 5eae4325e44..92e7ab24be2 100644 --- a/src/style-spec/expression/is_constant.js +++ b/src/style-spec/expression/is_constant.js @@ -2,7 +2,7 @@ import CompoundExpression from './compound_expression'; -import type { Expression } from './expression.js'; +import type {Expression} from './expression.js'; function isFeatureConstant(e: Expression) { if (e instanceof CompoundExpression) { @@ -52,4 +52,4 @@ function isGlobalPropertyConstant(e: Expression, properties: Array) { return result; } -export { isFeatureConstant, isGlobalPropertyConstant, isStateConstant }; +export {isFeatureConstant, isGlobalPropertyConstant, isStateConstant}; diff --git a/src/style-spec/expression/parsing_context.js b/src/style-spec/expression/parsing_context.js index 728407a72d3..2c7623e11e1 100644 --- a/src/style-spec/expression/parsing_context.js +++ b/src/style-spec/expression/parsing_context.js @@ -1,7 +1,7 @@ // @flow import Scope from './scope'; -import { checkSubtype } from './types'; +import {checkSubtype} from './types'; import ParsingError from './parsing_error'; import Literal from './definitions/literal'; import Assertion from './definitions/assertion'; diff --git a/src/style-spec/expression/stops.js b/src/style-spec/expression/stops.js index 22941ff20bb..770ab4acfba 100644 --- a/src/style-spec/expression/stops.js +++ b/src/style-spec/expression/stops.js @@ -2,7 +2,7 @@ import RuntimeError from './runtime_error'; -import type { Expression } from './expression'; +import type {Expression} from './expression'; export type Stops = Array<[number, Expression]>; diff --git a/src/style-spec/expression/types.js b/src/style-spec/expression/types.js index 1956102590a..1e209cbfb4f 100644 --- a/src/style-spec/expression/types.js +++ b/src/style-spec/expression/types.js @@ -32,16 +32,16 @@ export type ArrayType = { N: ?number } -export const NullType = { kind: 'null' }; -export const NumberType = { kind: 'number' }; -export const StringType = { kind: 'string' }; -export const BooleanType = { kind: 'boolean' }; -export const ColorType = { kind: 'color' }; -export const ObjectType = { kind: 'object' }; -export const ValueType = { kind: 'value' }; -export const ErrorType = { kind: 'error' }; -export const CollatorType = { kind: 'collator' }; -export const FormattedType = { kind: 'formatted' }; +export const NullType = {kind: 'null'}; +export const NumberType = {kind: 'number'}; +export const StringType = {kind: 'string'}; +export const BooleanType = {kind: 'boolean'}; +export const ColorType = {kind: 'color'}; +export const ObjectType = {kind: 'object'}; +export const ValueType = {kind: 'value'}; +export const ErrorType = {kind: 'error'}; +export const CollatorType = {kind: 'collator'}; +export const FormattedType = {kind: 'formatted'}; export function array(itemType: Type, N: ?number): ArrayType { return { diff --git a/src/style-spec/expression/types/collator.js b/src/style-spec/expression/types/collator.js index 40e80ec3214..c9bcd61589f 100644 --- a/src/style-spec/expression/types/collator.js +++ b/src/style-spec/expression/types/collator.js @@ -45,7 +45,7 @@ export default class Collator { this.locale = locale; this.collator = new Intl.Collator(this.locale ? this.locale : [], - { sensitivity: this.sensitivity, usage: 'search' }); + {sensitivity: this.sensitivity, usage: 'search'}); } compare(lhs: string, rhs: string): number { diff --git a/src/style-spec/expression/values.js b/src/style-spec/expression/values.js index 3f8b5c874c2..f3ccc080bbc 100644 --- a/src/style-spec/expression/values.js +++ b/src/style-spec/expression/values.js @@ -5,9 +5,9 @@ import assert from 'assert'; import Color from '../util/color'; import Collator from './types/collator'; import Formatted from './types/formatted'; -import { NullType, NumberType, StringType, BooleanType, ColorType, ObjectType, ValueType, CollatorType, FormattedType, array } from './types'; +import {NullType, NumberType, StringType, BooleanType, ColorType, ObjectType, ValueType, CollatorType, FormattedType, array} from './types'; -import type { Type } from './types'; +import type {Type} from './types'; export function validateRGBA(r: mixed, g: mixed, b: mixed, a?: mixed): ?string { if (!( @@ -115,4 +115,4 @@ export function toString(value: Value) { } } -export { Color, Collator }; +export {Color, Collator}; diff --git a/src/style-spec/feature_filter/convert.js b/src/style-spec/feature_filter/convert.js index 3a863bc6871..36bbee75a14 100644 --- a/src/style-spec/feature_filter/convert.js +++ b/src/style-spec/feature_filter/convert.js @@ -1,8 +1,8 @@ // @flow -import { isExpressionFilter } from './index'; +import {isExpressionFilter} from './index'; -import type { FilterSpecification } from '../types'; +import type {FilterSpecification} from '../types'; type ExpectedTypes = {[string]: 'string' | 'number' | 'boolean'}; diff --git a/src/style-spec/feature_filter/index.js b/src/style-spec/feature_filter/index.js index 4705a078e17..c3f45a2dfb1 100644 --- a/src/style-spec/feature_filter/index.js +++ b/src/style-spec/feature_filter/index.js @@ -1,12 +1,12 @@ // @flow -import { createExpression } from '../expression'; +import {createExpression} from '../expression'; import type {GlobalProperties} from '../expression'; export type FeatureFilter = (globalProperties: GlobalProperties, feature: VectorTileFeature) => boolean; export default createFilter; -export { isExpressionFilter }; +export {isExpressionFilter}; function isExpressionFilter(filter: any) { if (filter === true || filter === false) { diff --git a/src/style-spec/function/index.js b/src/style-spec/function/index.js index c8b6f17b30b..6ef3bc32b3d 100644 --- a/src/style-spec/function/index.js +++ b/src/style-spec/function/index.js @@ -6,8 +6,8 @@ import getType from '../util/get_type'; import * as interpolate from '../util/interpolate'; import Interpolate from '../expression/definitions/interpolate'; import Formatted from '../expression/types/formatted'; -import { supportsInterpolation } from '../util/properties'; -import { findStopLessThanOrEqualTo } from '../expression/stops'; +import {supportsInterpolation} from '../util/properties'; +import {findStopLessThanOrEqualTo} from '../expression/stops'; export function isFunction(value) { return typeof value === 'object' && value !== null && !Array.isArray(value); diff --git a/src/style-spec/migrate/expressions.js b/src/style-spec/migrate/expressions.js index 09c223de57e..544e6d15d06 100644 --- a/src/style-spec/migrate/expressions.js +++ b/src/style-spec/migrate/expressions.js @@ -4,11 +4,11 @@ import { eachLayer, eachProperty } from '../visit'; -import { isExpression } from '../expression'; +import {isExpression} from '../expression'; import convertFunction, {convertTokenString} from '../function/convert'; import convertFilter from '../feature_filter/convert'; -import type { StyleSpecification } from '../types'; +import type {StyleSpecification} from '../types'; /** * Migrate the given style object in place to use expressions. Specifically, diff --git a/src/style-spec/style-spec.js b/src/style-spec/style-spec.js index 8dfa885b869..19e55821168 100644 --- a/src/style-spec/style-spec.js +++ b/src/style-spec/style-spec.js @@ -67,13 +67,13 @@ import composite from './composite'; import diff from './diff'; import ValidationError from './error/validation_error'; import ParsingError from './error/parsing_error'; -import { StyleExpression, isExpression, createExpression, createPropertyExpression, normalizePropertyExpression, ZoomConstantExpression, ZoomDependentExpression, StylePropertyFunction } from './expression'; +import {StyleExpression, isExpression, createExpression, createPropertyExpression, normalizePropertyExpression, ZoomConstantExpression, ZoomDependentExpression, StylePropertyFunction} from './expression'; import featureFilter from './feature_filter'; import convertFilter from './feature_filter/convert'; import Color from './util/color'; -import { createFunction, isFunction } from './function'; +import {createFunction, isFunction} from './function'; import convertFunction from './function/convert'; -import { eachSource, eachLayer, eachProperty } from './visit'; +import {eachSource, eachLayer, eachProperty} from './visit'; import validate from './validate_style'; @@ -94,7 +94,7 @@ const styleFunction = { isFunction }; -const visit = { eachSource, eachLayer, eachProperty }; +const visit = {eachSource, eachLayer, eachProperty}; export { v8, diff --git a/src/style-spec/util/color.js b/src/style-spec/util/color.js index 6b1f88fed36..57e56165dd3 100644 --- a/src/style-spec/util/color.js +++ b/src/style-spec/util/color.js @@ -1,6 +1,6 @@ // @flow -import { parseCSSColor } from 'csscolorparser'; +import {parseCSSColor} from 'csscolorparser'; /** * An RGBA color value. Create instances from color strings using the static diff --git a/src/style-spec/util/result.js b/src/style-spec/util/result.js index b366f961965..9d0d3a6c4f7 100644 --- a/src/style-spec/util/result.js +++ b/src/style-spec/util/result.js @@ -11,9 +11,9 @@ export type Result = | {| result: 'error', value: E |}; export function success(value: T): Result { - return { result: 'success', value }; + return {result: 'success', value}; } export function error(value: E): Result { - return { result: 'error', value }; + return {result: 'error', value}; } diff --git a/src/style-spec/validate/validate.js b/src/style-spec/validate/validate.js index 76958cb0928..f9468cc458f 100644 --- a/src/style-spec/validate/validate.js +++ b/src/style-spec/validate/validate.js @@ -1,8 +1,8 @@ import extend from '../util/extend'; -import { unbundle, deepUnbundle } from '../util/unbundle_jsonlint'; -import { isExpression } from '../expression'; -import { isFunction } from '../function'; +import {unbundle, deepUnbundle} from '../util/unbundle_jsonlint'; +import {isExpression} from '../expression'; +import {isFunction} from '../function'; import validateFunction from './validate_function'; import validateExpression from './validate_expression'; diff --git a/src/style-spec/validate/validate_color.js b/src/style-spec/validate/validate_color.js index eedd924b79c..f0e935aada5 100644 --- a/src/style-spec/validate/validate_color.js +++ b/src/style-spec/validate/validate_color.js @@ -1,7 +1,7 @@ import ValidationError from '../error/validation_error'; import getType from '../util/get_type'; -import { parseCSSColor } from 'csscolorparser'; +import {parseCSSColor} from 'csscolorparser'; export default function validateColor(options) { const key = options.key; diff --git a/src/style-spec/validate/validate_enum.js b/src/style-spec/validate/validate_enum.js index 5d23392f361..655830c96ab 100644 --- a/src/style-spec/validate/validate_enum.js +++ b/src/style-spec/validate/validate_enum.js @@ -1,6 +1,6 @@ import ValidationError from '../error/validation_error'; -import { unbundle } from '../util/unbundle_jsonlint'; +import {unbundle} from '../util/unbundle_jsonlint'; export default function validateEnum(options) { const key = options.key; diff --git a/src/style-spec/validate/validate_expression.js b/src/style-spec/validate/validate_expression.js index d30e85a4ba6..573a9ac3d02 100644 --- a/src/style-spec/validate/validate_expression.js +++ b/src/style-spec/validate/validate_expression.js @@ -2,9 +2,9 @@ import ValidationError from '../error/validation_error'; -import { createExpression, createPropertyExpression } from '../expression'; -import { deepUnbundle } from '../util/unbundle_jsonlint'; -import { isStateConstant, isGlobalPropertyConstant, isFeatureConstant } from '../expression/is_constant'; +import {createExpression, createPropertyExpression} from '../expression'; +import {deepUnbundle} from '../util/unbundle_jsonlint'; +import {isStateConstant, isGlobalPropertyConstant, isFeatureConstant} from '../expression/is_constant'; export default function validateExpression(options: any): Array { const expression = (options.expressionContext === 'property' ? createPropertyExpression : createExpression)(deepUnbundle(options.value), options.valueSpec); diff --git a/src/style-spec/validate/validate_filter.js b/src/style-spec/validate/validate_filter.js index 121e995e51a..470ce40731a 100644 --- a/src/style-spec/validate/validate_filter.js +++ b/src/style-spec/validate/validate_filter.js @@ -3,15 +3,15 @@ import ValidationError from '../error/validation_error'; import validateExpression from './validate_expression'; import validateEnum from './validate_enum'; import getType from '../util/get_type'; -import { unbundle, deepUnbundle } from '../util/unbundle_jsonlint'; +import {unbundle, deepUnbundle} from '../util/unbundle_jsonlint'; import extend from '../util/extend'; -import { isExpressionFilter } from '../feature_filter'; +import {isExpressionFilter} from '../feature_filter'; export default function validateFilter(options) { if (isExpressionFilter(deepUnbundle(options.value))) { return validateExpression(extend({}, options, { expressionContext: 'filter', - valueSpec: { value: 'boolean' } + valueSpec: {value: 'boolean'} })); } else { return validateNonExpressionFilter(options); diff --git a/src/style-spec/validate/validate_function.js b/src/style-spec/validate/validate_function.js index 1930c496820..5c2fa42e6ff 100644 --- a/src/style-spec/validate/validate_function.js +++ b/src/style-spec/validate/validate_function.js @@ -5,8 +5,8 @@ import validate from './validate'; import validateObject from './validate_object'; import validateArray from './validate_array'; import validateNumber from './validate_number'; -import { isExpression } from '../expression'; -import { unbundle, deepUnbundle } from '../util/unbundle_jsonlint'; +import {isExpression} from '../expression'; +import {unbundle, deepUnbundle} from '../util/unbundle_jsonlint'; import { supportsPropertyExpression, supportsZoomExpression, @@ -124,10 +124,10 @@ export default function validateFunction(options) { errors = errors.concat(validateObject({ key: `${key}[0]`, value: value[0], - valueSpec: { zoom: {} }, + valueSpec: {zoom: {}}, style: options.style, styleSpec: options.styleSpec, - objectElementValidators: { zoom: validateNumber, value: validateStopDomainValue } + objectElementValidators: {zoom: validateNumber, value: validateStopDomainValue} })); } else { errors = errors.concat(validateStopDomainValue({ diff --git a/src/style-spec/validate/validate_layer.js b/src/style-spec/validate/validate_layer.js index e2225c7dbe8..6cfc75e1f01 100644 --- a/src/style-spec/validate/validate_layer.js +++ b/src/style-spec/validate/validate_layer.js @@ -1,6 +1,6 @@ import ValidationError from '../error/validation_error'; -import { unbundle } from '../util/unbundle_jsonlint'; +import {unbundle} from '../util/unbundle_jsonlint'; import validateObject from './validate_object'; import validateFilter from './validate_filter'; import validatePaintProperty from './validate_paint_property'; diff --git a/src/style-spec/validate/validate_property.js b/src/style-spec/validate/validate_property.js index 1c3d5c2e414..c2e922bfbe9 100644 --- a/src/style-spec/validate/validate_property.js +++ b/src/style-spec/validate/validate_property.js @@ -2,9 +2,9 @@ import validate from './validate'; import ValidationError from '../error/validation_error'; import getType from '../util/get_type'; -import { isFunction } from '../function'; -import { unbundle, deepUnbundle } from '../util/unbundle_jsonlint'; -import { supportsPropertyExpression } from '../util/properties'; +import {isFunction} from '../function'; +import {unbundle, deepUnbundle} from '../util/unbundle_jsonlint'; +import {supportsPropertyExpression} from '../util/properties'; export default function validateProperty(options, propertyType) { const key = options.key; diff --git a/src/style-spec/validate/validate_source.js b/src/style-spec/validate/validate_source.js index b325eb69508..cb7451ea5b7 100644 --- a/src/style-spec/validate/validate_source.js +++ b/src/style-spec/validate/validate_source.js @@ -1,6 +1,6 @@ import ValidationError from '../error/validation_error'; -import { unbundle } from '../util/unbundle_jsonlint'; +import {unbundle} from '../util/unbundle_jsonlint'; import validateObject from './validate_object'; import validateEnum from './validate_enum'; import validateExpression from './validate_expression'; diff --git a/src/style/evaluation_parameters.js b/src/style/evaluation_parameters.js index ad48a462c0a..a0bdc3930eb 100644 --- a/src/style/evaluation_parameters.js +++ b/src/style/evaluation_parameters.js @@ -54,8 +54,8 @@ class EvaluationParameters { const t = this.crossFadingFactor(); return z > this.zoomHistory.lastIntegerZoom ? - { fromScale: 2, toScale: 1, t: fraction + (1 - fraction) * t } : - { fromScale: 0.5, toScale: 1, t: 1 - (1 - t) * fraction }; + {fromScale: 2, toScale: 1, t: fraction + (1 - fraction) * t} : + {fromScale: 0.5, toScale: 1, t: 1 - (1 - t) * fraction}; } } diff --git a/src/style/light.js b/src/style/light.js index 14beb4e3e59..99c24d0d232 100644 --- a/src/style/light.js +++ b/src/style/light.js @@ -2,20 +2,20 @@ import styleSpec from '../style-spec/reference/latest'; -import { endsWith, extend, sphericalToCartesian } from '../util/util'; -import { Evented } from '../util/evented'; +import {endsWith, extend, sphericalToCartesian} from '../util/util'; +import {Evented} from '../util/evented'; import { validateStyle, validateLight, emitValidationErrors } from './validate_style'; import Color from '../style-spec/util/color'; -import { number as interpolate } from '../style-spec/util/interpolate'; +import {number as interpolate} from '../style-spec/util/interpolate'; import type {StylePropertySpecification} from '../style-spec/style-spec'; import type EvaluationParameters from './evaluation_parameters'; import type {StyleSetterOptions} from '../style/style'; -import { Properties, Transitionable, Transitioning, PossiblyEvaluated, DataConstantProperty } from './properties'; +import {Properties, Transitionable, Transitioning, PossiblyEvaluated, DataConstantProperty} from './properties'; import type { Property, diff --git a/src/style/load_glyph_range.js b/src/style/load_glyph_range.js index 7c0552459cf..7cd6c589cbd 100644 --- a/src/style/load_glyph_range.js +++ b/src/style/load_glyph_range.js @@ -1,6 +1,6 @@ // @flow -import { getArrayBuffer, ResourceType } from '../util/ajax'; +import {getArrayBuffer, ResourceType} from '../util/ajax'; import parseGlyphPBF from './parse_glyph_pbf'; diff --git a/src/style/load_sprite.js b/src/style/load_sprite.js index f868ec23014..11f5eb2e25e 100644 --- a/src/style/load_sprite.js +++ b/src/style/load_sprite.js @@ -1,9 +1,9 @@ // @flow -import { getJSON, getImage, ResourceType } from '../util/ajax'; +import {getJSON, getImage, ResourceType} from '../util/ajax'; import browser from '../util/browser'; -import { RGBAImage } from '../util/image'; +import {RGBAImage} from '../util/image'; import type {StyleImage} from './style_image'; import type {RequestManager} from '../util/mapbox'; diff --git a/src/style/parse_glyph_pbf.js b/src/style/parse_glyph_pbf.js index ad1f3b486ca..c5536d721e1 100644 --- a/src/style/parse_glyph_pbf.js +++ b/src/style/parse_glyph_pbf.js @@ -1,6 +1,6 @@ // @flow -import { AlphaImage } from '../util/image'; +import {AlphaImage} from '../util/image'; import Protobuf from 'pbf'; const border = 3; diff --git a/src/style/pauseable_placement.js b/src/style/pauseable_placement.js index 5d4ad1b75ed..a0d98465efb 100644 --- a/src/style/pauseable_placement.js +++ b/src/style/pauseable_placement.js @@ -2,7 +2,7 @@ import browser from '../util/browser'; -import { Placement } from '../symbol/placement'; +import {Placement} from '../symbol/placement'; import type Transform from '../geo/transform'; import type StyleLayer from './style_layer'; diff --git a/src/style/properties.js b/src/style/properties.js index 483b5ab2e9b..8ee9a9319f3 100644 --- a/src/style/properties.js +++ b/src/style/properties.js @@ -2,11 +2,11 @@ import assert from 'assert'; -import { clone, extend, easeCubicInOut } from '../util/util'; +import {clone, extend, easeCubicInOut} from '../util/util'; import * as interpolate from '../style-spec/util/interpolate'; -import { normalizePropertyExpression } from '../style-spec/expression'; +import {normalizePropertyExpression} from '../style-spec/expression'; import Color from '../style-spec/util/color'; -import { register } from '../util/web_worker_transfer'; +import {register} from '../util/web_worker_transfer'; import EvaluationParameters from './evaluation_parameters'; import type {StylePropertySpecification} from '../style-spec/style-spec'; @@ -632,7 +632,7 @@ export class CrossFadedDataDrivenProperty extends DataDrivenProperty { const z = parameters.zoom; - return z > parameters.zoomHistory.lastIntegerZoom ? { from: min, to: mid } : { from: max, to: mid }; + return z > parameters.zoomHistory.lastIntegerZoom ? {from: min, to: mid} : {from: max, to: mid}; } interpolate(a: PossiblyEvaluatedPropertyValue>): PossiblyEvaluatedPropertyValue> { @@ -670,7 +670,7 @@ export class CrossFadedProperty implements Property> { _calculate(min: T, mid: T, max: T, parameters: EvaluationParameters): ?CrossFaded { const z = parameters.zoom; - return z > parameters.zoomHistory.lastIntegerZoom ? { from: min, to: mid } : { from: max, to: mid }; + return z > parameters.zoomHistory.lastIntegerZoom ? {from: min, to: mid} : {from: max, to: mid}; } interpolate(a: ?CrossFaded): ?CrossFaded { diff --git a/src/style/style.js b/src/style/style.js index 38cd20568a9..1e364e5904b 100644 --- a/src/style/style.js +++ b/src/style/style.js @@ -2,7 +2,7 @@ import assert from 'assert'; -import { Event, ErrorEvent, Evented } from '../util/evented'; +import {Event, ErrorEvent, Evented} from '../util/evented'; import StyleLayer from './style_layer'; import createStyleLayer from './create_style_layer'; import loadSprite from './load_sprite'; @@ -10,18 +10,18 @@ import ImageManager from '../render/image_manager'; import GlyphManager from '../render/glyph_manager'; import Light from './light'; import LineAtlas from '../render/line_atlas'; -import { pick, clone, extend, deepEqual, filterObject, mapObject } from '../util/util'; -import { getJSON, getReferrer, makeRequest, ResourceType } from '../util/ajax'; -import { isMapboxURL } from '../util/mapbox'; +import {pick, clone, extend, deepEqual, filterObject, mapObject} from '../util/util'; +import {getJSON, getReferrer, makeRequest, ResourceType} from '../util/ajax'; +import {isMapboxURL} from '../util/mapbox'; import browser from '../util/browser'; import Dispatcher from '../util/dispatcher'; -import { validateStyle, emitValidationErrors as _emitValidationErrors } from './validate_style'; +import {validateStyle, emitValidationErrors as _emitValidationErrors} from './validate_style'; import { getType as getSourceType, setType as setSourceType, type SourceClass } from '../source/source'; -import { queryRenderedFeatures, queryRenderedSymbols, querySourceFeatures } from '../source/query_features'; +import {queryRenderedFeatures, queryRenderedSymbols, querySourceFeatures} from '../source/query_features'; import SourceCache from '../source/source_cache'; import GeoJSONSource from '../source/geojson_source'; import styleSpec from '../style-spec/reference/latest'; @@ -916,7 +916,7 @@ class Style extends Evented { } getTransition() { - return extend({ duration: 300, delay: 0 }, this.stylesheet && this.stylesheet.transition); + return extend({duration: 300, delay: 0}, this.stylesheet && this.stylesheet.transition); } serialize() { diff --git a/src/style/style_layer.js b/src/style/style_layer.js index bfdf0f65253..5df0f8d09e6 100644 --- a/src/style/style_layer.js +++ b/src/style/style_layer.js @@ -1,6 +1,6 @@ // @flow -import { endsWith, filterObject } from '../util/util'; +import {endsWith, filterObject} from '../util/util'; import styleSpec from '../style-spec/reference/latest'; import { @@ -9,11 +9,11 @@ import { validatePaintProperty, emitValidationErrors } from './validate_style'; -import { Evented } from '../util/evented'; -import { Layout, Transitionable, Transitioning, Properties, PossiblyEvaluatedPropertyValue } from './properties'; -import { supportsPropertyExpression } from '../style-spec/util/properties'; +import {Evented} from '../util/evented'; +import {Layout, Transitionable, Transitioning, Properties, PossiblyEvaluatedPropertyValue} from './properties'; +import {supportsPropertyExpression} from '../style-spec/util/properties'; -import type { FeatureState } from '../style-spec/expression'; +import type {FeatureState} from '../style-spec/expression'; import type {Bucket} from '../data/bucket'; import type Point from '@mapbox/point-geometry'; import type {FeatureFilter} from '../style-spec/feature_filter'; diff --git a/src/style/style_layer/background_style_layer.js b/src/style/style_layer/background_style_layer.js index 6e22e5f3b81..33a2ead347e 100644 --- a/src/style/style_layer/background_style_layer.js +++ b/src/style/style_layer/background_style_layer.js @@ -3,7 +3,7 @@ import StyleLayer from '../style_layer'; import properties from './background_style_layer_properties'; -import { Transitionable, Transitioning, PossiblyEvaluated } from '../properties'; +import {Transitionable, Transitioning, PossiblyEvaluated} from '../properties'; import type {PaintProps} from './background_style_layer_properties'; import type {LayerSpecification} from '../../style-spec/types'; diff --git a/src/style/style_layer/circle_style_layer.js b/src/style/style_layer/circle_style_layer.js index eafbc7d2eb8..e5168f56a29 100644 --- a/src/style/style_layer/circle_style_layer.js +++ b/src/style/style_layer/circle_style_layer.js @@ -3,14 +3,14 @@ import StyleLayer from '../style_layer'; import CircleBucket from '../../data/bucket/circle_bucket'; -import { polygonIntersectsBufferedPoint } from '../../util/intersection_tests'; -import { getMaximumPaintValue, translateDistance, translate } from '../query_utils'; +import {polygonIntersectsBufferedPoint} from '../../util/intersection_tests'; +import {getMaximumPaintValue, translateDistance, translate} from '../query_utils'; import properties from './circle_style_layer_properties'; -import { Transitionable, Transitioning, Layout, PossiblyEvaluated } from '../properties'; -import { vec4 } from 'gl-matrix'; +import {Transitionable, Transitioning, Layout, PossiblyEvaluated} from '../properties'; +import {vec4} from 'gl-matrix'; import Point from '@mapbox/point-geometry'; -import type { FeatureState } from '../../style-spec/expression'; +import type {FeatureState} from '../../style-spec/expression'; import type Transform from '../../geo/transform'; import type {Bucket, BucketParameters} from '../../data/bucket'; import type {LayoutProps, PaintProps} from './circle_style_layer_properties'; diff --git a/src/style/style_layer/fill_extrusion_style_layer.js b/src/style/style_layer/fill_extrusion_style_layer.js index 9e90893e7b3..10c98abaebf 100644 --- a/src/style/style_layer/fill_extrusion_style_layer.js +++ b/src/style/style_layer/fill_extrusion_style_layer.js @@ -3,14 +3,14 @@ import StyleLayer from '../style_layer'; import FillExtrusionBucket from '../../data/bucket/fill_extrusion_bucket'; -import { polygonIntersectsPolygon, polygonIntersectsMultiPolygon } from '../../util/intersection_tests'; -import { translateDistance, translate } from '../query_utils'; +import {polygonIntersectsPolygon, polygonIntersectsMultiPolygon} from '../../util/intersection_tests'; +import {translateDistance, translate} from '../query_utils'; import properties from './fill_extrusion_style_layer_properties'; -import { Transitionable, Transitioning, PossiblyEvaluated } from '../properties'; +import {Transitionable, Transitioning, PossiblyEvaluated} from '../properties'; import {vec4} from 'gl-matrix'; import Point from '@mapbox/point-geometry'; -import type { FeatureState } from '../../style-spec/expression'; +import type {FeatureState} from '../../style-spec/expression'; import type {BucketParameters} from '../../data/bucket'; import type {PaintProps} from './fill_extrusion_style_layer_properties'; import type Transform from '../../geo/transform'; diff --git a/src/style/style_layer/fill_style_layer.js b/src/style/style_layer/fill_style_layer.js index 57b7884b16f..d27790e7571 100644 --- a/src/style/style_layer/fill_style_layer.js +++ b/src/style/style_layer/fill_style_layer.js @@ -3,12 +3,12 @@ import StyleLayer from '../style_layer'; import FillBucket from '../../data/bucket/fill_bucket'; -import { polygonIntersectsMultiPolygon } from '../../util/intersection_tests'; -import { translateDistance, translate } from '../query_utils'; +import {polygonIntersectsMultiPolygon} from '../../util/intersection_tests'; +import {translateDistance, translate} from '../query_utils'; import properties from './fill_style_layer_properties'; -import { Transitionable, Transitioning, Layout, PossiblyEvaluated } from '../properties'; +import {Transitionable, Transitioning, Layout, PossiblyEvaluated} from '../properties'; -import type { FeatureState } from '../../style-spec/expression'; +import type {FeatureState} from '../../style-spec/expression'; import type {BucketParameters} from '../../data/bucket'; import type Point from '@mapbox/point-geometry'; import type {LayoutProps, PaintProps} from './fill_style_layer_properties'; diff --git a/src/style/style_layer/heatmap_style_layer.js b/src/style/style_layer/heatmap_style_layer.js index 2466783d2e2..2ae9575346d 100644 --- a/src/style/style_layer/heatmap_style_layer.js +++ b/src/style/style_layer/heatmap_style_layer.js @@ -3,10 +3,10 @@ import StyleLayer from '../style_layer'; import HeatmapBucket from '../../data/bucket/heatmap_bucket'; -import { RGBAImage } from '../../util/image'; +import {RGBAImage} from '../../util/image'; import properties from './heatmap_style_layer_properties'; import renderColorRamp from '../../util/color_ramp'; -import { Transitionable, Transitioning, PossiblyEvaluated } from '../properties'; +import {Transitionable, Transitioning, PossiblyEvaluated} from '../properties'; import type Texture from '../../render/texture'; import type Framebuffer from '../../gl/framebuffer'; diff --git a/src/style/style_layer/hillshade_style_layer.js b/src/style/style_layer/hillshade_style_layer.js index 4de3bf9af11..782ebe3d564 100644 --- a/src/style/style_layer/hillshade_style_layer.js +++ b/src/style/style_layer/hillshade_style_layer.js @@ -3,7 +3,7 @@ import StyleLayer from '../style_layer'; import properties from './hillshade_style_layer_properties'; -import { Transitionable, Transitioning, PossiblyEvaluated } from '../properties'; +import {Transitionable, Transitioning, PossiblyEvaluated} from '../properties'; import type {PaintProps} from './hillshade_style_layer_properties'; import type {LayerSpecification} from '../../style-spec/types'; diff --git a/src/style/style_layer/line_style_layer.js b/src/style/style_layer/line_style_layer.js index 8827cb672b7..037a5fb7779 100644 --- a/src/style/style_layer/line_style_layer.js +++ b/src/style/style_layer/line_style_layer.js @@ -4,16 +4,16 @@ import Point from '@mapbox/point-geometry'; import StyleLayer from '../style_layer'; import LineBucket from '../../data/bucket/line_bucket'; -import { RGBAImage } from '../../util/image'; -import { polygonIntersectsBufferedMultiLine } from '../../util/intersection_tests'; -import { getMaximumPaintValue, translateDistance, translate } from '../query_utils'; +import {RGBAImage} from '../../util/image'; +import {polygonIntersectsBufferedMultiLine} from '../../util/intersection_tests'; +import {getMaximumPaintValue, translateDistance, translate} from '../query_utils'; import properties from './line_style_layer_properties'; -import { extend } from '../../util/util'; +import {extend} from '../../util/util'; import EvaluationParameters from '../evaluation_parameters'; import renderColorRamp from '../../util/color_ramp'; -import { Transitionable, Transitioning, Layout, PossiblyEvaluated, DataDrivenProperty } from '../properties'; +import {Transitionable, Transitioning, Layout, PossiblyEvaluated, DataDrivenProperty} from '../properties'; -import type { FeatureState } from '../../style-spec/expression'; +import type {FeatureState} from '../../style-spec/expression'; import type {Bucket, BucketParameters} from '../../data/bucket'; import type {LayoutProps, PaintProps} from './line_style_layer_properties'; import type Transform from '../../geo/transform'; diff --git a/src/style/style_layer/raster_style_layer.js b/src/style/style_layer/raster_style_layer.js index f03d2f6e3af..33033909cb6 100644 --- a/src/style/style_layer/raster_style_layer.js +++ b/src/style/style_layer/raster_style_layer.js @@ -3,7 +3,7 @@ import StyleLayer from '../style_layer'; import properties from './raster_style_layer_properties'; -import { Transitionable, Transitioning, PossiblyEvaluated } from '../properties'; +import {Transitionable, Transitioning, PossiblyEvaluated} from '../properties'; import type {PaintProps} from './raster_style_layer_properties'; import type {LayerSpecification} from '../../style-spec/types'; diff --git a/src/style/style_layer/symbol_style_layer.js b/src/style/style_layer/symbol_style_layer.js index c1abf747a60..153d6edbf0d 100644 --- a/src/style/style_layer/symbol_style_layer.js +++ b/src/style/style_layer/symbol_style_layer.js @@ -27,7 +27,7 @@ import type {BucketParameters} from '../../data/bucket'; import type {LayoutProps, PaintProps} from './symbol_style_layer_properties'; import type EvaluationParameters from '../evaluation_parameters'; import type {LayerSpecification} from '../../style-spec/types'; -import type { Feature, SourceExpression, CompositeExpression } from '../../style-spec/expression'; +import type {Feature, SourceExpression, CompositeExpression} from '../../style-spec/expression'; import type {Expression} from '../../style-spec/expression/expression'; import {FormattedType} from '../../style-spec/expression/types'; import {typeOf} from '../../style-spec/expression/values'; diff --git a/src/style/style_layer_index.js b/src/style/style_layer_index.js index 25eddf0d0f6..393fb33299b 100644 --- a/src/style/style_layer_index.js +++ b/src/style/style_layer_index.js @@ -3,7 +3,7 @@ import StyleLayer from './style_layer'; import createStyleLayer from './create_style_layer'; -import { values } from '../util/util'; +import {values} from '../util/util'; import featureFilter from '../style-spec/feature_filter'; import groupByLayout from '../style-spec/group_by_layout'; diff --git a/src/style/validate_style.js b/src/style/validate_style.js index 57aba3060cc..a84a38de698 100644 --- a/src/style/validate_style.js +++ b/src/style/validate_style.js @@ -1,6 +1,6 @@ // @flow import validateStyleMin from '../style-spec/validate_style.min'; -import { ErrorEvent } from '../util/evented'; +import {ErrorEvent} from '../util/evented'; import type {Evented} from '../util/evented'; diff --git a/src/symbol/anchor.js b/src/symbol/anchor.js index 1637d9785fb..cd756cc72f8 100644 --- a/src/symbol/anchor.js +++ b/src/symbol/anchor.js @@ -2,7 +2,7 @@ import Point from '@mapbox/point-geometry'; -import { register } from '../util/web_worker_transfer'; +import {register} from '../util/web_worker_transfer'; class Anchor extends Point { angle: any; diff --git a/src/symbol/collision_index.js b/src/symbol/collision_index.js index e419e8b32c5..66cc64e6fb9 100644 --- a/src/symbol/collision_index.js +++ b/src/symbol/collision_index.js @@ -4,7 +4,7 @@ import Point from '@mapbox/point-geometry'; import * as intersectionTests from '../util/intersection_tests'; import Grid from './grid_index'; -import { mat4 } from 'gl-matrix'; +import {mat4} from 'gl-matrix'; import * as projection from '../symbol/projection'; @@ -309,14 +309,14 @@ class CollisionIndex { insertCollisionBox(collisionBox: Array, ignorePlacement: boolean, bucketInstanceId: number, featureIndex: number, collisionGroupID: number) { const grid = ignorePlacement ? this.ignoredGrid : this.grid; - const key = { bucketInstanceId, featureIndex, collisionGroupID }; + const key = {bucketInstanceId, featureIndex, collisionGroupID}; grid.insert(key, collisionBox[0], collisionBox[1], collisionBox[2], collisionBox[3]); } insertCollisionCircles(collisionCircles: Array, ignorePlacement: boolean, bucketInstanceId: number, featureIndex: number, collisionGroupID: number) { const grid = ignorePlacement ? this.ignoredGrid : this.grid; - const key = { bucketInstanceId, featureIndex, collisionGroupID }; + const key = {bucketInstanceId, featureIndex, collisionGroupID}; for (let k = 0; k < collisionCircles.length; k += 4) { grid.insertCircle(key, collisionCircles[k], collisionCircles[k + 1], collisionCircles[k + 2]); } diff --git a/src/symbol/cross_tile_symbol_index.js b/src/symbol/cross_tile_symbol_index.js index ade2eacdbc3..75b0508c0e2 100644 --- a/src/symbol/cross_tile_symbol_index.js +++ b/src/symbol/cross_tile_symbol_index.js @@ -2,9 +2,9 @@ import EXTENT from '../data/extent'; -import { SymbolInstanceArray } from '../data/array_types'; +import {SymbolInstanceArray} from '../data/array_types'; -import type { SymbolInstance } from '../data/array_types'; +import type {SymbolInstance} from '../data/array_types'; import type {OverscaledTileID} from '../source/tile_id'; import type SymbolBucket from '../data/bucket/symbol_bucket'; import type StyleLayer from '../style/style_layer'; diff --git a/src/symbol/get_anchors.js b/src/symbol/get_anchors.js index 32151c40734..9b034b4bc86 100644 --- a/src/symbol/get_anchors.js +++ b/src/symbol/get_anchors.js @@ -1,6 +1,6 @@ // @flow -import { number as interpolate } from '../style-spec/util/interpolate'; +import {number as interpolate} from '../style-spec/util/interpolate'; import Anchor from '../symbol/anchor'; import checkMaxAngle from './check_max_angle'; @@ -8,7 +8,7 @@ import checkMaxAngle from './check_max_angle'; import type Point from '@mapbox/point-geometry'; import type {Shaping, PositionedIcon} from './shaping'; -export { getAnchors, getCenterAnchor }; +export {getAnchors, getCenterAnchor}; function getLineLength(line: Array): number { let lineLength = 0; diff --git a/src/symbol/grid_index.js b/src/symbol/grid_index.js index 48623a47118..fa1dc103436 100644 --- a/src/symbol/grid_index.js +++ b/src/symbol/grid_index.js @@ -121,7 +121,7 @@ class GridIndex { } else { const queryArgs = { hitTest, - seenUids: { box: {}, circle: {} } + seenUids: {box: {}, circle: {}} }; this._forEachCell(x1, y1, x2, y2, this._queryCell, result, queryArgs, predicate); return hitTest ? result.length > 0 : result; @@ -145,8 +145,8 @@ class GridIndex { const result = []; const queryArgs = { hitTest, - circle: { x, y, radius }, - seenUids: { box: {}, circle: {} } + circle: {x, y, radius}, + seenUids: {box: {}, circle: {}} }; this._forEachCell(x1, y1, x2, y2, this._queryCellCircle, result, queryArgs, predicate); return hitTest ? result.length > 0 : result; diff --git a/src/symbol/opacity_state.js b/src/symbol/opacity_state.js index 864c1fb32f5..1649b2c2a0f 100644 --- a/src/symbol/opacity_state.js +++ b/src/symbol/opacity_state.js @@ -1,6 +1,6 @@ // @flow -import { register } from '../util/web_worker_transfer'; +import {register} from '../util/web_worker_transfer'; class OpacityState { opacity: number; diff --git a/src/symbol/placement.js b/src/symbol/placement.js index 613c80f40e6..cf302e4eb94 100644 --- a/src/symbol/placement.js +++ b/src/symbol/placement.js @@ -4,8 +4,8 @@ import CollisionIndex from './collision_index'; import EXTENT from '../data/extent'; import * as symbolSize from './symbol_size'; import * as projection from './projection'; -import { getAnchorJustification, evaluateRadialOffset } from './symbol_layout'; -import { getAnchorAlignment, WritingMode } from './shaping'; +import {getAnchorJustification, evaluateRadialOffset} from './symbol_layout'; +import {getAnchorAlignment, WritingMode} from './shaping'; import assert from 'assert'; import pixelsToTileUnits from '../source/pixels_to_tile_units'; import Point from '@mapbox/point-geometry'; @@ -13,7 +13,7 @@ import type Transform from '../geo/transform'; import type StyleLayer from '../style/style_layer'; import type Tile from '../source/tile'; -import type SymbolBucket, { CollisionArrays, SingleCollisionBox } from '../data/bucket/symbol_bucket'; +import type SymbolBucket, {CollisionArrays, SingleCollisionBox} from '../data/bucket/symbol_bucket'; import type {mat4} from 'gl-matrix'; import type {CollisionBoxArray, CollisionVertexArray, SymbolInstance} from '../data/array_types'; import type FeatureIndex from '../data/feature_index'; @@ -112,7 +112,7 @@ class CollisionGroups { } return this.collisionGroups[sourceID]; } else { - return { ID: 0, predicate: null }; + return {ID: 0, predicate: null}; } } } @@ -326,8 +326,8 @@ export class Placement { let placeIcon = false; let offscreen = true; - let placed = { box: null, offscreen: null }; - let placedVertical = { box: null, offscreen: null }; + let placed = {box: null, offscreen: null}; + let placedVertical = {box: null, offscreen: null}; let placedGlyphBoxes = null; let placedGlyphCircles = null; @@ -395,7 +395,7 @@ export class Placement { if (bucket.allowVerticalPlacement && symbolInstance.numVerticalGlyphVertices > 0 && verticalTextBox) { return placeBox(verticalTextBox, WritingMode.vertical); } - return { box: null, offscreen: null }; + return {box: null, offscreen: null}; }; placeTextForPlacementModes(placeHorizontal, placeVertical); @@ -420,7 +420,7 @@ export class Placement { const height = collisionTextBox.y2 - collisionTextBox.y1; const textBoxScale = symbolInstance.textBoxScale; - let placedBox: ?{ box: Array, offscreen: boolean } = { box: [], offscreen: false }; + let placedBox: ?{ box: Array, offscreen: boolean } = {box: [], offscreen: false}; const placementAttempts = textAllowOverlap ? anchors.length * 2 : anchors.length; for (let i = 0; i < placementAttempts; ++i) { const anchor = anchors[i % anchors.length]; @@ -449,7 +449,7 @@ export class Placement { if (bucket.allowVerticalPlacement && !wasPlaced && symbolInstance.numVerticalGlyphVertices > 0 && verticalTextBox) { return placeBoxForVariableAnchors(verticalTextBox, WritingMode.vertical); } - return { box: null, offscreen: null }; + return {box: null, offscreen: null}; }; placeTextForPlacementModes(placeHorizontal, placeVertical); diff --git a/src/symbol/projection.js b/src/symbol/projection.js index 19f0d8f540b..894e7ff345f 100644 --- a/src/symbol/projection.js +++ b/src/symbol/projection.js @@ -2,9 +2,9 @@ import Point from '@mapbox/point-geometry'; -import { mat4, vec4 } from 'gl-matrix'; +import {mat4, vec4} from 'gl-matrix'; import * as symbolSize from './symbol_size'; -import { addDynamicAttributes } from '../data/bucket/symbol_bucket'; +import {addDynamicAttributes} from '../data/bucket/symbol_bucket'; import type Painter from '../render/painter'; import type Transform from '../geo/transform'; @@ -14,9 +14,9 @@ import type { SymbolLineVertexArray, SymbolDynamicLayoutArray } from '../data/array_types'; -import { WritingMode } from '../symbol/shaping'; +import {WritingMode} from '../symbol/shaping'; -export { updateLineLabels, hideGlyphs, getLabelPlaneMatrix, getGlCoordMatrix, project, placeFirstAndLastGlyph, xyTransformMat4 }; +export {updateLineLabels, hideGlyphs, getLabelPlaneMatrix, getGlCoordMatrix, project, placeFirstAndLastGlyph, xyTransformMat4}; /* * # Overview of coordinate spaces @@ -226,7 +226,7 @@ function placeFirstAndLastGlyph(fontScale: number, glyphOffsetArray: GlyphOffset if (!lastPlacedGlyph) return null; - return { first: firstPlacedGlyph, last: lastPlacedGlyph }; + return {first: firstPlacedGlyph, last: lastPlacedGlyph}; } function requiresOrientationChange(writingMode, firstPoint, lastPoint, aspectRatio) { @@ -238,13 +238,13 @@ function requiresOrientationChange(writingMode, firstPoint, lastPoint, aspectRat const rise = Math.abs(lastPoint.y - firstPoint.y); const run = Math.abs(lastPoint.x - firstPoint.x) * aspectRatio; if (rise > run) { - return { useVertical: true }; + return {useVertical: true}; } } if (writingMode === WritingMode.vertical ? firstPoint.y < lastPoint.y : firstPoint.x > lastPoint.x) { // Includes "horizontalOnly" case for labels without vertical glyphs - return { needsFlipping: true }; + return {needsFlipping: true}; } return null; @@ -265,7 +265,7 @@ function placeGlyphsAlongLine(symbol, fontSize, flip, keepUpright, posMatrix, la // the overall orientation of the label and determine whether it needs to be flipped in keepUpright mode const firstAndLastGlyph = placeFirstAndLastGlyph(fontScale, glyphOffsetArray, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol, lineVertexArray, labelPlaneMatrix, projectionCache, false); if (!firstAndLastGlyph) { - return { notEnoughRoom: true }; + return {notEnoughRoom: true}; } const firstPoint = project(firstAndLastGlyph.first.point, glCoordMatrix).point; const lastPoint = project(firstAndLastGlyph.last.point, glCoordMatrix).point; @@ -310,7 +310,7 @@ function placeGlyphsAlongLine(symbol, fontSize, flip, keepUpright, posMatrix, la const singleGlyph = placeGlyphAlongLine(fontScale * glyphOffsetArray.getoffsetX(symbol.glyphStartIndex), lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment, symbol.lineStartIndex, symbol.lineStartIndex + symbol.lineLength, lineVertexArray, labelPlaneMatrix, projectionCache, false); if (!singleGlyph) - return { notEnoughRoom: true }; + return {notEnoughRoom: true}; placedGlyphs = [singleGlyph]; } diff --git a/src/symbol/quads.js b/src/symbol/quads.js index 62040852174..9a64a789f5e 100644 --- a/src/symbol/quads.js +++ b/src/symbol/quads.js @@ -2,7 +2,7 @@ import Point from '@mapbox/point-geometry'; -import { GLYPH_PBF_BORDER } from '../style/parse_glyph_pbf'; +import {GLYPH_PBF_BORDER} from '../style/parse_glyph_pbf'; import type Anchor from './anchor'; import type {PositionedIcon, Shaping} from './shaping'; diff --git a/src/symbol/shaping.js b/src/symbol/shaping.js index 71269981578..44c66923c18 100644 --- a/src/symbol/shaping.js +++ b/src/symbol/shaping.js @@ -6,7 +6,7 @@ import { charInComplexShapingScript } from '../util/script_detection'; import verticalizePunctuation from '../util/verticalize_punctuation'; -import { plugin as rtlTextPlugin } from '../source/rtl_text_plugin'; +import {plugin as rtlTextPlugin} from '../source/rtl_text_plugin'; import ONE_EM from './one_em'; import type {StyleGlyph} from '../style/style_glyph'; @@ -19,7 +19,7 @@ const WritingMode = { horizontalOnly: 3 }; -export { shapeText, shapeIcon, getAnchorAlignment, WritingMode }; +export {shapeText, shapeIcon, getAnchorAlignment, WritingMode}; // The position of a glyph relative to the text's anchor point. export type PositionedGlyph = { @@ -438,7 +438,7 @@ function getAnchorAlignment(anchor: SymbolAnchor) { break; } - return { horizontalAlign, verticalAlign }; + return {horizontalAlign, verticalAlign}; } function shapeLines(shaping: Shaping, diff --git a/src/symbol/symbol_layout.js b/src/symbol/symbol_layout.js index b85310ef051..7be720bc932 100644 --- a/src/symbol/symbol_layout.js +++ b/src/symbol/symbol_layout.js @@ -2,12 +2,12 @@ import Anchor from './anchor'; -import { getAnchors, getCenterAnchor } from './get_anchors'; +import {getAnchors, getCenterAnchor} from './get_anchors'; import clipLine from './clip_line'; -import { shapeText, shapeIcon, WritingMode } from './shaping'; -import { getGlyphQuads, getIconQuads } from './quads'; +import {shapeText, shapeIcon, WritingMode} from './shaping'; +import {getGlyphQuads, getIconQuads} from './quads'; import CollisionFeature from './collision_feature'; -import { warnOnce } from '../util/util'; +import {warnOnce} from '../util/util'; import { allowsVerticalWritingMode, allowsLetterSpacing diff --git a/src/symbol/symbol_size.js b/src/symbol/symbol_size.js index afdc734c1bd..42a6355ad00 100644 --- a/src/symbol/symbol_size.js +++ b/src/symbol/symbol_size.js @@ -1,8 +1,8 @@ // @flow -import { number as interpolate } from '../style-spec/util/interpolate'; +import {number as interpolate} from '../style-spec/util/interpolate'; import Interpolate from '../style-spec/expression/definitions/interpolate'; -import { clamp } from '../util/util'; +import {clamp} from '../util/util'; import EvaluationParameters from '../style/evaluation_parameters'; import type {PropertyValue, PossiblyEvaluatedPropertyValue} from '../style/properties'; @@ -10,7 +10,7 @@ import type {InterpolationType} from '../style-spec/expression/definitions/inter const SIZE_PACK_FACTOR = 256; -export { getSizeData, evaluateSizeForFeature, evaluateSizeForZoom, SIZE_PACK_FACTOR }; +export {getSizeData, evaluateSizeForFeature, evaluateSizeForZoom, SIZE_PACK_FACTOR}; export type SizeData = { kind: 'constant', diff --git a/src/symbol/transform_text.js b/src/symbol/transform_text.js index 4c782f2d6c1..c6d4c746713 100644 --- a/src/symbol/transform_text.js +++ b/src/symbol/transform_text.js @@ -1,6 +1,6 @@ // @flow -import { plugin as rtlTextPlugin } from '../source/rtl_text_plugin'; +import {plugin as rtlTextPlugin} from '../source/rtl_text_plugin'; import type SymbolStyleLayer from '../style/style_layer/symbol_style_layer'; import type {Feature} from '../style-spec/expression'; diff --git a/src/ui/bind_handlers.js b/src/ui/bind_handlers.js index b66144ffd1f..3b675ca3979 100644 --- a/src/ui/bind_handlers.js +++ b/src/ui/bind_handlers.js @@ -1,6 +1,6 @@ // @flow -import { MapMouseEvent, MapTouchEvent, MapWheelEvent } from '../ui/events'; +import {MapMouseEvent, MapTouchEvent, MapWheelEvent} from '../ui/events'; import DOM from '../util/dom'; import type Map from './map'; import scrollZoom from './handler/scroll_zoom'; diff --git a/src/ui/camera.js b/src/ui/camera.js index 57968fa1b5d..126fc8288ad 100644 --- a/src/ui/camera.js +++ b/src/ui/camera.js @@ -10,12 +10,12 @@ import { ease as defaultEasing, pick } from '../util/util'; -import { number as interpolate } from '../style-spec/util/interpolate'; +import {number as interpolate} from '../style-spec/util/interpolate'; import browser from '../util/browser'; import LngLat from '../geo/lng_lat'; import LngLatBounds from '../geo/lng_lat_bounds'; import Point from '@mapbox/point-geometry'; -import { Event, Evented } from '../util/evented'; +import {Event, Evented} from '../util/evented'; import type Transform from '../geo/transform'; import type {LngLatLike} from '../geo/lng_lat'; diff --git a/src/ui/control/attribution_control.js b/src/ui/control/attribution_control.js index 71122dd2df5..09cfd9219eb 100644 --- a/src/ui/control/attribution_control.js +++ b/src/ui/control/attribution_control.js @@ -1,7 +1,7 @@ // @flow import DOM from '../../util/dom'; -import { bindAll } from '../../util/util'; +import {bindAll} from '../../util/util'; import config from '../../util/config'; import type Map from '../map'; diff --git a/src/ui/control/fullscreen_control.js b/src/ui/control/fullscreen_control.js index 6ede36b8efa..f858ddc21af 100644 --- a/src/ui/control/fullscreen_control.js +++ b/src/ui/control/fullscreen_control.js @@ -2,7 +2,7 @@ import DOM from '../../util/dom'; -import { bindAll, warnOnce } from '../../util/util'; +import {bindAll, warnOnce} from '../../util/util'; import window from '../../util/window'; import type Map from '../map'; diff --git a/src/ui/control/geolocate_control.js b/src/ui/control/geolocate_control.js index f914aca9d74..71a5a593a0d 100644 --- a/src/ui/control/geolocate_control.js +++ b/src/ui/control/geolocate_control.js @@ -1,15 +1,15 @@ // @flow -import { Event, Evented } from '../../util/evented'; +import {Event, Evented} from '../../util/evented'; import DOM from '../../util/dom'; import window from '../../util/window'; -import { extend, bindAll, warnOnce } from '../../util/util'; +import {extend, bindAll, warnOnce} from '../../util/util'; import assert from 'assert'; import LngLat from '../../geo/lng_lat'; import Marker from '../marker'; import type Map from '../map'; -import type { AnimationOptions, CameraOptions } from '../camera'; +import type {AnimationOptions, CameraOptions} from '../camera'; type Options = { positionOptions?: PositionOptions, @@ -43,7 +43,7 @@ function checkGeolocationSupport(callback) { // http://caniuse.com/#feat=permissions-api // Test for the case where a browser disables Geolocation because of an // insecure origin - window.navigator.permissions.query({ name: 'geolocation' }).then((p) => { + window.navigator.permissions.query({name: 'geolocation'}).then((p) => { supportsGeolocation = p.state !== 'denied'; callback(supportsGeolocation); }); diff --git a/src/ui/control/logo_control.js b/src/ui/control/logo_control.js index ee2263c36b2..c7c2e4cbe5c 100644 --- a/src/ui/control/logo_control.js +++ b/src/ui/control/logo_control.js @@ -2,7 +2,7 @@ import DOM from '../../util/dom'; -import { bindAll } from '../../util/util'; +import {bindAll} from '../../util/util'; import type Map from '../map'; diff --git a/src/ui/control/navigation_control.js b/src/ui/control/navigation_control.js index 194e5710943..0d7ce4be0ab 100644 --- a/src/ui/control/navigation_control.js +++ b/src/ui/control/navigation_control.js @@ -1,7 +1,7 @@ // @flow import DOM from '../../util/dom'; -import { extend, bindAll } from '../../util/util'; +import {extend, bindAll} from '../../util/util'; import DragRotateHandler from '../handler/drag_rotate'; import type Map from '../map'; @@ -106,7 +106,7 @@ class NavigationControl { this._rotateCompassArrow(); this._handler = new DragRotateHandler(map, {button: 'left', element: this._compass}); DOM.addEventListener(this._compass, 'mousedown', this._handler.onMouseDown); - DOM.addEventListener(this._compass, 'touchstart', this._handler.onMouseDown, { passive: false }); + DOM.addEventListener(this._compass, 'touchstart', this._handler.onMouseDown, {passive: false}); this._handler.enable(); } return this._container; @@ -123,7 +123,7 @@ class NavigationControl { } this._map.off('rotate', this._rotateCompassArrow); DOM.removeEventListener(this._compass, 'mousedown', this._handler.onMouseDown); - DOM.removeEventListener(this._compass, 'touchstart', this._handler.onMouseDown, { passive: false }); + DOM.removeEventListener(this._compass, 'touchstart', this._handler.onMouseDown, {passive: false}); this._handler.disable(); delete this._handler; } diff --git a/src/ui/control/scale_control.js b/src/ui/control/scale_control.js index 021a1fe4547..f642ef911eb 100644 --- a/src/ui/control/scale_control.js +++ b/src/ui/control/scale_control.js @@ -1,7 +1,7 @@ // @flow import DOM from '../../util/dom'; -import { extend, bindAll } from '../../util/util'; +import {extend, bindAll} from '../../util/util'; import type Map from '../map'; diff --git a/src/ui/events.js b/src/ui/events.js index dcfde5f82ee..a6fe1fdb5b8 100644 --- a/src/ui/events.js +++ b/src/ui/events.js @@ -1,10 +1,10 @@ // @flow -import { Event } from '../util/evented'; +import {Event} from '../util/evented'; import DOM from '../util/dom'; import Point from '@mapbox/point-geometry'; -import { extend } from '../util/util'; +import {extend} from '../util/util'; import type Map from './map'; import type LngLat from '../geo/lng_lat'; @@ -78,7 +78,7 @@ export class MapMouseEvent extends Event { constructor(type: string, map: Map, originalEvent: MouseEvent, data: Object = {}) { const point = DOM.mousePos(map.getCanvasContainer(), originalEvent); const lngLat = map.unproject(point); - super(type, extend({ point, lngLat, originalEvent }, data)); + super(type, extend({point, lngLat, originalEvent}, data)); this._defaultPrevented = false; this.target = map; } @@ -161,7 +161,7 @@ export class MapTouchEvent extends Event { return prev.add(curr.div(arr.length)); }, new Point(0, 0)); const lngLat = map.unproject(point); - super(type, { points, point, lngLats, lngLat, originalEvent }); + super(type, {points, point, lngLats, lngLat, originalEvent}); this._defaultPrevented = false; } } @@ -208,7 +208,7 @@ export class MapWheelEvent extends Event { * @private */ constructor(type: string, map: Map, originalEvent: WheelEvent) { - super(type, { originalEvent }); + super(type, {originalEvent}); this._defaultPrevented = false; } } diff --git a/src/ui/handler/box_zoom.js b/src/ui/handler/box_zoom.js index 3dadc54a9be..5b846a4fde9 100644 --- a/src/ui/handler/box_zoom.js +++ b/src/ui/handler/box_zoom.js @@ -2,9 +2,9 @@ import DOM from '../../util/dom'; -import { bindAll } from '../../util/util'; +import {bindAll} from '../../util/util'; import window from '../../util/window'; -import { Event } from '../../util/evented'; +import {Event} from '../../util/evented'; import type Map from '../map'; @@ -136,7 +136,7 @@ class BoxZoomHandler { } else { this._map .fitScreenCoordinates(p0, p1, this._map.getBearing(), {linear: true}) - .fire(new Event('boxzoomend', { originalEvent: e})); + .fire(new Event('boxzoomend', {originalEvent: e})); } } @@ -168,7 +168,7 @@ class BoxZoomHandler { } _fireEvent(type: string, e: *) { - return this._map.fire(new Event(type, { originalEvent: e })); + return this._map.fire(new Event(type, {originalEvent: e})); } } diff --git a/src/ui/handler/dblclick_zoom.js b/src/ui/handler/dblclick_zoom.js index e4b5f23d21f..ed4f75b5c97 100644 --- a/src/ui/handler/dblclick_zoom.js +++ b/src/ui/handler/dblclick_zoom.js @@ -1,6 +1,6 @@ // @flow -import { bindAll } from '../../util/util'; +import {bindAll} from '../../util/util'; import type Map from '../map'; import type {MapMouseEvent, MapTouchEvent} from '../events'; diff --git a/src/ui/handler/drag_pan.js b/src/ui/handler/drag_pan.js index e39b0346e91..9b159e3c6c8 100644 --- a/src/ui/handler/drag_pan.js +++ b/src/ui/handler/drag_pan.js @@ -1,10 +1,10 @@ // @flow import DOM from '../../util/dom'; -import { bezier, bindAll } from '../../util/util'; +import {bezier, bindAll} from '../../util/util'; import window from '../../util/window'; import browser from '../../util/browser'; -import { Event } from '../../util/evented'; +import {Event} from '../../util/evented'; import assert from 'assert'; import type Map from '../map'; @@ -307,11 +307,11 @@ class DragPanHandler { duration: duration * 1000, easing: inertiaEasing, noMoveStart: true - }, { originalEvent: e }); + }, {originalEvent: e}); } _fireEvent(type: string, e: *) { - return this._map.fire(new Event(type, e ? { originalEvent: e } : {})); + return this._map.fire(new Event(type, e ? {originalEvent: e} : {})); } _drainInertiaBuffer() { diff --git a/src/ui/handler/drag_rotate.js b/src/ui/handler/drag_rotate.js index be201e0bbb5..2f45978aa66 100644 --- a/src/ui/handler/drag_rotate.js +++ b/src/ui/handler/drag_rotate.js @@ -2,10 +2,10 @@ import DOM from '../../util/dom'; -import { bezier, bindAll } from '../../util/util'; +import {bezier, bindAll} from '../../util/util'; import window from '../../util/window'; import browser from '../../util/browser'; -import { Event } from '../../util/evented'; +import {Event} from '../../util/evented'; import assert from 'assert'; import type Map from '../map'; @@ -152,10 +152,10 @@ class DragRotateHandler { // fall outside the map canvas element. Use `{capture: true}` for the move event // to prevent map move events from being fired during a drag. if (touchEvent) { - window.document.addEventListener('touchmove', this._onMouseMove, { capture: true }); + window.document.addEventListener('touchmove', this._onMouseMove, {capture: true}); window.document.addEventListener('touchend', this._onMouseUp); } else { - window.document.addEventListener('mousemove', this._onMouseMove, { capture: true }); + window.document.addEventListener('mousemove', this._onMouseMove, {capture: true}); window.document.addEventListener('mouseup', this._onMouseUp); } @@ -275,9 +275,9 @@ class DragRotateHandler { } _unbind() { - window.document.removeEventListener('mousemove', this._onMouseMove, { capture: true }); + window.document.removeEventListener('mousemove', this._onMouseMove, {capture: true}); window.document.removeEventListener('mouseup', this._onMouseUp); - window.document.removeEventListener('touchmove', this._onMouseMove, { capture: true }); + window.document.removeEventListener('touchmove', this._onMouseMove, {capture: true}); window.document.removeEventListener('touchend', this._onMouseUp); window.removeEventListener('blur', this._onBlur); DOM.enableDrag(); @@ -304,7 +304,7 @@ class DragRotateHandler { const finish = () => { if (Math.abs(mapBearing) < this._bearingSnap) { - map.resetNorth({noMoveStart: true}, { originalEvent: e }); + map.resetNorth({noMoveStart: true}, {originalEvent: e}); } else { this._fireEvent('moveend', e); } @@ -347,11 +347,11 @@ class DragRotateHandler { duration: duration * 1000, easing: inertiaEasing, noMoveStart: true - }, { originalEvent: e }); + }, {originalEvent: e}); } _fireEvent(type: string, e: *) { - return this._map.fire(new Event(type, e ? { originalEvent: e } : {})); + return this._map.fire(new Event(type, e ? {originalEvent: e} : {})); } _drainInertiaBuffer() { diff --git a/src/ui/handler/keyboard.js b/src/ui/handler/keyboard.js index b103746a271..2d98e8b3df2 100644 --- a/src/ui/handler/keyboard.js +++ b/src/ui/handler/keyboard.js @@ -1,6 +1,6 @@ // @flow -import { bindAll } from '../../util/util'; +import {bindAll} from '../../util/util'; import type Map from '../map'; diff --git a/src/ui/handler/scroll_zoom.js b/src/ui/handler/scroll_zoom.js index 7e58131cdd2..6e93ca0db3a 100644 --- a/src/ui/handler/scroll_zoom.js +++ b/src/ui/handler/scroll_zoom.js @@ -3,12 +3,12 @@ import assert from 'assert'; import DOM from '../../util/dom'; -import { ease as _ease, bindAll, bezier } from '../../util/util'; +import {ease as _ease, bindAll, bezier} from '../../util/util'; import browser from '../../util/browser'; import window from '../../util/window'; -import { number as interpolate } from '../../style-spec/util/interpolate'; +import {number as interpolate} from '../../style-spec/util/interpolate'; import LngLat from '../../geo/lng_lat'; -import { Event } from '../../util/evented'; +import {Event} from '../../util/evented'; import type Map from '../map'; import type Point from '@mapbox/point-geometry'; diff --git a/src/ui/handler/touch_zoom_rotate.js b/src/ui/handler/touch_zoom_rotate.js index 0f2ab959d81..8c26daa8833 100644 --- a/src/ui/handler/touch_zoom_rotate.js +++ b/src/ui/handler/touch_zoom_rotate.js @@ -1,10 +1,10 @@ // @flow import DOM from '../../util/dom'; -import { bezier, bindAll } from '../../util/util'; +import {bezier, bindAll} from '../../util/util'; import window from '../../util/window'; import browser from '../../util/browser'; -import { Event } from '../../util/evented'; +import {Event} from '../../util/evented'; import type Map from '../map'; import type Point from '@mapbox/point-geometry'; @@ -161,8 +161,8 @@ class TouchZoomRotateHandler { } if (this._gestureIntent) { - this._map.fire(new Event(`${this._gestureIntent}start`, { originalEvent: e })); - this._map.fire(new Event('movestart', { originalEvent: e })); + this._map.fire(new Event(`${this._gestureIntent}start`, {originalEvent: e})); + this._map.fire(new Event('movestart', {originalEvent: e})); this._startVec = vec; } } @@ -225,7 +225,7 @@ class TouchZoomRotateHandler { if (!gestureIntent) return; - this._map.fire(new Event(`${gestureIntent}end`, { originalEvent: e })); + this._map.fire(new Event(`${gestureIntent}end`, {originalEvent: e})); this._drainInertiaBuffer(); @@ -233,7 +233,7 @@ class TouchZoomRotateHandler { map = this._map; if (inertia.length < 2) { - map.snapToNorth({}, { originalEvent: e }); + map.snapToNorth({}, {originalEvent: e}); return; } @@ -246,7 +246,7 @@ class TouchZoomRotateHandler { p = last[2]; if (scaleDuration === 0 || lastScale === firstScale) { - map.snapToNorth({}, { originalEvent: e }); + map.snapToNorth({}, {originalEvent: e}); return; } @@ -274,7 +274,7 @@ class TouchZoomRotateHandler { easing: inertiaEasing, around: this._aroundCenter ? map.getCenter() : map.unproject(p), noMoveStart: true - }, { originalEvent: e }); + }, {originalEvent: e}); } _drainInertiaBuffer() { diff --git a/src/ui/hash.js b/src/ui/hash.js index 938accae4fa..eb49227496f 100644 --- a/src/ui/hash.js +++ b/src/ui/hash.js @@ -1,6 +1,6 @@ // @flow -import { bindAll } from '../util/util'; +import {bindAll} from '../util/util'; import window from '../util/window'; import throttle from '../util/throttle'; diff --git a/src/ui/map.js b/src/ui/map.js index 977d952977e..5b9286cda4d 100755 --- a/src/ui/map.js +++ b/src/ui/map.js @@ -1,13 +1,13 @@ // @flow -import { version } from '../../package.json'; -import { extend, bindAll, warnOnce, uniqueId } from '../util/util'; +import {version} from '../../package.json'; +import {extend, bindAll, warnOnce, uniqueId} from '../util/util'; import browser from '../util/browser'; import window from '../util/window'; -const { HTMLImageElement, HTMLElement } = window; +const {HTMLImageElement, HTMLElement} = window; import DOM from '../util/dom'; -import { getImage, getJSON, ResourceType } from '../util/ajax'; -import { RequestManager } from '../util/mapbox'; +import {getImage, getJSON, ResourceType} from '../util/ajax'; +import {RequestManager} from '../util/mapbox'; import Style from '../style/style'; import EvaluationParameters from '../style/evaluation_parameters'; import Painter from '../render/painter'; @@ -21,15 +21,15 @@ import Point from '@mapbox/point-geometry'; import AttributionControl from './control/attribution_control'; import LogoControl from './control/logo_control'; import isSupported from '@mapbox/mapbox-gl-supported'; -import { RGBAImage } from '../util/image'; -import { Event, ErrorEvent } from '../util/evented'; -import { MapMouseEvent } from './events'; +import {RGBAImage} from '../util/image'; +import {Event, ErrorEvent} from '../util/evented'; +import {MapMouseEvent} from './events'; import TaskQueue from '../util/task_queue'; import webpSupported from '../util/webp_supported'; -import { setCacheLimits } from '../util/tile_request_cache'; +import {setCacheLimits} from '../util/tile_request_cache'; import type {PointLike} from '@mapbox/point-geometry'; -import type { RequestTransformFunction } from '../util/mapbox'; +import type {RequestTransformFunction} from '../util/mapbox'; import type {LngLatLike} from '../geo/lng_lat'; import type {LngLatBoundsLike} from '../geo/lng_lat_bounds'; import type {StyleOptions, StyleSetterOptions} from '../style/style'; @@ -391,17 +391,17 @@ class Map extends Camera { if (options.bounds) { this.resize(); - this.fitBounds(options.bounds, extend({}, options.fitBoundsOptions, { duration: 0 })); + this.fitBounds(options.bounds, extend({}, options.fitBoundsOptions, {duration: 0})); } } this.resize(); this._localIdeographFontFamily = options.localIdeographFontFamily; - if (options.style) this.setStyle(options.style, { localIdeographFontFamily: options.localIdeographFontFamily }); + if (options.style) this.setStyle(options.style, {localIdeographFontFamily: options.localIdeographFontFamily}); if (options.attributionControl) - this.addControl(new AttributionControl({ customAttribution: options.customAttribution })); + this.addControl(new AttributionControl({customAttribution: options.customAttribution})); this.addControl(new LogoControl(), options.logoPosition); @@ -965,7 +965,7 @@ class Map extends Camera { * @see [Change a map's style](https://www.mapbox.com/mapbox-gl-js/example/setstyle/) */ setStyle(style: StyleSpecification | string | null, options?: {diff?: boolean} & StyleOptions) { - options = extend({}, { localIdeographFontFamily: this._localIdeographFontFamily}, options); + options = extend({}, {localIdeographFontFamily: this._localIdeographFontFamily}, options); if ((options.diff !== false && options.localIdeographFontFamily === this._localIdeographFontFamily) && this.style && style) { this._diffStyle(style, options); @@ -1163,7 +1163,7 @@ class Map extends Camera { if (image instanceof HTMLImageElement) { const {width, height, data} = browser.getImageData(image); - this.style.addImage(id, { data: new RGBAImage({width, height}, data), pixelRatio, sdf, version }); + this.style.addImage(id, {data: new RGBAImage({width, height}, data), pixelRatio, sdf, version}); } else if (image.width === undefined || image.height === undefined) { return this.fire(new ErrorEvent(new Error( 'Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, ' + diff --git a/src/ui/marker.js b/src/ui/marker.js index 1bf3b6de7e6..5df1db44ad6 100644 --- a/src/ui/marker.js +++ b/src/ui/marker.js @@ -5,9 +5,9 @@ import window from '../util/window'; import LngLat from '../geo/lng_lat'; import Point from '@mapbox/point-geometry'; import smartWrap from '../util/smart_wrap'; -import { bindAll, extend } from '../util/util'; -import { type Anchor, anchorTranslate, applyAnchorClass } from './anchor'; -import { Event, Evented } from '../util/evented'; +import {bindAll, extend} from '../util/util'; +import {type Anchor, anchorTranslate, applyAnchorClass} from './anchor'; +import {Event, Evented} from '../util/evented'; import type Map from './map'; import type Popup from './popup'; import type {LngLatLike} from "../geo/lng_lat"; diff --git a/src/ui/popup.js b/src/ui/popup.js index 36c71f9c642..143b82bb379 100644 --- a/src/ui/popup.js +++ b/src/ui/popup.js @@ -1,13 +1,13 @@ // @flow -import { extend, bindAll } from '../util/util'; -import { Event, Evented } from '../util/evented'; +import {extend, bindAll} from '../util/util'; +import {Event, Evented} from '../util/evented'; import DOM from '../util/dom'; import LngLat from '../geo/lng_lat'; import Point from '@mapbox/point-geometry'; import window from '../util/window'; import smartWrap from '../util/smart_wrap'; -import { type Anchor, anchorTranslate, applyAnchorClass } from './anchor'; +import {type Anchor, anchorTranslate, applyAnchorClass} from './anchor'; import type Map from './map'; import type {LngLatLike} from '../geo/lng_lat'; diff --git a/src/util/actor.js b/src/util/actor.js index af626c8ec30..0724954540c 100644 --- a/src/util/actor.js +++ b/src/util/actor.js @@ -1,7 +1,7 @@ // @flow -import { bindAll } from './util'; -import { serialize, deserialize } from './web_worker_transfer'; +import {bindAll} from './util'; +import {serialize, deserialize} from './web_worker_transfer'; import ThrottledInvoker from './throttled_invoker'; import type {Transferable} from '../types/transferable'; diff --git a/src/util/ajax.js b/src/util/ajax.js index 6bc8efd7126..72e6439837f 100644 --- a/src/util/ajax.js +++ b/src/util/ajax.js @@ -1,14 +1,14 @@ // @flow import window from './window'; -import { extend, warnOnce } from './util'; -import { isMapboxHTTPURL, hasCacheDefeatingSku } from './mapbox'; +import {extend, warnOnce} from './util'; +import {isMapboxHTTPURL, hasCacheDefeatingSku} from './mapbox'; import config from './config'; import assert from 'assert'; -import { cacheGet, cachePut } from './tile_request_cache'; +import {cacheGet, cachePut} from './tile_request_cache'; -import type { Callback } from '../types/callback'; -import type { Cancelable } from '../types/cancelable'; +import type {Callback} from '../types/callback'; +import type {Cancelable} from '../types/cancelable'; /** * The type of a resource. @@ -26,7 +26,7 @@ const ResourceType = { SpriteJSON: 'SpriteJSON', Image: 'Image' }; -export { ResourceType }; +export {ResourceType}; if (typeof Object.freeze == 'function') { Object.freeze(ResourceType); @@ -175,7 +175,7 @@ function makeFetchRequest(requestParameters: RequestParameters, callback: Respon validateOrFetch(null, null); } - return { cancel: () => { + return {cancel: () => { aborted = true; if (!complete) controller.abort(); }}; @@ -216,7 +216,7 @@ function makeXMLHttpRequest(requestParameters: RequestParameters, callback: Resp } }; xhr.send(requestParameters.body); - return { cancel: () => xhr.abort() }; + return {cancel: () => xhr.abort()}; } export const makeRequest = function(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable { @@ -239,15 +239,15 @@ export const makeRequest = function(requestParameters: RequestParameters, callba }; export const getJSON = function(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable { - return makeRequest(extend(requestParameters, { type: 'json' }), callback); + return makeRequest(extend(requestParameters, {type: 'json'}), callback); }; export const getArrayBuffer = function(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable { - return makeRequest(extend(requestParameters, { type: 'arrayBuffer' }), callback); + return makeRequest(extend(requestParameters, {type: 'arrayBuffer'}), callback); }; export const postData = function(requestParameters: RequestParameters, callback: ResponseCallback): Cancelable { - return makeRequest(extend(requestParameters, { method: 'POST' }), callback); + return makeRequest(extend(requestParameters, {method: 'POST'}), callback); }; function sameOrigin(url) { @@ -310,7 +310,7 @@ export const getImage = function(requestParameters: RequestParameters, callback: URL.revokeObjectURL(img.src); }; img.onerror = () => callback(new Error('Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.')); - const blob: Blob = new window.Blob([new Uint8Array(data)], { type: 'image/png' }); + const blob: Blob = new window.Blob([new Uint8Array(data)], {type: 'image/png'}); (img: any).cacheControl = cacheControl; (img: any).expires = expires; img.src = data.byteLength ? URL.createObjectURL(blob) : transparentPngUrl; @@ -339,5 +339,5 @@ export const getVideo = function(urls: Array, callback: Callback {} }; + return {cancel: () => {}}; }; diff --git a/src/util/browser.js b/src/util/browser.js index 773d7a3e08f..8ae14d1906e 100755 --- a/src/util/browser.js +++ b/src/util/browser.js @@ -1,7 +1,7 @@ // @flow strict import window from './window'; -import type { Cancelable } from '../types/cancelable'; +import type {Cancelable} from '../types/cancelable'; const now = window.performance && window.performance.now ? window.performance.now.bind(window.performance) : @@ -33,7 +33,7 @@ const exported = { frame(fn: () => void): Cancelable { const frame = raf(fn); - return { cancel: () => cancel(frame) }; + return {cancel: () => cancel(frame)}; }, getImageData(img: CanvasImageSource, padding?: number = 0): ImageData { diff --git a/src/util/classify_rings.js b/src/util/classify_rings.js index 90a32fceada..3d18b60fcab 100644 --- a/src/util/classify_rings.js +++ b/src/util/classify_rings.js @@ -2,7 +2,7 @@ import quickselect from 'quickselect'; -import { calculateSignedArea } from './util'; +import {calculateSignedArea} from './util'; import type Point from '@mapbox/point-geometry'; diff --git a/src/util/color_ramp.js b/src/util/color_ramp.js index 8dd2c4e08e0..a6c93a6c535 100644 --- a/src/util/color_ramp.js +++ b/src/util/color_ramp.js @@ -1,6 +1,6 @@ // @flow -import { RGBAImage } from './image'; +import {RGBAImage} from './image'; import type {StylePropertyExpression} from '../style-spec/expression/index'; diff --git a/src/util/dispatcher.js b/src/util/dispatcher.js index bb43c1d1864..9ae0f4129d6 100644 --- a/src/util/dispatcher.js +++ b/src/util/dispatcher.js @@ -1,6 +1,6 @@ // @flow -import { uniqueId, asyncAll } from './util'; +import {uniqueId, asyncAll} from './util'; import Actor from './actor'; import type WorkerPool from './worker_pool'; diff --git a/src/util/evented.js b/src/util/evented.js index c522488a252..eeab1a88c79 100644 --- a/src/util/evented.js +++ b/src/util/evented.js @@ -1,6 +1,6 @@ // @flow -import { extend } from './util'; +import {extend} from './util'; type Listener = (Object) => any; type Listeners = { [string]: Array }; diff --git a/src/util/find_pole_of_inaccessibility.js b/src/util/find_pole_of_inaccessibility.js index 1eada64fe96..5bf8c1c44c8 100644 --- a/src/util/find_pole_of_inaccessibility.js +++ b/src/util/find_pole_of_inaccessibility.js @@ -3,7 +3,7 @@ import Queue from 'tinyqueue'; import Point from '@mapbox/point-geometry'; -import { distToSegmentSquared } from './intersection_tests'; +import {distToSegmentSquared} from './intersection_tests'; /** * Finds an approximation of a polygon's Pole Of Inaccessibiliy https://en.wikipedia.org/wiki/Pole_of_inaccessibility diff --git a/src/util/image.js b/src/util/image.js index 89b899490e8..5e14d15f751 100644 --- a/src/util/image.js +++ b/src/util/image.js @@ -2,7 +2,7 @@ import assert from 'assert'; -import { register } from './web_worker_transfer'; +import {register} from './web_worker_transfer'; export type Size = { width: number, diff --git a/src/util/intersection_tests.js b/src/util/intersection_tests.js index 6121ed54346..d79f6f744b3 100644 --- a/src/util/intersection_tests.js +++ b/src/util/intersection_tests.js @@ -1,10 +1,10 @@ // @flow -import { isCounterClockwise } from './util'; +import {isCounterClockwise} from './util'; import Point from '@mapbox/point-geometry'; -export { polygonIntersectsBufferedPoint, polygonIntersectsMultiPolygon, polygonIntersectsBufferedMultiLine, polygonIntersectsPolygon, distToSegmentSquared, polygonIntersectsBox }; +export {polygonIntersectsBufferedPoint, polygonIntersectsMultiPolygon, polygonIntersectsBufferedMultiLine, polygonIntersectsPolygon, distToSegmentSquared, polygonIntersectsBox}; type Line = Array; type MultiLine = Array; diff --git a/src/util/mapbox.js b/src/util/mapbox.js index 7a698859c3e..59e6c53734b 100644 --- a/src/util/mapbox.js +++ b/src/util/mapbox.js @@ -18,14 +18,14 @@ import config from './config'; import browser from './browser'; import window from './window'; import webpSupported from './webp_supported'; -import { createSkuToken, SKU_ID } from './sku_token'; -import { version as sdkVersion } from '../../package.json'; -import { uuid, validateUuid, storageAvailable, b64DecodeUnicode, b64EncodeUnicode, warnOnce, extend } from './util'; -import { postData, ResourceType } from './ajax'; +import {createSkuToken, SKU_ID} from './sku_token'; +import {version as sdkVersion} from '../../package.json'; +import {uuid, validateUuid, storageAvailable, b64DecodeUnicode, b64EncodeUnicode, warnOnce, extend} from './util'; +import {postData, ResourceType} from './ajax'; -import type { RequestParameters } from './ajax'; -import type { Cancelable } from '../types/cancelable'; -import type { TileJSON } from '../types/tilejson'; +import type {RequestParameters} from './ajax'; +import type {Cancelable} from '../types/cancelable'; +import type {TileJSON} from '../types/tilejson'; type ResourceTypeEnum = $Keys; export type RequestTransformFunction = (url: string, resourceType?: ResourceTypeEnum) => RequestParameters; @@ -217,7 +217,7 @@ function formatUrl(obj: UrlObject): string { return `${obj.protocol}://${obj.authority}${obj.path}${params}`; } -export { isMapboxURL, isMapboxHTTPURL, hasCacheDefeatingSku }; +export {isMapboxURL, isMapboxHTTPURL, hasCacheDefeatingSku}; const telemEventKey = 'mapbox.eventData'; diff --git a/src/util/sku_token.js b/src/util/sku_token.js index e448afcb976..990a1c60c1e 100644 --- a/src/util/sku_token.js +++ b/src/util/sku_token.js @@ -33,10 +33,10 @@ function createSkuToken(): SkuTokenObject { const token = [TOKEN_VERSION, SKU_ID, sessionRandomizer].join(''); const tokenExpiresAt = Date.now() + expiration; - return { token, tokenExpiresAt }; + return {token, tokenExpiresAt}; } -export { createSkuToken, SKU_ID }; +export {createSkuToken, SKU_ID}; /***** END WARNING - REMOVAL OR MODIFICATION OF THE PRECEDING CODE VIOLATES THE MAPBOX TERMS OF SERVICE ******/ diff --git a/src/util/struct_array.js b/src/util/struct_array.js index 9bed2979a7d..4b20579fd4d 100644 --- a/src/util/struct_array.js +++ b/src/util/struct_array.js @@ -239,4 +239,4 @@ function align(offset: number, size: number): number { return Math.ceil(offset / size) * size; } -export { StructArray, Struct, viewTypes, createLayout }; +export {StructArray, Struct, viewTypes, createLayout}; diff --git a/src/util/tile_cover.js b/src/util/tile_cover.js index 8bff1f117d6..43fe4e03a70 100644 --- a/src/util/tile_cover.js +++ b/src/util/tile_cover.js @@ -3,7 +3,7 @@ import MercatorCoordinate from '../geo/mercator_coordinate'; import Point from '@mapbox/point-geometry'; -import { OverscaledTileID } from '../source/tile_id'; +import {OverscaledTileID} from '../source/tile_id'; export default tileCover; diff --git a/src/util/tile_request_cache.js b/src/util/tile_request_cache.js index 853b415036d..172d8adf1b0 100644 --- a/src/util/tile_request_cache.js +++ b/src/util/tile_request_cache.js @@ -1,6 +1,6 @@ // @flow -import { parseCacheControl } from './util'; +import {parseCacheControl} from './util'; import window from './window'; import type Dispatcher from './dispatcher'; diff --git a/src/util/util.js b/src/util/util.js index 3044dd9387b..81a3c3706e7 100644 --- a/src/util/util.js +++ b/src/util/util.js @@ -286,7 +286,7 @@ export function filterObject(input: Object, iterator: Function, context?: Object } import deepEqual from '../style-spec/util/deep_equal'; -export { deepEqual }; +export {deepEqual}; /** * Deeply clones two objects. diff --git a/src/util/web_worker_transfer.js b/src/util/web_worker_transfer.js index 2d3817b7e28..6e90b374e09 100644 --- a/src/util/web_worker_transfer.js +++ b/src/util/web_worker_transfer.js @@ -4,11 +4,11 @@ import assert from 'assert'; import Grid from 'grid-index'; import Color from '../style-spec/util/color'; -import { StylePropertyFunction, StyleExpression, ZoomDependentExpression, ZoomConstantExpression } from '../style-spec/expression'; +import {StylePropertyFunction, StyleExpression, ZoomDependentExpression, ZoomConstantExpression} from '../style-spec/expression'; import CompoundExpression from '../style-spec/expression/compound_expression'; import expressions from '../style-spec/expression/definitions'; import window from './window'; -const { ImageData } = window; +const {ImageData} = window; import type {Transferable} from '../types/transferable'; diff --git a/src/util/window.js b/src/util/window.js index 6957f438a60..618f2919f49 100644 --- a/src/util/window.js +++ b/src/util/window.js @@ -13,7 +13,7 @@ import sinon from 'sinon'; import type {Window} from '../types/window'; -const { window: _window } = new jsdom.JSDOM('', { +const {window: _window} = new jsdom.JSDOM('', { virtualConsole: new jsdom.VirtualConsole().sendTo(console) }); @@ -32,7 +32,7 @@ function restore(): Window { } // Create new window and inject into exported object - const { window } = new jsdom.JSDOM('', { + const {window} = new jsdom.JSDOM('', { // Send jsdom console output to the node console object. virtualConsole: new jsdom.VirtualConsole().sendTo(console) }); diff --git a/test/ajax_stubs.js b/test/ajax_stubs.js index fa235faa86d..ab9c4fca1a8 100644 --- a/test/ajax_stubs.js +++ b/test/ajax_stubs.js @@ -22,7 +22,7 @@ const ResourceType = { SpriteJSON: 'SpriteJSON', Image: 'Image' }; -export { ResourceType }; +export {ResourceType}; if (typeof Object.freeze == 'function') { Object.freeze(ResourceType); @@ -36,7 +36,7 @@ function cached(data, callback) { export const getReferrer = () => undefined; -export const getJSON = function({ url }, callback) { +export const getJSON = function({url}, callback) { if (cache[url]) return cached(cache[url], callback); return request(url, (error, response, body) => { if (!error && response.statusCode >= 200 && response.statusCode < 300) { @@ -54,14 +54,14 @@ export const getJSON = function({ url }, callback) { }); }; -export const getArrayBuffer = function({ url }, callback) { +export const getArrayBuffer = function({url}, callback) { if (cache[url]) return cached(cache[url], callback); - return request({ url, encoding: null }, (error, response, body) => { + return request({url, encoding: null}, (error, response, body) => { if (!error && response.statusCode >= 200 && response.statusCode < 300) { cache[url] = body; callback(null, body); } else { - if (!error) error = { status: +response.statusCode }; + if (!error) error = {status: +response.statusCode}; callback(error); } }); @@ -69,7 +69,7 @@ export const getArrayBuffer = function({ url }, callback) { export const makeRequest = getArrayBuffer; -export const postData = function({ url, body }, callback) { +export const postData = function({url, body}, callback) { return request.post(url, body, (error, response, body) => { if (!error && response.statusCode >= 200 && response.statusCode < 300) { callback(null, body); @@ -79,9 +79,9 @@ export const postData = function({ url, body }, callback) { }); }; -export const getImage = function({ url }, callback) { +export const getImage = function({url}, callback) { if (cache[url]) return cached(cache[url], callback); - return request({ url, encoding: null }, (error, response, body) => { + return request({url, encoding: null}, (error, response, body) => { if (!error && response.statusCode >= 200 && response.statusCode < 300) { new PNG().parse(body, (err, png) => { if (err) return callback(err); @@ -108,7 +108,7 @@ browser.getImageData = function({width, height, data}, padding = 0) { // Hack: since node doesn't have any good video codec modules, just grab a png with // the first frame and fake the video API. export const getVideo = function(urls, callback) { - return request({ url: urls[0], encoding: null }, (error, response, body) => { + return request({url: urls[0], encoding: null}, (error, response, body) => { if (!error && response.statusCode >= 200 && response.statusCode < 300) { new PNG().parse(body, (err, png) => { if (err) return callback(err); diff --git a/test/build/min.test.js b/test/build/min.test.js index df13cdf13b8..75c5d64511e 100644 --- a/test/build/min.test.js +++ b/test/build/min.test.js @@ -2,8 +2,8 @@ import {test} from '../util/test'; import fs from 'fs'; import path from 'path'; import reference from '../../src/style-spec/reference/latest'; -import { Linter } from 'eslint'; -import { scripts } from '../../package.json'; +import {Linter} from 'eslint'; +import {scripts} from '../../package.json'; const minBundle = fs.readFileSync('dist/mapbox-gl.js', 'utf8'); diff --git a/test/build/published-flow-types.js b/test/build/published-flow-types.js index 59c6fa03dcc..d691f8d4a80 100644 --- a/test/build/published-flow-types.js +++ b/test/build/published-flow-types.js @@ -1,4 +1,4 @@ -import { test } from '../util/test'; +import {test} from '../util/test'; import cp from 'child_process'; test('downstream projects can consume published flow types', (t) => { diff --git a/test/build/style-spec.test.js b/test/build/style-spec.test.js index 85be336c2fd..4d98121e42d 100644 --- a/test/build/style-spec.test.js +++ b/test/build/style-spec.test.js @@ -8,7 +8,7 @@ const isBuiltin = require('is-builtin-module'); const Linter = require('eslint').Linter; const rollup = require('rollup'); -import { test } from '../util/test'; +import {test} from '../util/test'; import rollupConfig from '../../src/style-spec/rollup.config'; // some paths diff --git a/test/expression.test.js b/test/expression.test.js index b2c9f4c4843..3fc046eb36e 100644 --- a/test/expression.test.js +++ b/test/expression.test.js @@ -1,8 +1,8 @@ -import { run } from './integration/lib/expression'; -import { createPropertyExpression } from '../src/style-spec/expression'; -import { isFunction } from '../src/style-spec/function'; +import {run} from './integration/lib/expression'; +import {createPropertyExpression} from '../src/style-spec/expression'; +import {isFunction} from '../src/style-spec/function'; import convertFunction from '../src/style-spec/function/convert'; -import { toString } from '../src/style-spec/expression/types'; +import {toString} from '../src/style-spec/expression/types'; import ignores from './ignores.json'; let tests; @@ -11,7 +11,7 @@ if (process.argv[1] === __filename && process.argv.length > 2) { tests = process.argv.slice(2); } -run('js', { ignores, tests }, (fixture) => { +run('js', {ignores, tests}, (fixture) => { const spec = Object.assign({}, fixture.propertySpec); if (!spec['property-type']) { @@ -47,7 +47,7 @@ run('js', { ignores, tests }, (fixture) => { for (const input of fixture.inputs || []) { try { - const feature = { properties: input[1].properties || {} }; + const feature = {properties: input[1].properties || {}}; if ('id' in input[1]) { feature.id = input[1].id; } @@ -61,9 +61,9 @@ run('js', { ignores, tests }, (fixture) => { evaluationResult.push(value); } catch (error) { if (error.name === 'ExpressionEvaluationError') { - evaluationResult.push({ error: error.toJSON() }); + evaluationResult.push({error: error.toJSON()}); } else { - evaluationResult.push({ error: error.message }); + evaluationResult.push({error: error.message}); } } } @@ -73,7 +73,7 @@ run('js', { ignores, tests }, (fixture) => { } }; - const result = { compiled: {}, recompiled: {} }; + const result = {compiled: {}, recompiled: {}}; const expression = (() => { if (isFunction(fixture.expression)) { return createPropertyExpression(convertFunction(fixture.expression, spec), spec); diff --git a/test/integration/lib/harness.js b/test/integration/lib/harness.js index 5afda7c4fe8..d12cedc5773 100644 --- a/test/integration/lib/harness.js +++ b/test/integration/lib/harness.js @@ -179,7 +179,7 @@ export default function (directory, implementation, options, run) { const unsuccessful = tests.filter(test => test.status === 'failed' || test.status === 'errored'); - const resultsShell = resultsTemplate({ unsuccessful, tests, stats, shuffle: options.shuffle, seed: options.seed }) + const resultsShell = resultsTemplate({unsuccessful, tests, stats, shuffle: options.shuffle, seed: options.seed}) .split(''); const p = path.join(directory, options.recycleMap ? 'index-recycle-map.html' : 'index.html'); @@ -188,7 +188,7 @@ export default function (directory, implementation, options, run) { const q = queue(1); q.defer(write, out, resultsShell[0]); for (const test of tests) { - q.defer(write, out, itemTemplate({ r: test, hasFailedTests: unsuccessful.length > 0 })); + q.defer(write, out, itemTemplate({r: test, hasFailedTests: unsuccessful.length > 0})); } q.defer(write, out, resultsShell[1]); q.await(() => { diff --git a/test/integration/lib/render.js b/test/integration/lib/render.js index 345073443f7..e2846a47c0b 100644 --- a/test/integration/lib/render.js +++ b/test/integration/lib/render.js @@ -37,7 +37,7 @@ import * as glob from 'glob'; * @returns {undefined} terminates the process when testing is complete */ export function run(implementation, ignores, render) { - const options = { ignores, tests:[], shuffle:false, recycleMap:false, seed:makeHash() }; + const options = {ignores, tests:[], shuffle:false, recycleMap:false, seed:makeHash()}; // https://stackoverflow.com/a/1349426/229714 function makeHash() { diff --git a/test/integration/lib/server.js b/test/integration/lib/server.js index 3a3199cb003..636c08a7f7e 100644 --- a/test/integration/lib/server.js +++ b/test/integration/lib/server.js @@ -117,7 +117,7 @@ export default function () { localizeStyleURLs(styleJSON); op[1] = styleJSON; - op[2] = { diff: false }; + op[2] = {diff: false}; } }); } diff --git a/test/integration/tiles/upgrade.js b/test/integration/tiles/upgrade.js index bb4ffd38f0a..1ee44f24bb1 100644 --- a/test/integration/tiles/upgrade.js +++ b/test/integration/tiles/upgrade.js @@ -18,7 +18,7 @@ function upgrade(z, x, y, path, callback) { function createExtent1024(callback) { console.log('Creating extent1024'); const buffer = fs.readFileSync('14-8802-5374.mvt'); - const vt = new mapnik.VectorTile(14, 8802, 5374, { tileSize: 1024 }); + const vt = new mapnik.VectorTile(14, 8802, 5374, {tileSize: 1024}); vt.addData(buffer, {validate: true}, (err) => { if (err) throw err; fs.writeFileSync('extent1024-14-8802-5374.mvt', vt.getDataSync()); diff --git a/test/suite_implementation.js b/test/suite_implementation.js index bc9554002df..7c597f74f0f 100644 --- a/test/suite_implementation.js +++ b/test/suite_implementation.js @@ -170,7 +170,7 @@ module.exports = function(style, options, _callback) { // eslint-disable-line im } else if (operation[0] === 'setStyle') { // Disable local ideograph generation (enabled by default) for // consistent local ideograph rendering using fixtures in all runs of the test suite. - map.setStyle(operation[1], { localIdeographFontFamily: false }); + map.setStyle(operation[1], {localIdeographFontFamily: false}); applyOperations(map, operations.slice(1), callback); } else { map[operation[0]](...operation.slice(1)); diff --git a/test/unit/data/dem_data.test.js b/test/unit/data/dem_data.test.js index 5b412183b7d..4f9627d37e2 100644 --- a/test/unit/data/dem_data.test.js +++ b/test/unit/data/dem_data.test.js @@ -1,7 +1,7 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import DEMData from '../../../src/data/dem_data'; -import { RGBAImage } from '../../../src/util/image'; -import { serialize, deserialize } from '../../../src/util/web_worker_transfer'; +import {RGBAImage} from '../../../src/util/image'; +import {serialize, deserialize} from '../../../src/util/web_worker_transfer'; function createMockImage(height, width) { // RGBAImage passed to constructor has uniform 1px padding on all sides. diff --git a/test/unit/data/feature_position_map.test.js b/test/unit/data/feature_position_map.test.js index 52ed9aade54..b450f05efe7 100644 --- a/test/unit/data/feature_position_map.test.js +++ b/test/unit/data/feature_position_map.test.js @@ -1,7 +1,7 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import FeatureMap from '../../../src/data/feature_position_map'; -import { serialize, deserialize } from '../../../src/util/web_worker_transfer'; +import {serialize, deserialize} from '../../../src/util/web_worker_transfer'; test('FeaturePositionMap', (t) => { diff --git a/test/unit/data/fill_bucket.test.js b/test/unit/data/fill_bucket.test.js index cf1e950d920..ad18a695be1 100644 --- a/test/unit/data/fill_bucket.test.js +++ b/test/unit/data/fill_bucket.test.js @@ -1,8 +1,8 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import fs from 'fs'; import path from 'path'; import Protobuf from 'pbf'; -import { VectorTile } from '@mapbox/vector-tile'; +import {VectorTile} from '@mapbox/vector-tile'; import Point from '@mapbox/point-geometry'; import segment from '../../../src/data/segment'; import FillBucket from '../../../src/data/bucket/fill_bucket'; @@ -21,10 +21,10 @@ function createPolygon(numPoints) { } test('FillBucket', (t) => { - const layer = new FillStyleLayer({ id: 'test', type: 'fill', layout: {} }); + const layer = new FillStyleLayer({id: 'test', type: 'fill', layout: {}}); layer.recalculate({zoom: 0, zoomHistory: {}}); - const bucket = new FillBucket({ layers: [layer] }); + const bucket = new FillBucket({layers: [layer]}); bucket.addFeature({}, [[ new Point(0, 0), @@ -57,7 +57,7 @@ test('FillBucket segmentation', (t) => { }); layer.recalculate({zoom: 0, zoomHistory: {}}); - const bucket = new FillBucket({ layers: [layer] }); + const bucket = new FillBucket({layers: [layer]}); // first add an initial, small feature to make sure the next one starts at // a non-zero offset diff --git a/test/unit/data/line_bucket.test.js b/test/unit/data/line_bucket.test.js index e62bdd99db2..5660a98a7bb 100644 --- a/test/unit/data/line_bucket.test.js +++ b/test/unit/data/line_bucket.test.js @@ -1,8 +1,8 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import fs from 'fs'; import path from 'path'; import Protobuf from 'pbf'; -import { VectorTile } from '@mapbox/vector-tile'; +import {VectorTile} from '@mapbox/vector-tile'; import Point from '@mapbox/point-geometry'; import segment from '../../../src/data/segment'; import LineBucket from '../../../src/data/bucket/line_bucket'; @@ -21,10 +21,10 @@ function createLine(numPoints) { } test('LineBucket', (t) => { - const layer = new LineStyleLayer({ id: 'test', type: 'line' }); + const layer = new LineStyleLayer({id: 'test', type: 'line'}); layer.recalculate({zoom: 0, zoomHistory: {}}); - const bucket = new LineBucket({ layers: [layer] }); + const bucket = new LineBucket({layers: [layer]}); const line = { type: 2, @@ -104,10 +104,10 @@ test('LineBucket segmentation', (t) => { // breaking across array groups without tests taking a _long_ time. t.stub(segment, 'MAX_VERTEX_ARRAY_LENGTH').value(256); - const layer = new LineStyleLayer({ id: 'test', type: 'line' }); + const layer = new LineStyleLayer({id: 'test', type: 'line'}); layer.recalculate({zoom: 0, zoomHistory: {}}); - const bucket = new LineBucket({ layers: [layer] }); + const bucket = new LineBucket({layers: [layer]}); // first add an initial, small feature to make sure the next one starts at // a non-zero offset diff --git a/test/unit/data/load_geometry.test.js b/test/unit/data/load_geometry.test.js index 4adb556eda7..1ad2269f35d 100644 --- a/test/unit/data/load_geometry.test.js +++ b/test/unit/data/load_geometry.test.js @@ -1,8 +1,8 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import fs from 'fs'; import path from 'path'; import Protobuf from 'pbf'; -import { VectorTile } from '@mapbox/vector-tile'; +import {VectorTile} from '@mapbox/vector-tile'; import loadGeometry from '../../../src/data/load_geometry.js'; // Load a line feature from fixture tile. diff --git a/test/unit/data/symbol_bucket.test.js b/test/unit/data/symbol_bucket.test.js index 3d9a9108a2a..5a1355c969b 100644 --- a/test/unit/data/symbol_bucket.test.js +++ b/test/unit/data/symbol_bucket.test.js @@ -1,16 +1,16 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import fs from 'fs'; import path from 'path'; import Protobuf from 'pbf'; -import { VectorTile } from '@mapbox/vector-tile'; +import {VectorTile} from '@mapbox/vector-tile'; import SymbolBucket from '../../../src/data/bucket/symbol_bucket'; -import { CollisionBoxArray } from '../../../src/data/array_types'; +import {CollisionBoxArray} from '../../../src/data/array_types'; import SymbolStyleLayer from '../../../src/style/style_layer/symbol_style_layer'; import featureFilter from '../../../src/style-spec/feature_filter'; -import { performSymbolLayout } from '../../../src/symbol/symbol_layout'; -import { Placement } from '../../../src/symbol/placement'; +import {performSymbolLayout} from '../../../src/symbol/symbol_layout'; +import {Placement} from '../../../src/symbol/placement'; import Transform from '../../../src/geo/transform'; -import { OverscaledTileID } from '../../../src/source/tile_id'; +import {OverscaledTileID} from '../../../src/source/tile_id'; import Tile from '../../../src/source/tile'; import CrossTileSymbolIndex from '../../../src/symbol/cross_tile_symbol_index'; import FeatureIndex from '../../../src/data/feature_index'; @@ -27,13 +27,13 @@ transform.width = 100; transform.height = 100; transform.cameraToCenterDistance = 100; -const stacks = { 'Test': glyphs }; +const stacks = {'Test': glyphs}; function bucketSetup() { const layer = new SymbolStyleLayer({ id: 'test', type: 'symbol', - layout: { 'text-font': ['Test'], 'text-field': 'abcde' }, + layout: {'text-font': ['Test'], 'text-field': 'abcde'}, filter: featureFilter() }); layer.recalculate({zoom: 0, zoomHistory: {}}); @@ -59,14 +59,14 @@ test('SymbolBucket', (t) => { performSymbolLayout(bucketA, stacks, {}); const tileA = new Tile(tileID, 512); tileA.latestFeatureIndex = new FeatureIndex(tileID); - tileA.buckets = { test: bucketA }; + tileA.buckets = {test: bucketA}; tileA.collisionBoxArray = collisionBoxArray; // add same feature from bucket B bucketB.populate([{feature}], options); performSymbolLayout(bucketB, stacks, {}); const tileB = new Tile(tileID, 512); - tileB.buckets = { test: bucketB }; + tileB.buckets = {test: bucketB}; tileB.collisionBoxArray = collisionBoxArray; crossTileSymbolIndex.addLayer(bucketA.layers[0], [tileA, tileB]); @@ -91,8 +91,8 @@ test('SymbolBucket integer overflow', (t) => { const options = {iconDependencies: {}, glyphDependencies: {}}; bucket.populate([{feature}], options); - const fakeGlyph = { rect: { w: 10, h: 10 }, metrics: { left: 10, top: 10, advance: 10 } }; - performSymbolLayout(bucket, stacks, { 'Test': {97: fakeGlyph, 98: fakeGlyph, 99: fakeGlyph, 100: fakeGlyph, 101: fakeGlyph, 102: fakeGlyph} }); + const fakeGlyph = {rect: {w: 10, h: 10}, metrics: {left: 10, top: 10, advance: 10}}; + performSymbolLayout(bucket, stacks, {'Test': {97: fakeGlyph, 98: fakeGlyph, 99: fakeGlyph, 100: fakeGlyph, 101: fakeGlyph, 102: fakeGlyph}}); t.ok(console.warn.calledOnce); t.ok(console.warn.getCall(0).calledWithMatch(/Too many glyphs being rendered in a tile./)); diff --git a/test/unit/data/vertex_buffer.test.js b/test/unit/data/vertex_buffer.test.js index bb8256b1b1f..464359eaa02 100644 --- a/test/unit/data/vertex_buffer.test.js +++ b/test/unit/data/vertex_buffer.test.js @@ -1,13 +1,13 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import VertexBuffer from '../../../src/gl/vertex_buffer'; -import { StructArrayLayout3i6 } from '../../../src/data/array_types'; +import {StructArrayLayout3i6} from '../../../src/data/array_types'; import Context from '../../../src/gl/context'; test('VertexBuffer', (t) => { class TestArray extends StructArrayLayout3i6 {} const attributes = [ - { name: 'map', components: 1, type: 'Int16', offset: 0 }, - { name: 'box', components: 2, type: 'Int16', offset: 4 } + {name: 'map', components: 1, type: 'Int16', offset: 0}, + {name: 'box', components: 2, type: 'Int16', offset: 4} ]; t.test('constructs itself', (t) => { @@ -20,8 +20,8 @@ test('VertexBuffer', (t) => { const buffer = new VertexBuffer(context, array, attributes); t.deepEqual(buffer.attributes, [ - { name: 'map', components: 1, type: 'Int16', offset: 0 }, - { name: 'box', components: 2, type: 'Int16', offset: 4 } + {name: 'map', components: 1, type: 'Int16', offset: 0}, + {name: 'box', components: 2, type: 'Int16', offset: 4} ]); t.deepEqual(buffer.itemSize, 6); t.deepEqual(buffer.length, 3); @@ -33,7 +33,7 @@ test('VertexBuffer', (t) => { const array = new TestArray(); const buffer = new VertexBuffer(context, array, attributes); t.stub(context.gl, 'enableVertexAttribArray').callsFake(() => {}); - buffer.enableAttributes(context.gl, { attributes: { map: 5, box: 6 } }); + buffer.enableAttributes(context.gl, {attributes: {map: 5, box: 6}}); t.deepEqual(context.gl.enableVertexAttribArray.args, [[5], [6]]); t.end(); }); @@ -43,7 +43,7 @@ test('VertexBuffer', (t) => { const array = new TestArray(); const buffer = new VertexBuffer(context, array, attributes); t.stub(context.gl, 'vertexAttribPointer').callsFake(() => {}); - buffer.setVertexAttribPointers(context.gl, { attributes: { map: 5, box: 6 } }, 50); + buffer.setVertexAttribPointers(context.gl, {attributes: {map: 5, box: 6}}, 50); t.deepEqual(context.gl.vertexAttribPointer.args, [ [5, 1, context.gl['SHORT'], false, 6, 300], [6, 2, context.gl['SHORT'], false, 6, 304] diff --git a/test/unit/geo/lng_lat.test.js b/test/unit/geo/lng_lat.test.js index 4ef48b1b65a..469b4eb12c2 100644 --- a/test/unit/geo/lng_lat.test.js +++ b/test/unit/geo/lng_lat.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import LngLat from '../../../src/geo/lng_lat'; test('LngLat', (t) => { @@ -39,10 +39,10 @@ test('LngLat', (t) => { }); t.test('#wrap', (t) => { - t.deepEqual(new LngLat(0, 0).wrap(), { lng: 0, lat: 0 }); - t.deepEqual(new LngLat(10, 20).wrap(), { lng: 10, lat: 20 }); - t.deepEqual(new LngLat(360, 0).wrap(), { lng: 0, lat: 0 }); - t.deepEqual(new LngLat(190, 0).wrap(), { lng: -170, lat: 0 }); + t.deepEqual(new LngLat(0, 0).wrap(), {lng: 0, lat: 0}); + t.deepEqual(new LngLat(10, 20).wrap(), {lng: 10, lat: 20}); + t.deepEqual(new LngLat(360, 0).wrap(), {lng: 0, lat: 0}); + t.deepEqual(new LngLat(190, 0).wrap(), {lng: -170, lat: 0}); t.end(); }); diff --git a/test/unit/geo/lng_lat_bounds.test.js b/test/unit/geo/lng_lat_bounds.test.js index 8f616521502..ee85fad9ff7 100644 --- a/test/unit/geo/lng_lat_bounds.test.js +++ b/test/unit/geo/lng_lat_bounds.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import LngLat from '../../../src/geo/lng_lat'; import LngLatBounds from '../../../src/geo/lng_lat_bounds'; diff --git a/test/unit/geo/mercator_coordinate.test.js b/test/unit/geo/mercator_coordinate.test.js index d7acb1393da..097a03be44e 100644 --- a/test/unit/geo/mercator_coordinate.test.js +++ b/test/unit/geo/mercator_coordinate.test.js @@ -1,6 +1,6 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import LngLat from '../../../src/geo/lng_lat'; -import MercatorCoordinate, { mercatorScale } from '../../../src/geo/mercator_coordinate'; +import MercatorCoordinate, {mercatorScale} from '../../../src/geo/mercator_coordinate'; test('LngLat', (t) => { t.test('#constructor', (t) => { @@ -11,13 +11,13 @@ test('LngLat', (t) => { t.test('#fromLngLat', (t) => { const nullIsland = new LngLat(0, 0); - t.deepEqual(MercatorCoordinate.fromLngLat(nullIsland), { x: 0.5, y: 0.5, z: 0 }); + t.deepEqual(MercatorCoordinate.fromLngLat(nullIsland), {x: 0.5, y: 0.5, z: 0}); t.end(); }); t.test('#toLngLat', (t) => { const dc = new LngLat(-77, 39); - t.deepEqual(MercatorCoordinate.fromLngLat(dc, 500).toLngLat(), { lng: -77, lat: 39 }); + t.deepEqual(MercatorCoordinate.fromLngLat(dc, 500).toLngLat(), {lng: -77, lat: 39}); t.end(); }); diff --git a/test/unit/geo/transform.test.js b/test/unit/geo/transform.test.js index c28ce5da496..ac7fcbaa13d 100644 --- a/test/unit/geo/transform.test.js +++ b/test/unit/geo/transform.test.js @@ -1,8 +1,8 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import Point from '@mapbox/point-geometry'; import Transform from '../../../src/geo/transform'; import LngLat from '../../../src/geo/lng_lat'; -import { OverscaledTileID, CanonicalTileID } from '../../../src/source/tile_id'; +import {OverscaledTileID, CanonicalTileID} from '../../../src/source/tile_id'; import {fixedLngLat, fixedCoord} from '../../util/fixed'; test('transform', (t) => { @@ -24,7 +24,7 @@ test('transform', (t) => { t.equal(transform.minZoom = 10, 10); t.equal(transform.maxZoom = 10, 10); t.equal(transform.minZoom, 10); - t.deepEqual(transform.center, { lng: 0, lat: 0 }); + t.deepEqual(transform.center, {lng: 0, lat: 0}); t.equal(transform.maxZoom, 10); t.equal(transform.size.equals(new Point(500, 500)), true); t.equal(transform.centerPoint.equals(new Point(250, 250)), true); @@ -32,10 +32,10 @@ test('transform', (t) => { t.equal(transform.scaleZoom(10), 3.3219280948873626); t.deepEqual(transform.point, new Point(262144, 262144)); t.equal(transform.height, 500); - t.deepEqual(fixedLngLat(transform.pointLocation(new Point(250, 250))), { lng: 0, lat: 0 }); - t.deepEqual(fixedCoord(transform.pointCoordinate(new Point(250, 250))), { x: 0.5, y: 0.5, z: 0 }); - t.deepEqual(transform.locationPoint(new LngLat(0, 0)), { x: 250, y: 250 }); - t.deepEqual(transform.locationCoordinate(new LngLat(0, 0)), { x: 0.5, y: 0.5, z: 0 }); + t.deepEqual(fixedLngLat(transform.pointLocation(new Point(250, 250))), {lng: 0, lat: 0}); + t.deepEqual(fixedCoord(transform.pointCoordinate(new Point(250, 250))), {x: 0.5, y: 0.5, z: 0}); + t.deepEqual(transform.locationPoint(new LngLat(0, 0)), {x: 250, y: 250}); + t.deepEqual(transform.locationCoordinate(new LngLat(0, 0)), {x: 0.5, y: 0.5, z: 0}); t.end(); }); @@ -50,9 +50,9 @@ test('transform', (t) => { const transform = new Transform(); transform.resize(500, 500); transform.zoom = 4; - t.deepEqual(transform.center, { lng: 0, lat: 0 }); - transform.setLocationAtPoint({ lng: 13, lat: 10 }, new Point(15, 45)); - t.deepEqual(fixedLngLat(transform.pointLocation(new Point(15, 45))), { lng: 13, lat: 10 }); + t.deepEqual(transform.center, {lng: 0, lat: 0}); + transform.setLocationAtPoint({lng: 13, lat: 10}, new Point(15, 45)); + t.deepEqual(fixedLngLat(transform.pointLocation(new Point(15, 45))), {lng: 13, lat: 10}); t.end(); }); @@ -61,9 +61,9 @@ test('transform', (t) => { transform.resize(500, 500); transform.zoom = 4; transform.pitch = 50; - t.deepEqual(transform.center, { lng: 0, lat: 0 }); - transform.setLocationAtPoint({ lng: 13, lat: 10 }, new Point(15, 45)); - t.deepEqual(fixedLngLat(transform.pointLocation(new Point(15, 45))), { lng: 13, lat: 10 }); + t.deepEqual(transform.center, {lng: 0, lat: 0}); + transform.setLocationAtPoint({lng: 13, lat: 10}, new Point(15, 45)); + t.deepEqual(fixedLngLat(transform.pointLocation(new Point(15, 45))), {lng: 13, lat: 10}); t.end(); }); @@ -117,7 +117,7 @@ test('transform', (t) => { transform.resize(200, 200); // make slightly off center so that sort order is not subject to precision issues - transform.center = { lng: -0.01, lat: 0.01 }; + transform.center = {lng: -0.01, lat: 0.01}; transform.zoom = 0; t.deepEqual(transform.coveringTiles(options), []); @@ -240,7 +240,7 @@ test('transform', (t) => { const transform = new Transform(); transform.resize(200, 200); transform.zoom = 0; - transform.center = { lng: -170.01, lat: 0.01 }; + transform.center = {lng: -170.01, lat: 0.01}; let unwrappedCoords = transform.getVisibleUnwrappedCoordinates(new CanonicalTileID(0, 0, 0)); t.equal(unwrappedCoords.length, 4); diff --git a/test/unit/gl/state.test.js b/test/unit/gl/state.test.js index b0e6b73e20d..eb3f4bb0a15 100644 --- a/test/unit/gl/state.test.js +++ b/test/unit/gl/state.test.js @@ -1,8 +1,8 @@ -import { test } from '../../util/test'; -import { ClearColor, ClearDepth, ClearStencil, ColorMask, DepthMask, StencilMask, StencilFunc, StencilOp, StencilTest, DepthRange, DepthTest, DepthFunc, Blend, BlendFunc, BlendColor, Program, ActiveTextureUnit, Viewport, BindFramebuffer, BindRenderbuffer, BindTexture, BindVertexBuffer, BindElementBuffer, BindVertexArrayOES, PixelStoreUnpack, PixelStoreUnpackPremultiplyAlpha } from '../../../src/gl/value'; +import {test} from '../../util/test'; +import {ClearColor, ClearDepth, ClearStencil, ColorMask, DepthMask, StencilMask, StencilFunc, StencilOp, StencilTest, DepthRange, DepthTest, DepthFunc, Blend, BlendFunc, BlendColor, Program, ActiveTextureUnit, Viewport, BindFramebuffer, BindRenderbuffer, BindTexture, BindVertexBuffer, BindElementBuffer, BindVertexArrayOES, PixelStoreUnpack, PixelStoreUnpackPremultiplyAlpha} from '../../../src/gl/value'; import Context from '../../../src/gl/context'; import Color from '../../../src/style-spec/util/color'; -import { deepEqual } from '../../../src/util/util'; +import {deepEqual} from '../../../src/util/util'; const context = new Context(require('gl')(10, 10)); diff --git a/test/unit/mapbox-gl.js b/test/unit/mapbox-gl.js index 3c05c0f37ad..3b3764fb7a7 100644 --- a/test/unit/mapbox-gl.js +++ b/test/unit/mapbox-gl.js @@ -1,4 +1,4 @@ -import { test } from '../util/test'; +import {test} from '../util/test'; import mapboxgl from '../../src'; test('mapboxgl', (t) => { diff --git a/test/unit/render/glyph_manager.test.js b/test/unit/render/glyph_manager.test.js index d357062c499..b03b9036b2f 100644 --- a/test/unit/render/glyph_manager.test.js +++ b/test/unit/render/glyph_manager.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import parseGlyphPBF from '../../../src/style/parse_glyph_pbf'; import GlyphManager from '../../../src/render/glyph_manager'; import fs from 'fs'; diff --git a/test/unit/render/uniform_binding.test.js b/test/unit/render/uniform_binding.test.js index 33bbf9b5012..bbdecdb4b92 100644 --- a/test/unit/render/uniform_binding.test.js +++ b/test/unit/render/uniform_binding.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import { Uniform1i, Uniform1f, diff --git a/test/unit/shaders/encode_attribute.test.js b/test/unit/shaders/encode_attribute.test.js index bf621902114..5530317ca31 100644 --- a/test/unit/shaders/encode_attribute.test.js +++ b/test/unit/shaders/encode_attribute.test.js @@ -1,5 +1,5 @@ -import { test } from '../../util/test'; -import { packUint8ToFloat } from '../../../src/shaders/encode_attribute'; +import {test} from '../../util/test'; +import {packUint8ToFloat} from '../../../src/shaders/encode_attribute'; test('packUint8ToFloat', (t) => { t.equal(packUint8ToFloat(0, 0), 0); diff --git a/test/unit/source/canvas_source.test.js b/test/unit/source/canvas_source.test.js index cb7e3640e4c..5e26b11d343 100644 --- a/test/unit/source/canvas_source.test.js +++ b/test/unit/source/canvas_source.test.js @@ -1,8 +1,8 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import CanvasSource from '../../../src/source/canvas_source'; import Transform from '../../../src/geo/transform'; -import { Event, Evented } from '../../../src/util/evented'; -import { extend } from '../../../src/util/util'; +import {Event, Evented} from '../../../src/util/evented'; +import {extend} from '../../../src/util/util'; import window from '../../../src/util/window'; function createSource(options) { @@ -17,7 +17,7 @@ function createSource(options) { coordinates: [[0, 0], [1, 0], [1, 1], [0, 1]], }, options); - const source = new CanvasSource('id', options, { send() {} }, options.eventedParent); + const source = new CanvasSource('id', options, {send() {}}, options.eventedParent); source.canvas = c; @@ -61,24 +61,24 @@ test('CanvasSource', (t) => { t.test('self-validates', (t) => { const stub = t.stub(console, 'error'); - createSource({ coordinates: [] }); + createSource({coordinates: []}); t.ok(stub.called, 'should error when `coordinates` array parameter has incorrect number of elements'); stub.resetHistory(); - createSource({ coordinates: 'asdf' }); + createSource({coordinates: 'asdf'}); t.ok(stub.called, 'should error with non-array `coordinates` parameter'); stub.resetHistory(); - createSource({ animate: 8 }); + createSource({animate: 8}); t.ok(stub.called, 'should error with non-boolean `animate` parameter'); stub.resetHistory(); - createSource({ canvas: {} }); + createSource({canvas: {}}); t.ok(stub.called, 'should error with non-string/non-Canvas `canvas` parameter'); stub.resetHistory(); const canvasEl = window.document.createElement('canvas'); - createSource({ canvas: canvasEl }); + createSource({canvas: canvasEl}); t.notOk(stub.called, 'should not error with HTMLCanvasElement'); stub.resetHistory(); diff --git a/test/unit/source/geojson_source.test.js b/test/unit/source/geojson_source.test.js index f1e867605d8..6e16e72e8f6 100644 --- a/test/unit/source/geojson_source.test.js +++ b/test/unit/source/geojson_source.test.js @@ -1,10 +1,10 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import Tile from '../../../src/source/tile'; -import { OverscaledTileID } from '../../../src/source/tile_id'; +import {OverscaledTileID} from '../../../src/source/tile_id'; import GeoJSONSource from '../../../src/source/geojson_source'; import Transform from '../../../src/geo/transform'; import LngLat from '../../../src/geo/lng_lat'; -import { extend } from '../../../src/util/util'; +import {extend} from '../../../src/util/util'; const wrapDispatcher = (dispatcher) => { return { @@ -55,7 +55,7 @@ const hawkHill = { test('GeoJSONSource#setData', (t) => { function createSource(opts) { opts = opts || {}; - opts = extend(opts, { data: {} }); + opts = extend(opts, {data: {}}); return new GeoJSONSource('id', opts, wrapDispatcher({ send (type, data, callback) { if (callback) { @@ -87,10 +87,10 @@ test('GeoJSONSource#setData', (t) => { }); t.test('respects collectResourceTiming parameter on source', (t) => { - const source = createSource({ collectResourceTiming: true }); + const source = createSource({collectResourceTiming: true}); source.map = { _requestManager: { - transformRequest: (url) => { return { url }; } + transformRequest: (url) => { return {url}; } } }; source.actor.send = function(type, params, cb) { @@ -112,7 +112,7 @@ test('GeoJSONSource#onRemove', (t) => { send(type, data, callback) { t.false(callback); t.equal(type, 'removeSource'); - t.deepEqual(data, { type: 'geojson', source: 'id' }); + t.deepEqual(data, {type: 'geojson', source: 'id'}); t.end(); }, broadcast() { @@ -173,7 +173,7 @@ test('GeoJSONSource#update', (t) => { t.test('transforms url before making request', (t) => { const mapStub = { _requestManager: { - transformRequest: (url) => { return { url }; } + transformRequest: (url) => { return {url}; } } }; const transformSpy = t.spy(mapStub._requestManager, 'transformRequest'); @@ -254,7 +254,7 @@ test('GeoJSONSource#update', (t) => { test('GeoJSONSource#serialize', (t) => { const mapStub = { _requestManager: { - transformRequest: (url) => { return { url }; } + transformRequest: (url) => { return {url}; } } }; t.test('serialize source with inline data', (t) => { diff --git a/test/unit/source/geojson_worker_source.test.js b/test/unit/source/geojson_worker_source.test.js index 8f9bed39856..94d853020d3 100644 --- a/test/unit/source/geojson_worker_source.test.js +++ b/test/unit/source/geojson_worker_source.test.js @@ -1,7 +1,7 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import GeoJSONWorkerSource from '../../../src/source/geojson_worker_source'; import StyleLayerIndex from '../../../src/style/style_layer_index'; -import { OverscaledTileID } from '../../../src/source/tile_id'; +import {OverscaledTileID} from '../../../src/source/tile_id'; import perf from '../../../src/util/performance'; test('reloadTile', (t) => { @@ -36,8 +36,8 @@ test('reloadTile', (t) => { }; function addData(callback) { - source.loadData({ source: 'sourceId', data: JSON.stringify(geoJson) }, (err) => { - source.coalesce({ source: 'sourceId' }); + source.loadData({source: 'sourceId', data: JSON.stringify(geoJson)}, (err) => { + source.coalesce({source: 'sourceId'}); t.equal(err, null); callback(); }); @@ -128,7 +128,7 @@ test('resourceTiming', (t) => { const layerIndex = new StyleLayerIndex(layers); const source = new GeoJSONWorkerSource(null, layerIndex, (params, callback) => { return callback(null, geoJson); }); - source.loadData({ source: 'testSource', request: { url: 'http://localhost/nonexistent', collectResourceTiming: true } }, (err, result) => { + source.loadData({source: 'testSource', request: {url: 'http://localhost/nonexistent', collectResourceTiming: true}}, (err, result) => { t.equal(err, null); t.deepEquals(result.resourceTiming.testSource, [ exampleResourceTiming ], 'got expected resource timing'); t.end(); @@ -160,9 +160,9 @@ test('resourceTiming', (t) => { const layerIndex = new StyleLayerIndex(layers); const source = new GeoJSONWorkerSource(null, layerIndex, (params, callback) => { return callback(null, geoJson); }); - source.loadData({ source: 'testSource', request: { url: 'http://localhost/nonexistent', collectResourceTiming: true } }, (err, result) => { + source.loadData({source: 'testSource', request: {url: 'http://localhost/nonexistent', collectResourceTiming: true}}, (err, result) => { t.equal(err, null); - t.deepEquals(result.resourceTiming.testSource, [{"duration": 250, "entryType": "measure", "name": "http://localhost/nonexistent", "startTime": 100 }], 'got expected resource timing'); + t.deepEquals(result.resourceTiming.testSource, [{"duration": 250, "entryType": "measure", "name": "http://localhost/nonexistent", "startTime": 100}], 'got expected resource timing'); t.end(); }); }); @@ -171,7 +171,7 @@ test('resourceTiming', (t) => { const layerIndex = new StyleLayerIndex(layers); const source = new GeoJSONWorkerSource(null, layerIndex); - source.loadData({ source: 'testSource', data: JSON.stringify(geoJson) }, (err, result) => { + source.loadData({source: 'testSource', data: JSON.stringify(geoJson)}, (err, result) => { t.equal(err, null); t.equal(result.resourceTiming, undefined, 'no resourceTiming property when loadData is not sent a URL'); t.end(); @@ -223,18 +223,18 @@ test('loadData', (t) => { // Expect first call to run, second to be abandoned, // and third to run in response to coalesce const worker = createWorker(); - worker.loadData({ source: 'source1', data: JSON.stringify(geoJson) }, (err, result) => { + worker.loadData({source: 'source1', data: JSON.stringify(geoJson)}, (err, result) => { t.equal(err, null); t.notOk(result && result.abandoned); - worker.coalesce({ source: 'source1' }); + worker.coalesce({source: 'source1'}); }); - worker.loadData({ source: 'source1', data: JSON.stringify(geoJson) }, (err, result) => { + worker.loadData({source: 'source1', data: JSON.stringify(geoJson)}, (err, result) => { t.equal(err, null); t.ok(result && result.abandoned); }); - worker.loadData({ source: 'source1', data: JSON.stringify(geoJson) }, (err, result) => { + worker.loadData({source: 'source1', data: JSON.stringify(geoJson)}, (err, result) => { t.equal(err, null); t.notOk(result && result.abandoned); t.end(); @@ -248,18 +248,18 @@ test('loadData', (t) => { // removeSource is executed immediately // First loadData finishes running, sends results back to foreground const worker = createWorker(); - worker.loadData({ source: 'source1', data: JSON.stringify(geoJson) }, (err, result) => { + worker.loadData({source: 'source1', data: JSON.stringify(geoJson)}, (err, result) => { t.equal(err, null); t.notOk(result && result.abandoned); t.end(); }); - worker.loadData({ source: 'source1', data: JSON.stringify(geoJson) }, (err, result) => { + worker.loadData({source: 'source1', data: JSON.stringify(geoJson)}, (err, result) => { t.equal(err, null); t.ok(result && result.abandoned); }); - worker.removeSource({ source: 'source1' }, (err) => { + worker.removeSource({source: 'source1'}, (err) => { t.notOk(err); }); diff --git a/test/unit/source/geojson_wrapper.test.js b/test/unit/source/geojson_wrapper.test.js index b5f9e74b9f1..4c04c27f340 100644 --- a/test/unit/source/geojson_wrapper.test.js +++ b/test/unit/source/geojson_wrapper.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import Wrapper from '../../../src/source/geojson_wrapper'; test('geojsonwrapper', (t) => { @@ -7,7 +7,7 @@ test('geojsonwrapper', (t) => { const features = [{ type: 2, geometry: [[[0, 0], [10, 10]]], - tags: { hello: 'world' } + tags: {hello: 'world'} }]; const wrap = new Wrapper(features); diff --git a/test/unit/source/image_source.test.js b/test/unit/source/image_source.test.js index 18f0451c13c..fb0e1d843b4 100644 --- a/test/unit/source/image_source.test.js +++ b/test/unit/source/image_source.test.js @@ -1,9 +1,9 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import assert from 'assert'; import ImageSource from '../../../src/source/image_source'; -import { Evented } from '../../../src/util/evented'; +import {Evented} from '../../../src/util/evented'; import Transform from '../../../src/geo/transform'; -import { extend } from '../../../src/util/util'; +import {extend} from '../../../src/util/util'; import browser from '../../../src/util/browser'; import window from '../../../src/util/window'; @@ -12,7 +12,7 @@ function createSource(options) { coordinates: [[0, 0], [1, 0], [1, 1], [0, 1]] }, options); - const source = new ImageSource('id', options, { send() {} }, options.eventedParent); + const source = new ImageSource('id', options, {send() {}}, options.eventedParent); return source; } @@ -22,7 +22,7 @@ class StubMap extends Evented { this.transform = new Transform(); this._requestManager = { transformRequest: (url) => { - return { url }; + return {url}; } }; } @@ -52,7 +52,7 @@ test('ImageSource', (t) => { t.stub(browser, 'getImageData').callsFake(() => new ArrayBuffer(1)); t.test('constructor', (t) => { - const source = createSource({ url : '/image.png' }); + const source = createSource({url : '/image.png'}); t.equal(source.minzoom, 0); t.equal(source.maxzoom, 22); @@ -61,7 +61,7 @@ test('ImageSource', (t) => { }); t.test('fires dataloading event', (t) => { - const source = createSource({ url : '/image.png' }); + const source = createSource({url : '/image.png'}); source.on('dataloading', (e) => { t.equal(e.dataType, 'source'); t.end(); @@ -71,7 +71,7 @@ test('ImageSource', (t) => { }); t.test('transforms url request', (t) => { - const source = createSource({ url : '/image.png' }); + const source = createSource({url : '/image.png'}); const map = new StubMap(); const spy = t.spy(map._requestManager, 'transformRequest'); source.onAdd(map); @@ -83,7 +83,7 @@ test('ImageSource', (t) => { }); t.test('updates url from updateImage', (t) => { - const source = createSource({ url : '/image.png' }); + const source = createSource({url : '/image.png'}); const map = new StubMap(); const spy = t.spy(map._requestManager, 'transformRequest'); source.onAdd(map); @@ -91,7 +91,7 @@ test('ImageSource', (t) => { t.ok(spy.calledOnce); t.equal(spy.getCall(0).args[0], '/image.png'); t.equal(spy.getCall(0).args[1], 'Image'); - source.updateImage({ url: '/image2.png' }); + source.updateImage({url: '/image2.png'}); respond(); t.ok(spy.calledTwice); t.equal(spy.getCall(1).args[0], '/image2.png'); @@ -100,7 +100,7 @@ test('ImageSource', (t) => { }); t.test('sets coordinates', (t) => { - const source = createSource({ url : '/image.png' }); + const source = createSource({url : '/image.png'}); const map = new StubMap(); source.onAdd(map); respond(); @@ -113,7 +113,7 @@ test('ImageSource', (t) => { }); t.test('sets coordinates via updateImage', (t) => { - const source = createSource({ url : '/image.png' }); + const source = createSource({url : '/image.png'}); const map = new StubMap(); source.onAdd(map); respond(); @@ -130,7 +130,7 @@ test('ImageSource', (t) => { }); t.test('fires data event when content is loaded', (t) => { - const source = createSource({ url : '/image.png' }); + const source = createSource({url : '/image.png'}); source.on('data', (e) => { if (e.dataType === 'source' && e.sourceDataType === 'content') { t.ok(typeof source.tileID == 'object'); @@ -142,7 +142,7 @@ test('ImageSource', (t) => { }); t.test('fires data event when metadata is loaded', (t) => { - const source = createSource({ url : '/image.png' }); + const source = createSource({url : '/image.png'}); source.on('data', (e) => { if (e.dataType === 'source' && e.sourceDataType === 'metadata') { t.end(); @@ -153,7 +153,7 @@ test('ImageSource', (t) => { }); t.test('serialize url and coordinates', (t) => { - const source = createSource({ url: '/image.png' }); + const source = createSource({url: '/image.png'}); const serialized = source.serialize(); t.equal(serialized.type, 'image'); diff --git a/test/unit/source/query_features.test.js b/test/unit/source/query_features.test.js index 678aa3e7d0e..94c77ee03ed 100644 --- a/test/unit/source/query_features.test.js +++ b/test/unit/source/query_features.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import { queryRenderedFeatures, querySourceFeatures @@ -8,7 +8,7 @@ import Transform from '../../../src/geo/transform.js'; test('QueryFeatures#rendered', (t) => { t.test('returns empty object if source returns no tiles', (t) => { - const mockSourceCache = { tilesIn () { return []; } }; + const mockSourceCache = {tilesIn () { return []; }}; const transform = new Transform(); const result = queryRenderedFeatures(mockSourceCache, undefined, {}, undefined, transform); t.deepEqual(result, []); @@ -22,7 +22,7 @@ test('QueryFeatures#source', (t) => { t.test('returns empty result when source has no features', (t) => { const sourceCache = new SourceCache('test', { type: 'geojson', - data: { type: 'FeatureCollection', features: [] } + data: {type: 'FeatureCollection', features: []} }, { getActor() { return { diff --git a/test/unit/source/raster_dem_tile_source.test.js b/test/unit/source/raster_dem_tile_source.test.js index debd6fc9bab..0f2ee7617e6 100644 --- a/test/unit/source/raster_dem_tile_source.test.js +++ b/test/unit/source/raster_dem_tile_source.test.js @@ -1,13 +1,13 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import RasterDEMTileSource from '../../../src/source/raster_dem_tile_source'; import window from '../../../src/util/window'; -import { OverscaledTileID } from '../../../src/source/tile_id'; -import { RequestManager } from '../../../src/util/mapbox'; +import {OverscaledTileID} from '../../../src/source/tile_id'; +import {RequestManager} from '../../../src/util/mapbox'; function createSource(options, transformCallback) { - const source = new RasterDEMTileSource('id', options, { send() {} }, options.eventedParent); + const source = new RasterDEMTileSource('id', options, {send() {}}, options.eventedParent); source.onAdd({ - transform: { angle: 0, pitch: 0, showCollisionBoxes: false }, + transform: {angle: 0, pitch: 0, showCollisionBoxes: false}, _getMapId: () => 1, _requestManager: new RequestManager(transformCallback) }); @@ -39,10 +39,10 @@ test('RasterTileSource', (t) => { bounds: [-47, -7, -45, -5] })); const transformSpy = t.spy((url) => { - return { url }; + return {url}; }); - createSource({ url: "/source.json" }, transformSpy); + createSource({url: "/source.json"}, transformSpy); window.server.respond(); t.equal(transformSpy.getCall(0).args[0], '/source.json'); @@ -58,7 +58,7 @@ test('RasterTileSource', (t) => { tiles: ["http://example.com/{z}/{x}/{y}.png"], bounds: [-47, -7, -45, -5] })); - const source = createSource({ url: "/source.json" }); + const source = createSource({url: "/source.json"}); const transformSpy = t.spy(source.map._requestManager, 'transformRequest'); source.on('data', (e) => { if (e.sourceDataType === 'metadata') { @@ -86,7 +86,7 @@ test('RasterTileSource', (t) => { attribution: "Mapbox", tiles: ["http://example.com/{z}/{x}/{y}.png"] })); - const source = createSource({ url: "/source.json" }); + const source = createSource({url: "/source.json"}); source.on('data', (e) => { if (e.sourceDataType === 'metadata') { const tile = { @@ -122,7 +122,7 @@ test('RasterTileSource', (t) => { attribution: "Mapbox", tiles: ["http://example.com/{z}/{x}/{y}.png"] })); - const source = createSource({ url: "/source.json" }); + const source = createSource({url: "/source.json"}); source.on('data', (e) => { if (e.sourceDataType === 'metadata') { const tile = { diff --git a/test/unit/source/raster_dem_tile_worker_source.test.js b/test/unit/source/raster_dem_tile_worker_source.test.js index 826fd4ff673..febeaa32b27 100644 --- a/test/unit/source/raster_dem_tile_worker_source.test.js +++ b/test/unit/source/raster_dem_tile_worker_source.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import RasterDEMTileWorkerSource from '../../../src/source/raster_dem_tile_worker_source'; import StyleLayerIndex from '../../../src/style/style_layer_index'; import DEMData from '../../../src/data/dem_data'; diff --git a/test/unit/source/raster_tile_source.test.js b/test/unit/source/raster_tile_source.test.js index 37b8ccb9f57..2b77fa7db9e 100644 --- a/test/unit/source/raster_tile_source.test.js +++ b/test/unit/source/raster_tile_source.test.js @@ -1,13 +1,13 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import RasterTileSource from '../../../src/source/raster_tile_source'; import window from '../../../src/util/window'; -import { OverscaledTileID } from '../../../src/source/tile_id'; -import { RequestManager } from '../../../src/util/mapbox'; +import {OverscaledTileID} from '../../../src/source/tile_id'; +import {RequestManager} from '../../../src/util/mapbox'; function createSource(options, transformCallback) { - const source = new RasterTileSource('id', options, { send() {} }, options.eventedParent); + const source = new RasterTileSource('id', options, {send() {}}, options.eventedParent); source.onAdd({ - transform: { angle: 0, pitch: 0, showCollisionBoxes: false }, + transform: {angle: 0, pitch: 0, showCollisionBoxes: false}, _getMapId: () => 1, _requestManager: new RequestManager(transformCallback) }); @@ -39,10 +39,10 @@ test('RasterTileSource', (t) => { bounds: [-47, -7, -45, -5] })); const transformSpy = t.spy((url) => { - return { url }; + return {url}; }); - createSource({ url: "/source.json" }, transformSpy); + createSource({url: "/source.json"}, transformSpy); window.server.respond(); t.equal(transformSpy.getCall(0).args[0], '/source.json'); @@ -92,7 +92,7 @@ test('RasterTileSource', (t) => { tiles: ["http://example.com/{z}/{x}/{y}.png"], bounds: [-47, -7, -45, -5] })); - const source = createSource({ url: "/source.json" }); + const source = createSource({url: "/source.json"}); source.on('data', (e) => { if (e.sourceDataType === 'metadata') { @@ -112,7 +112,7 @@ test('RasterTileSource', (t) => { tiles: ["http://example.com/{z}/{x}/{y}.png"], bounds: [-47, -7, -45, -5] })); - const source = createSource({ url: "/source.json" }); + const source = createSource({url: "/source.json"}); const transformSpy = t.spy(source.map._requestManager, 'transformRequest'); source.on('data', (e) => { if (e.sourceDataType === 'metadata') { @@ -133,7 +133,7 @@ test('RasterTileSource', (t) => { }); t.test('cancels TileJSON request if removed', (t) => { - const source = createSource({ url: "/source.json" }); + const source = createSource({url: "/source.json"}); source.onRemove(); t.equal(window.server.lastRequest.aborted, true); t.end(); diff --git a/test/unit/source/source_cache.test.js b/test/unit/source/source_cache.test.js index cc59deab049..b8eb33b4cc6 100644 --- a/test/unit/source/source_cache.test.js +++ b/test/unit/source/source_cache.test.js @@ -1,13 +1,13 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import SourceCache from '../../../src/source/source_cache'; import {setType} from '../../../src/source/source'; import Tile from '../../../src/source/tile'; -import { OverscaledTileID } from '../../../src/source/tile_id'; +import {OverscaledTileID} from '../../../src/source/tile_id'; import Transform from '../../../src/geo/transform'; import LngLat from '../../../src/geo/lng_lat'; import Point from '@mapbox/point-geometry'; -import { Event, ErrorEvent, Evented } from '../../../src/util/evented'; -import { extend } from '../../../src/util/util'; +import {Event, ErrorEvent, Evented} from '../../../src/util/evented'; +import {extend} from '../../../src/util/util'; import browser from '../../../src/util/browser'; // Add a mocked source type for use in these tests @@ -301,7 +301,7 @@ test('SourceCache#removeTile', (t) => { callback(); } }); - sourceCache.map = { painter: { crossTileSymbolIndex: "", tileExtentVAO: {} } }; + sourceCache.map = {painter: {crossTileSymbolIndex: "", tileExtentVAO: {}}}; sourceCache._addTile(tileID); @@ -335,7 +335,7 @@ test('SourceCache / Source lifecycle', (t) => { }); t.test('forward error event', (t) => { - const sourceCache = createSourceCache({ error: 'Error loading source' }).on('error', (err) => { + const sourceCache = createSourceCache({error: 'Error loading source'}).on('error', (err) => { t.equal(err.error, 'Error loading source'); t.end(); }); @@ -350,7 +350,7 @@ test('SourceCache / Source lifecycle', (t) => { }); t.test('loaded() true after source error', (t) => { - const sourceCache = createSourceCache({ error: 'Error loading source' }).on('error', () => { + const sourceCache = createSourceCache({error: 'Error loading source'}).on('error', () => { t.ok(sourceCache.loaded()); t.end(); }); @@ -1226,7 +1226,7 @@ test('SourceCache#tilesIn', (t) => { tr.width = 512; tr.height = 512; tr._calcMatrices(); - const sourceCache = createSourceCache({ noLoad: true }); + const sourceCache = createSourceCache({noLoad: true}); sourceCache.transform = tr; sourceCache.onAdd(); t.same(sourceCache.tilesIn([ @@ -1420,7 +1420,7 @@ test('SourceCache#getIds (ascending order by zoom level)', (t) => { const sourceCache = createSourceCache({}); sourceCache.transform = new Transform(); for (let i = 0; i < ids.length; i++) { - sourceCache._tiles[ids[i].key] = { tileID: ids[i] }; + sourceCache._tiles[ids[i].key] = {tileID: ids[i]}; } t.deepEqual(sourceCache.getIds(), [ new OverscaledTileID(0, 0, 0, 0, 0).key, @@ -1477,7 +1477,7 @@ test('SourceCache#findLoadedParent', (t) => { test('SourceCache#reload', (t) => { t.test('before loaded', (t) => { - const sourceCache = createSourceCache({ noLoad: true }); + const sourceCache = createSourceCache({noLoad: true}); sourceCache.onAdd(); t.doesNotThrow(() => { @@ -1496,7 +1496,7 @@ test('SourceCache reloads expiring tiles', (t) => { const expiryDate = new Date(); expiryDate.setMilliseconds(expiryDate.getMilliseconds() + 50); - const sourceCache = createSourceCache({ expires: expiryDate }); + const sourceCache = createSourceCache({expires: expiryDate}); sourceCache._reloadTile = (id, state) => { t.equal(state, 'expired'); diff --git a/test/unit/source/tile.test.js b/test/unit/source/tile.test.js index 4024c2ed818..9f0a1d033e8 100644 --- a/test/unit/source/tile.test.js +++ b/test/unit/source/tile.test.js @@ -1,21 +1,21 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import Tile from '../../../src/source/tile'; import GeoJSONWrapper from '../../../src/source/geojson_wrapper'; -import { OverscaledTileID } from '../../../src/source/tile_id'; +import {OverscaledTileID} from '../../../src/source/tile_id'; import fs from 'fs'; import path from 'path'; import vtpbf from 'vt-pbf'; import FeatureIndex from '../../../src/data/feature_index'; -import { CollisionBoxArray } from '../../../src/data/array_types'; -import { extend } from '../../../src/util/util'; +import {CollisionBoxArray} from '../../../src/data/array_types'; +import {extend} from '../../../src/util/util'; import Context from '../../../src/gl/context'; -import { serialize, deserialize } from '../../../src/util/web_worker_transfer'; +import {serialize, deserialize} from '../../../src/util/web_worker_transfer'; test('querySourceFeatures', (t) => { const features = [{ type: 1, geometry: [0, 0], - tags: { oneway: true } + tags: {oneway: true} }]; t.test('geojson tile', (t) => { @@ -29,7 +29,7 @@ test('querySourceFeatures', (t) => { const geojsonWrapper = new GeoJSONWrapper(features); geojsonWrapper.name = '_geojsonTileLayer'; tile.loadVectorData( - createVectorData({rawTileData: vtpbf({ layers: { '_geojsonTileLayer': geojsonWrapper }})}), + createVectorData({rawTileData: vtpbf({layers: {'_geojsonTileLayer': geojsonWrapper}})}), createPainter() ); @@ -42,10 +42,10 @@ test('querySourceFeatures', (t) => { t.equal(result.length, 1); t.deepEqual(result[0].properties, features[0].tags); result = []; - tile.querySourceFeatures(result, { filter: ['==', 'oneway', true]}); + tile.querySourceFeatures(result, {filter: ['==', 'oneway', true]}); t.equal(result.length, 1); result = []; - tile.querySourceFeatures(result, { filter: ['!=', 'oneway', true]}); + tile.querySourceFeatures(result, {filter: ['!=', 'oneway', true]}); t.equal(result.length, 0); t.end(); }); @@ -60,7 +60,7 @@ test('querySourceFeatures', (t) => { const geojsonWrapper = new GeoJSONWrapper([]); geojsonWrapper.name = '_geojsonTileLayer'; - tile.rawTileData = vtpbf({ layers: { '_geojsonTileLayer': geojsonWrapper }}); + tile.rawTileData = vtpbf({layers: {'_geojsonTileLayer': geojsonWrapper}}); result = []; t.doesNotThrow(() => { tile.querySourceFeatures(result); }); t.equal(result.length, 0); @@ -81,18 +81,18 @@ test('querySourceFeatures', (t) => { ); result = []; - tile.querySourceFeatures(result, { 'sourceLayer': 'does-not-exist'}); + tile.querySourceFeatures(result, {'sourceLayer': 'does-not-exist'}); t.equal(result.length, 0); result = []; - tile.querySourceFeatures(result, { 'sourceLayer': 'road' }); + tile.querySourceFeatures(result, {'sourceLayer': 'road'}); t.equal(result.length, 3); result = []; - tile.querySourceFeatures(result, { 'sourceLayer': 'road', filter: ['==', 'class', 'main'] }); + tile.querySourceFeatures(result, {'sourceLayer': 'road', filter: ['==', 'class', 'main']}); t.equal(result.length, 1); result = []; - tile.querySourceFeatures(result, { 'sourceLayer': 'road', filter: ['!=', 'class', 'main'] }); + tile.querySourceFeatures(result, {'sourceLayer': 'road', filter: ['!=', 'class', 'main']}); t.equal(result.length, 2); t.end(); @@ -124,7 +124,7 @@ test('querySourceFeatures', (t) => { ); const features = []; - tile.querySourceFeatures(features, { 'sourceLayer': 'road' }); + tile.querySourceFeatures(features, {'sourceLayer': 'road'}); t.equal(features.length, 3); t.end(); @@ -318,5 +318,5 @@ function createVectorData(options) { } function createPainter() { - return { style: {} }; + return {style: {}}; } diff --git a/test/unit/source/tile_cache.test.js b/test/unit/source/tile_cache.test.js index 3f0215230ca..623d8710d84 100644 --- a/test/unit/source/tile_cache.test.js +++ b/test/unit/source/tile_cache.test.js @@ -1,16 +1,16 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import TileCache from '../../../src/source/tile_cache'; -import { OverscaledTileID } from '../../../src/source/tile_id'; +import {OverscaledTileID} from '../../../src/source/tile_id'; const idA = new OverscaledTileID(10, 0, 10, 0, 1); const idB = new OverscaledTileID(10, 0, 10, 0, 2); const idC = new OverscaledTileID(10, 0, 10, 0, 3); const idD = new OverscaledTileID(10, 0, 10, 0, 4); -const tileA = { tileID: idA }; -const tileA2 = { tileID: idA }; -const tileB = { tileID: idB }; -const tileC = { tileID: idC }; -const tileD = { tileID: idD }; +const tileA = {tileID: idA}; +const tileA2 = {tileID: idA}; +const tileB = {tileID: idB}; +const tileC = {tileID: idC}; +const tileD = {tileID: idD}; function keysExpected(t, cache, ids) { t.deepEqual(cache.order, ids.map((id) => id.key), 'keys'); diff --git a/test/unit/source/tile_id.test.js b/test/unit/source/tile_id.test.js index 61ef5df26d4..10e276964af 100644 --- a/test/unit/source/tile_id.test.js +++ b/test/unit/source/tile_id.test.js @@ -1,5 +1,5 @@ -import { test } from '../../util/test'; -import { CanonicalTileID, OverscaledTileID } from '../../../src/source/tile_id'; +import {test} from '../../util/test'; +import {CanonicalTileID, OverscaledTileID} from '../../../src/source/tile_id'; test('CanonicalTileID', (t) => { t.test('#constructor', (t) => { diff --git a/test/unit/source/tile_mask.test.js b/test/unit/source/tile_mask.test.js index 687b0be29b9..fd1728b1a9d 100644 --- a/test/unit/source/tile_mask.test.js +++ b/test/unit/source/tile_mask.test.js @@ -1,6 +1,6 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import updateTileMasks from '../../../src/render/tile_mask'; -import { OverscaledTileID } from '../../../src/source/tile_id'; +import {OverscaledTileID} from '../../../src/source/tile_id'; test('computeTileMasks', (t) => { class Tile { diff --git a/test/unit/source/vector_tile_source.test.js b/test/unit/source/vector_tile_source.test.js index 8db87f7f000..b3a00588805 100644 --- a/test/unit/source/vector_tile_source.test.js +++ b/test/unit/source/vector_tile_source.test.js @@ -1,9 +1,9 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import VectorTileSource from '../../../src/source/vector_tile_source'; -import { OverscaledTileID } from '../../../src/source/tile_id'; +import {OverscaledTileID} from '../../../src/source/tile_id'; import window from '../../../src/util/window'; -import { Evented } from '../../../src/util/evented'; -import { RequestManager } from '../../../src/util/mapbox'; +import {Evented} from '../../../src/util/evented'; +import {RequestManager} from '../../../src/util/mapbox'; const wrapDispatcher = (dispatcher) => { return { @@ -20,7 +20,7 @@ const mockDispatcher = wrapDispatcher({ function createSource(options, transformCallback) { const source = new VectorTileSource('id', options, mockDispatcher, options.eventedParent); source.onAdd({ - transform: { showCollisionBoxes: false }, + transform: {showCollisionBoxes: false}, _getMapId: () => 1, _requestManager: new RequestManager(transformCallback) }); @@ -65,7 +65,7 @@ test('VectorTileSource', (t) => { t.test('can be constructed from a TileJSON URL', (t) => { window.server.respondWith('/source.json', JSON.stringify(require('../../fixtures/source'))); - const source = createSource({ url: "/source.json" }); + const source = createSource({url: "/source.json"}); source.on('data', (e) => { if (e.sourceDataType === 'metadata') { @@ -83,10 +83,10 @@ test('VectorTileSource', (t) => { t.test('transforms the request for TileJSON URL', (t) => { window.server.respondWith('/source.json', JSON.stringify(require('../../fixtures/source'))); const transformSpy = t.spy((url) => { - return { url }; + return {url}; }); - createSource({ url: "/source.json" }, transformSpy); + createSource({url: "/source.json"}, transformSpy); window.server.respond(); t.equal(transformSpy.getCall(0).args[0], '/source.json'); t.equal(transformSpy.getCall(0).args[1], 'Source'); @@ -95,7 +95,7 @@ test('VectorTileSource', (t) => { t.test('fires event with metadata property', (t) => { window.server.respondWith('/source.json', JSON.stringify(require('../../fixtures/source'))); - const source = createSource({ url: "/source.json" }); + const source = createSource({url: "/source.json"}); source.on('data', (e) => { if (e.sourceDataType === 'content') t.end(); }); @@ -109,7 +109,7 @@ test('VectorTileSource', (t) => { evented.on('dataloading', () => { dataloadingFired = true; }); - const source = createSource({ url: "/source.json", eventedParent: evented }); + const source = createSource({url: "/source.json", eventedParent: evented}); source.on('data', (e) => { if (e.sourceDataType === 'metadata') { if (!dataloadingFired) t.fail(); @@ -179,7 +179,7 @@ test('VectorTileSource', (t) => { t.test('transforms tile urls before requesting', (t) => { window.server.respondWith('/source.json', JSON.stringify(require('../../fixtures/source'))); - const source = createSource({ url: "/source.json" }); + const source = createSource({url: "/source.json"}); const transformSpy = t.spy(source.map._requestManager, 'transformRequest'); source.on('data', (e) => { if (e.sourceDataType === 'metadata') { @@ -276,7 +276,7 @@ test('VectorTileSource', (t) => { tiles: ["http://example.com/{z}/{x}/{y}.png"], bounds: [-47, -7, -45, -5] })); - const source = createSource({ url: "/source.json" }); + const source = createSource({url: "/source.json"}); source.on('data', (e) => { if (e.sourceDataType === 'metadata') { @@ -320,7 +320,7 @@ test('VectorTileSource', (t) => { }); t.test('cancels TileJSON request if removed', (t) => { - const source = createSource({ url: "/source.json" }); + const source = createSource({url: "/source.json"}); source.onRemove(); t.equal(window.server.lastRequest.aborted, true); t.end(); diff --git a/test/unit/source/vector_tile_worker_source.test.js b/test/unit/source/vector_tile_worker_source.test.js index b9ceab1fb73..d2c59d2e17c 100644 --- a/test/unit/source/vector_tile_worker_source.test.js +++ b/test/unit/source/vector_tile_worker_source.test.js @@ -2,7 +2,7 @@ import fs from 'fs'; import path from 'path'; import vt from '@mapbox/vector-tile'; import Protobuf from 'pbf'; -import { test } from '../../util/test'; +import {test} from '../../util/test'; import VectorTileWorkerSource from '../../../src/source/vector_tile_worker_source'; import StyleLayerIndex from '../../../src/style/style_layer_index'; import perf from '../../../src/util/performance'; @@ -13,8 +13,8 @@ test('VectorTileWorkerSource#abortTile aborts pending request', (t) => { source.loadTile({ source: 'source', uid: 0, - tileID: { overscaledZ: 0, wrap: 0, canonical: {x: 0, y: 0, z: 0, w: 0} }, - request: { url: 'http://localhost:2900/abort' } + tileID: {overscaledZ: 0, wrap: 0, canonical: {x: 0, y: 0, z: 0, w: 0}}, + request: {url: 'http://localhost:2900/abort'} }, (err, res) => { t.false(err); t.false(res); @@ -64,7 +64,7 @@ test('VectorTileWorkerSource#reloadTile reloads a previously-loaded tile', (t) = }; const callback = t.spy(); - source.reloadTile({ uid: 0 }, callback); + source.reloadTile({uid: 0}, callback); t.equal(parse.callCount, 1); parse.firstCall.args[3](); @@ -87,11 +87,11 @@ test('VectorTileWorkerSource#reloadTile queues a reload when parsing is in progr const callback1 = t.spy(); const callback2 = t.spy(); - source.reloadTile({ uid: 0 }, callback1); + source.reloadTile({uid: 0}, callback1); t.equal(parse.callCount, 1); source.loaded[0].status = 'parsing'; - source.reloadTile({ uid: 0 }, callback2); + source.reloadTile({uid: 0}, callback2); t.equal(parse.callCount, 1); parse.firstCall.args[3](); @@ -122,11 +122,11 @@ test('VectorTileWorkerSource#reloadTile handles multiple pending reloads', (t) = const callback1 = t.spy(); const callback2 = t.spy(); const callback3 = t.spy(); - source.reloadTile({ uid: 0 }, callback1); + source.reloadTile({uid: 0}, callback1); t.equal(parse.callCount, 1); source.loaded[0].status = 'parsing'; - source.reloadTile({ uid: 0 }, callback2); + source.reloadTile({uid: 0}, callback2); t.equal(parse.callCount, 1); parse.firstCall.args[3](); @@ -135,7 +135,7 @@ test('VectorTileWorkerSource#reloadTile handles multiple pending reloads', (t) = t.equal(callback2.callCount, 0); t.equal(callback3.callCount, 0); - source.reloadTile({ uid: 0 }, callback3); + source.reloadTile({uid: 0}, callback3); t.equal(parse.callCount, 2); t.equal(callback1.callCount, 1); t.equal(callback2.callCount, 0); @@ -168,7 +168,7 @@ test('VectorTileWorkerSource#reloadTile does not reparse tiles with no vectorTil const callback = t.spy(); - source.reloadTile({ uid: 0 }, callback); + source.reloadTile({uid: 0}, callback); t.ok(parse.notCalled); t.ok(callback.calledOnce); @@ -222,8 +222,8 @@ test('VectorTileWorkerSource provides resource timing information', (t) => { source.loadTile({ source: 'source', uid: 0, - tileID: { overscaledZ: 0, wrap: 0, canonical: {x: 0, y: 0, z: 0, w: 0} }, - request: { url: 'http://localhost:2900/faketile.pbf', collectResourceTiming: true } + tileID: {overscaledZ: 0, wrap: 0, canonical: {x: 0, y: 0, z: 0, w: 0}}, + request: {url: 'http://localhost:2900/faketile.pbf', collectResourceTiming: true} }, (err, res) => { t.false(err); t.deepEquals(res.resourceTiming[0], exampleResourceTiming, 'resourceTiming resp is expected'); @@ -276,11 +276,11 @@ test('VectorTileWorkerSource provides resource timing information (fallback meth source.loadTile({ source: 'source', uid: 0, - tileID: { overscaledZ: 0, wrap: 0, canonical: {x: 0, y: 0, z: 0, w: 0} }, - request: { url: 'http://localhost:2900/faketile.pbf', collectResourceTiming: true } + tileID: {overscaledZ: 0, wrap: 0, canonical: {x: 0, y: 0, z: 0, w: 0}}, + request: {url: 'http://localhost:2900/faketile.pbf', collectResourceTiming: true} }, (err, res) => { t.false(err); - t.deepEquals(res.resourceTiming[0], {"duration": 250, "entryType": "measure", "name": "http://localhost:2900/faketile.pbf", "startTime": 100 }, 'resourceTiming resp is expected'); + t.deepEquals(res.resourceTiming[0], {"duration": 250, "entryType": "measure", "name": "http://localhost:2900/faketile.pbf", "startTime": 100}, 'resourceTiming resp is expected'); t.end(); }); }); diff --git a/test/unit/source/video_source.test.js b/test/unit/source/video_source.test.js index 5fe143a9136..ad44dfc1762 100644 --- a/test/unit/source/video_source.test.js +++ b/test/unit/source/video_source.test.js @@ -1,6 +1,6 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import VideoSource from '../../../src/source/video_source'; -import { extend } from '../../../src/util/util'; +import {extend} from '../../../src/util/util'; import window from '../../../src/util/window'; function createSource(options) { @@ -9,7 +9,7 @@ function createSource(options) { options = extend({coordinates: [[0, 0], [1, 0], [1, 1], [0, 1]]}, options); - const source = new VideoSource('id', options, { send() {} }, options.eventedParent); + const source = new VideoSource('id', options, {send() {}}, options.eventedParent); source.video = c; return source; diff --git a/test/unit/source/worker.test.js b/test/unit/source/worker.test.js index c987fdb63e4..e46fb81bc8e 100644 --- a/test/unit/source/worker.test.js +++ b/test/unit/source/worker.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import Worker from '../../../src/source/worker'; import window from '../../../src/util/window'; @@ -14,8 +14,8 @@ test('load tile', (t) => { type: 'vector', source: 'source', uid: 0, - tileID: { overscaledZ: 0, wrap: 0, canonical: {x: 0, y: 0, z: 0, w: 0} }, - request: { url: '/error' }// Sinon fake server gives 404 responses by default + tileID: {overscaledZ: 0, wrap: 0, canonical: {x: 0, y: 0, z: 0, w: 0}}, + request: {url: '/error'}// Sinon fake server gives 404 responses by default }, (err) => { t.ok(err); window.restore(); @@ -31,12 +31,12 @@ test('isolates different instances\' data', (t) => { const worker = new Worker(_self); worker.setLayers(0, [ - { id: 'one', type: 'circle' } + {id: 'one', type: 'circle'} ], () => {}); worker.setLayers(1, [ - { id: 'one', type: 'circle' }, - { id: 'two', type: 'circle' }, + {id: 'one', type: 'circle'}, + {id: 'two', type: 'circle'}, ], () => {}); t.notEqual(worker.layerIndexes[0], worker.layerIndexes[1]); diff --git a/test/unit/source/worker_tile.test.js b/test/unit/source/worker_tile.test.js index 5c825e73f26..4f44da3871e 100644 --- a/test/unit/source/worker_tile.test.js +++ b/test/unit/source/worker_tile.test.js @@ -1,7 +1,7 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import WorkerTile from '../../../src/source/worker_tile'; import Wrapper from '../../../src/source/geojson_wrapper'; -import { OverscaledTileID } from '../../../src/source/tile_id'; +import {OverscaledTileID} from '../../../src/source/tile_id'; import StyleLayerIndex from '../../../src/style/style_layer_index'; function createWorkerTile() { @@ -44,7 +44,7 @@ test('WorkerTile#parse skips hidden layers', (t) => { id: 'test-hidden', source: 'source', type: 'fill', - layout: { visibility: 'none' } + layout: {visibility: 'none'} }]); const tile = createWorkerTile(); diff --git a/test/unit/style-spec/color.js b/test/unit/style-spec/color.js index 9fe843b51e1..1da9ebc0744 100644 --- a/test/unit/style-spec/color.js +++ b/test/unit/style-spec/color.js @@ -1,6 +1,6 @@ // @flow -import { test } from '../../util/test'; +import {test} from '../../util/test'; import Color from '../../../src/style-spec/util/color'; test('Color.parse', (t) => { diff --git a/test/unit/style-spec/composite.test.js b/test/unit/style-spec/composite.test.js index be27e90b970..b648131807b 100644 --- a/test/unit/style-spec/composite.test.js +++ b/test/unit/style-spec/composite.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import composite from '../../../src/style-spec/composite'; test('composites Mapbox vector sources', (t) => { diff --git a/test/unit/style-spec/declass.test.js b/test/unit/style-spec/declass.test.js index 16e9c0ac5dd..858c4b5705d 100644 --- a/test/unit/style-spec/declass.test.js +++ b/test/unit/style-spec/declass.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import declass from '../../../src/style-spec/declass'; test('declass a style, one class', (t) => { @@ -6,11 +6,11 @@ test('declass a style, one class', (t) => { layers: [{ id: 'a', paint: { - 'fill-color': { base: 2, stops: [[0, 'red'], [22, 'yellow']] }, + 'fill-color': {base: 2, stops: [[0, 'red'], [22, 'yellow']]}, 'fill-outline-color': 'green' }, 'paint.one': { - 'fill-color': { base: 1 }, + 'fill-color': {base: 1}, 'fill-opacity': 0.5 } }] @@ -27,7 +27,7 @@ test('declass a style, one class', (t) => { layers: [{ id: 'a', paint: { - 'fill-color': { base: 1 }, + 'fill-color': {base: 1}, 'fill-outline-color': 'green', 'fill-opacity': 0.5 } diff --git a/test/unit/style-spec/deref.test.js b/test/unit/style-spec/deref.test.js index 7269524705d..847e5cba1d2 100644 --- a/test/unit/style-spec/deref.test.js +++ b/test/unit/style-spec/deref.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import deref from '../../../src/style-spec/deref'; test('derefs a ref layer which follows its parent', (t) => { diff --git a/test/unit/style-spec/diff.test.js b/test/unit/style-spec/diff.test.js index c177c31b593..5e1a1d7c943 100644 --- a/test/unit/style-spec/diff.test.js +++ b/test/unit/style-spec/diff.test.js @@ -1,118 +1,118 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import diffStyles from '../../../src/style-spec/diff'; test('diff', (t) => { t.deepEqual(diffStyles({ - layers: [{ id: 'a' }] + layers: [{id: 'a'}] }, { - layers: [{ id: 'a' }] + layers: [{id: 'a'}] }), [], 'no changes'); t.deepEqual(diffStyles({ version: 7, - layers: [{ id: 'a' }] + layers: [{id: 'a'}] }, { version: 8, - layers: [{ id: 'a' }] + layers: [{id: 'a'}] }), [ - { command: 'setStyle', args: [{ version: 8, layers: [{ id: 'a' }] }] } + {command: 'setStyle', args: [{version: 8, layers: [{id: 'a'}]}]} ], 'version change'); t.deepEqual(diffStyles({ - layers: [{ id: 'a' }] + layers: [{id: 'a'}] }, { - layers: [{ id: 'a' }, { id: 'b' }] + layers: [{id: 'a'}, {id: 'b'}] }), [ - { command: 'addLayer', args: [{ id: 'b' }, undefined] } + {command: 'addLayer', args: [{id: 'b'}, undefined]} ], 'add a layer'); t.deepEqual(diffStyles({ - layers: [{ id: 'b' }] + layers: [{id: 'b'}] }, { - layers: [{ id: 'a' }, { id: 'b' }] + layers: [{id: 'a'}, {id: 'b'}] }), [ - { command: 'addLayer', args: [{ id: 'a' }, 'b'] } + {command: 'addLayer', args: [{id: 'a'}, 'b']} ], 'add a layer before another'); t.deepEqual(diffStyles({ - layers: [{ id: 'a' }, { id: 'b', source: 'foo', nested: [1] }] + layers: [{id: 'a'}, {id: 'b', source: 'foo', nested: [1]}] }, { - layers: [{ id: 'a' }] + layers: [{id: 'a'}] }), [ - { command: 'removeLayer', args: ['b'] } + {command: 'removeLayer', args: ['b']} ], 'remove a layer'); t.deepEqual(diffStyles({ - layers: [{ id: 'a' }, { id: 'b' }] + layers: [{id: 'a'}, {id: 'b'}] }, { - layers: [{ id: 'b' }, { id: 'a' }] + layers: [{id: 'b'}, {id: 'a'}] }), [ - { command: 'removeLayer', args: ['a'] }, - { command: 'addLayer', args: [{ id: 'a' }, undefined] } + {command: 'removeLayer', args: ['a']}, + {command: 'addLayer', args: [{id: 'a'}, undefined]} ], 'move a layer'); t.deepEqual(diffStyles({ - layers: [{ id: 'a', paint: { foo: 1 } }] + layers: [{id: 'a', paint: {foo: 1}}] }, { - layers: [{ id: 'a', paint: { foo: 2 } }] + layers: [{id: 'a', paint: {foo: 2}}] }), [ - { command: 'setPaintProperty', args: ['a', 'foo', 2, null] } + {command: 'setPaintProperty', args: ['a', 'foo', 2, null]} ], 'update paint property'); t.deepEqual(diffStyles({ - layers: [{ id: 'a', 'paint.light': { foo: 1 } }] + layers: [{id: 'a', 'paint.light': {foo: 1}}] }, { - layers: [{ id: 'a', 'paint.light': { foo: 2 } }] + layers: [{id: 'a', 'paint.light': {foo: 2}}] }), [ - { command: 'setPaintProperty', args: ['a', 'foo', 2, 'light'] } + {command: 'setPaintProperty', args: ['a', 'foo', 2, 'light']} ], 'update paint property class'); t.deepEqual(diffStyles({ - layers: [{ id: 'a', paint: { foo: { ramp: [1, 2] } } }] + layers: [{id: 'a', paint: {foo: {ramp: [1, 2]}}}] }, { - layers: [{ id: 'a', paint: { foo: { ramp: [1] } } }] + layers: [{id: 'a', paint: {foo: {ramp: [1]}}}] }), [ - { command: 'setPaintProperty', args: ['a', 'foo', { ramp: [1] }, null] } + {command: 'setPaintProperty', args: ['a', 'foo', {ramp: [1]}, null]} ], 'nested style change'); t.deepEqual(diffStyles({ - layers: [{ id: 'a', layout: { foo: 1 } }] + layers: [{id: 'a', layout: {foo: 1}}] }, { - layers: [{ id: 'a', layout: { foo: 2 } }] + layers: [{id: 'a', layout: {foo: 2}}] }), [ - { command: 'setLayoutProperty', args: ['a', 'foo', 2, null] } + {command: 'setLayoutProperty', args: ['a', 'foo', 2, null]} ], 'update layout property'); t.deepEqual(diffStyles({ - layers: [{ id: 'a', filter: ['==', 'foo', 'bar'] }] + layers: [{id: 'a', filter: ['==', 'foo', 'bar']}] }, { - layers: [{ id: 'a', filter: ['==', 'foo', 'baz'] }] + layers: [{id: 'a', filter: ['==', 'foo', 'baz']}] }), [ - { command: 'setFilter', args: ['a', [ '==', 'foo', 'baz' ] ] } + {command: 'setFilter', args: ['a', [ '==', 'foo', 'baz' ] ]} ], 'update a filter'); t.deepEqual(diffStyles({ - sources: { foo: 1 } + sources: {foo: 1} }, { sources: {} }), [ - { command: 'removeSource', args: ['foo'] } + {command: 'removeSource', args: ['foo']} ], 'remove a source'); t.deepEqual(diffStyles({ sources: {} }, { - sources: { foo: 1 } + sources: {foo: 1} }), [ - { command: 'addSource', args: ['foo', 1] } + {command: 'addSource', args: ['foo', 1]} ], 'add a source'); t.deepEqual(diffStyles({ sources: { foo: { type: 'geojson', - data: { type: 'FeatureCollection', features: [] } + data: {type: 'FeatureCollection', features: []} } } }, { @@ -123,17 +123,17 @@ test('diff', (t) => { type: 'FeatureCollection', features: [{ type: 'Feature', - geometry: { type: 'Point', coordinates: [10, 20] } + geometry: {type: 'Point', coordinates: [10, 20]} }] } } } }), [ - { command: 'setGeoJSONSourceData', args: ['foo', { + {command: 'setGeoJSONSourceData', args: ['foo', { type: 'FeatureCollection', features: [{ type: 'Feature', - geometry: { type: 'Point', coordinates: [10, 20] } + geometry: {type: 'Point', coordinates: [10, 20]} }] }]} ], 'update a geojson source'); @@ -142,23 +142,23 @@ test('diff', (t) => { sources: { foo: { type: 'geojson', - data: { type: 'FeatureCollection', features: [] } + data: {type: 'FeatureCollection', features: []} } } }, { sources: { foo: { type: 'geojson', - data: { type: 'FeatureCollection', features: [] }, + data: {type: 'FeatureCollection', features: []}, cluster: true } } }), [ - { command: 'removeSource', args: ['foo'] }, - { command: 'addSource', args: ['foo', { + {command: 'removeSource', args: ['foo']}, + {command: 'addSource', args: ['foo', { type: 'geojson', cluster: true, - data: { type: 'FeatureCollection', features: [] } + data: {type: 'FeatureCollection', features: []} }]} ], 'remove and re-add a source if cluster changes'); @@ -166,7 +166,7 @@ test('diff', (t) => { sources: { foo: { type: 'geojson', - data: { type: 'FeatureCollection', features: [] }, + data: {type: 'FeatureCollection', features: []}, cluster: true } } @@ -174,18 +174,18 @@ test('diff', (t) => { sources: { foo: { type: 'geojson', - data: { type: 'FeatureCollection', features: [] }, + data: {type: 'FeatureCollection', features: []}, cluster: true, clusterRadius: 100 } } }), [ - { command: 'removeSource', args: ['foo'] }, - { command: 'addSource', args: ['foo', { + {command: 'removeSource', args: ['foo']}, + {command: 'addSource', args: ['foo', { type: 'geojson', cluster: true, clusterRadius: 100, - data: { type: 'FeatureCollection', features: [] } + data: {type: 'FeatureCollection', features: []} }]} ], 'remove and re-add a source if cluster radius changes'); @@ -193,7 +193,7 @@ test('diff', (t) => { sources: { foo: { type: 'geojson', - data: { type: 'FeatureCollection', features: [] }, + data: {type: 'FeatureCollection', features: []}, cluster: true, clusterRadius: 100 } @@ -202,27 +202,27 @@ test('diff', (t) => { sources: { foo: { type: 'geojson', - data: { type: 'FeatureCollection', features: [] }, + data: {type: 'FeatureCollection', features: []}, cluster: true } } }), [ - { command: 'removeSource', args: ['foo'] }, - { command: 'addSource', args: ['foo', { + {command: 'removeSource', args: ['foo']}, + {command: 'addSource', args: ['foo', { type: 'geojson', cluster: true, - data: { type: 'FeatureCollection', features: [] } + data: {type: 'FeatureCollection', features: []} }]} ], 'remove and re-add a source if cluster radius changes (before and after swapped)'); t.deepEqual(diffStyles({}, { - metadata: { 'mapbox:author': 'nobody' } + metadata: {'mapbox:author': 'nobody'} }), [], 'ignore style metadata'); t.deepEqual(diffStyles({ - layers: [{ id: 'a', metadata: { 'mapbox:group': 'Group Name' } }] + layers: [{id: 'a', metadata: {'mapbox:group': 'Group Name'}}] }, { - layers: [{ id: 'a', metadata: { 'mapbox:group': 'Another Name' } }] + layers: [{id: 'a', metadata: {'mapbox:group': 'Another Name'}}] }), [], 'ignore layer metadata'); t.deepEqual(diffStyles({ @@ -230,7 +230,7 @@ test('diff', (t) => { }, { center: [1, 1] }), [ - { command: 'setCenter', args: [[1, 1]] } + {command: 'setCenter', args: [[1, 1]]} ], 'center change'); t.deepEqual(diffStyles({ @@ -238,7 +238,7 @@ test('diff', (t) => { }, { zoom: 15 }), [ - { command: 'setZoom', args: [15] } + {command: 'setZoom', args: [15]} ], 'zoom change'); t.deepEqual(diffStyles({ @@ -246,7 +246,7 @@ test('diff', (t) => { }, { bearing: 180 }), [ - { command: 'setBearing', args: [180] } + {command: 'setBearing', args: [180]} ], 'bearing change'); t.deepEqual(diffStyles({ @@ -254,7 +254,7 @@ test('diff', (t) => { }, { pitch: 1 }), [ - { command: 'setPitch', args: [1] } + {command: 'setPitch', args: [1]} ], 'pitch change'); t.deepEqual(diffStyles({ @@ -275,35 +275,35 @@ test('diff', (t) => { ], 'light no change'); t.deepEqual(diffStyles({ - light: { anchor: 'map' } + light: {anchor: 'map'} }, { - light: { anchor: 'viewport' } + light: {anchor: 'viewport'} }), [ - { command: 'setLight', args: [{'anchor': 'viewport'}] } + {command: 'setLight', args: [{'anchor': 'viewport'}]} ], 'light anchor change'); t.deepEqual(diffStyles({ - light: { color: 'white' } + light: {color: 'white'} }, { - light: { color: 'red' } + light: {color: 'red'} }), [ - { command: 'setLight', args: [{'color': 'red'}] } + {command: 'setLight', args: [{'color': 'red'}]} ], 'light color change'); t.deepEqual(diffStyles({ - light: { position: [0, 1, 0] } + light: {position: [0, 1, 0]} }, { - light: { position: [1, 0, 0] } + light: {position: [1, 0, 0]} }), [ - { command: 'setLight', args: [{'position': [1, 0, 0]}] } + {command: 'setLight', args: [{'position': [1, 0, 0]}]} ], 'light position change'); t.deepEqual(diffStyles({ - light: { intensity: 1 } + light: {intensity: 1} }, { - light: { intensity: 10 } + light: {intensity: 10} }), [ - { command: 'setLight', args: [{'intensity': 10}] } + {command: 'setLight', args: [{'intensity': 10}]} ], 'light intensity change'); t.deepEqual(diffStyles({ @@ -321,94 +321,94 @@ test('diff', (t) => { intensity: 1.0 } }), [ - { command: 'setLight', args: [{ + {command: 'setLight', args: [{ anchor: 'map', color: 'red', position: [1, 40, 30], intensity: 1.0 - }] } + }]} ], 'multiple light properties change'); t.deepEqual(diffStyles({ - layers: [ { id: 'a', source: 'source-one' } ] + layers: [ {id: 'a', source: 'source-one'} ] }, { - layers: [ { id: 'a', source: 'source-two' } ] + layers: [ {id: 'a', source: 'source-two'} ] }), [ - { command: 'removeLayer', args: ['a'] }, - { command: 'addLayer', args: [{ id: 'a', source: 'source-two' }, undefined] } + {command: 'removeLayer', args: ['a']}, + {command: 'addLayer', args: [{id: 'a', source: 'source-two'}, undefined]} ], 'updating a layer\'s source removes/re-adds the layer'); t.deepEqual(diffStyles({ - layers: [{ id: 'a', type: 'fill' }] + layers: [{id: 'a', type: 'fill'}] }, { - layers: [{ id: 'a', type: 'line' }] + layers: [{id: 'a', type: 'line'}] }), [ - { command: 'removeLayer', args: ['a'] }, - { command: 'addLayer', args: [{ id: 'a', type: 'line' }, undefined] } + {command: 'removeLayer', args: ['a']}, + {command: 'addLayer', args: [{id: 'a', type: 'line'}, undefined]} ], 'updating a layer\'s type removes/re-adds the layer'); t.deepEqual(diffStyles({ - layers: [{ id: 'a', source: 'a', 'source-layer': 'layer-one' }] + layers: [{id: 'a', source: 'a', 'source-layer': 'layer-one'}] }, { - layers: [{ id: 'a', source: 'a', 'source-layer': 'layer-two' }] + layers: [{id: 'a', source: 'a', 'source-layer': 'layer-two'}] }), [ - { command: 'removeLayer', args: ['a'] }, - { command: 'addLayer', args: [{ id: 'a', source: 'a', 'source-layer': 'layer-two' }, undefined] } + {command: 'removeLayer', args: ['a']}, + {command: 'addLayer', args: [{id: 'a', source: 'a', 'source-layer': 'layer-two'}, undefined]} ], 'updating a layer\'s source-layer removes/re-adds the layer'); t.deepEqual(diffStyles({ layers: [ - { id: 'b' }, - { id: 'c' }, - { id: 'a', type: 'fill' } + {id: 'b'}, + {id: 'c'}, + {id: 'a', type: 'fill'} ] }, { layers: [ - { id: 'c' }, - { id: 'a', type: 'line' }, - { id: 'b' } + {id: 'c'}, + {id: 'a', type: 'line'}, + {id: 'b'} ] }), [ - { command: 'removeLayer', args: ['b'] }, - { command: 'addLayer', args: [{id: 'b'}, undefined] }, - { command: 'removeLayer', args: ['a'] }, - { command: 'addLayer', args: [{ id: 'a', type: 'line' }, 'b'] } + {command: 'removeLayer', args: ['b']}, + {command: 'addLayer', args: [{id: 'b'}, undefined]}, + {command: 'removeLayer', args: ['a']}, + {command: 'addLayer', args: [{id: 'a', type: 'line'}, 'b']} ], 'pair respects layer reordering'); t.deepEqual(diffStyles({ - sources: { foo: { data: 1 }, bar: {} }, + sources: {foo: {data: 1}, bar: {}}, layers: [ - { id: 'a', source: 'bar' }, - { id: 'b', source: 'foo' }, - { id: 'c', source: 'bar' } + {id: 'a', source: 'bar'}, + {id: 'b', source: 'foo'}, + {id: 'c', source: 'bar'} ] }, { - sources: { foo: { data: 2 }, bar: {} }, + sources: {foo: {data: 2}, bar: {}}, layers: [ - { id: 'a', source: 'bar' }, - { id: 'b', source: 'foo' }, - { id: 'c', source: 'bar' } + {id: 'a', source: 'bar'}, + {id: 'b', source: 'foo'}, + {id: 'c', source: 'bar'} ] }), [ - { command: 'removeLayer', args: ['b'] }, - { command: 'removeSource', args: ['foo'] }, - { command: 'addSource', args: ['foo', { data: 2 }] }, - { command: 'addLayer', args: [{id: 'b', source: 'foo'}, 'c'] } + {command: 'removeLayer', args: ['b']}, + {command: 'removeSource', args: ['foo']}, + {command: 'addSource', args: ['foo', {data: 2}]}, + {command: 'addLayer', args: [{id: 'b', source: 'foo'}, 'c']} ], 'changing a source removes and re-adds dependent layers'); t.deepEqual(diffStyles({ - sources: { foo: { data: 1 }, bar: {} }, + sources: {foo: {data: 1}, bar: {}}, layers: [ - { id: 'a', source: 'bar' } + {id: 'a', source: 'bar'} ] }, { - sources: { foo: { data: 1 }, bar: {} }, + sources: {foo: {data: 1}, bar: {}}, layers: [ - { id: 'a', source: 'bar' } + {id: 'a', source: 'bar'} ], transition: 'transition' }), [ - { command: 'setTransition', args: ['transition'] } + {command: 'setTransition', args: ['transition']} ], 'changing transition'); t.end(); diff --git a/test/unit/style-spec/expression.test.js b/test/unit/style-spec/expression.test.js index c5bc0fe889e..7579190a657 100644 --- a/test/unit/style-spec/expression.test.js +++ b/test/unit/style-spec/expression.test.js @@ -1,5 +1,5 @@ -import { test } from '../../util/test'; -import { createPropertyExpression } from '../../../src/style-spec/expression'; +import {test} from '../../util/test'; +import {createPropertyExpression} from '../../../src/style-spec/expression'; import definitions from '../../../src/style-spec/expression/definitions'; import v8 from '../../../src/style-spec/reference/v8'; @@ -53,8 +53,8 @@ test('evaluate expression', (t) => { t.equal(value.kind, 'source'); - t.equal(value.evaluate({}, { properties: {x: 'b'} }), 'b'); - t.equal(value.evaluate({}, { properties: {x: 'invalid'} }), 'a'); + t.equal(value.evaluate({}, {properties: {x: 'b'}}), 'b'); + t.equal(value.evaluate({}, {properties: {x: 'invalid'}}), 'a'); t.ok(console.warn.calledWith(`Expected value to be one of "a", "b", "c", but found "invalid" instead.`)); t.end(); diff --git a/test/unit/style-spec/feature_filter.test.js b/test/unit/style-spec/feature_filter.test.js index 1eb86ba80f5..0bb574b67b0 100644 --- a/test/unit/style-spec/feature_filter.test.js +++ b/test/unit/style-spec/feature_filter.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import createFilter from '../../../src/style-spec/feature_filter'; import convertFilter from '../../../src/style-spec/feature_filter/convert'; @@ -26,12 +26,12 @@ test('filter', t => { }); t.test('expression, collator comparison', (t) => { - const caseSensitive = createFilter(['==', ['string', ['get', 'x']], ['string', ['get', 'y']], ['collator', { 'case-sensitive': true }]]); + const caseSensitive = createFilter(['==', ['string', ['get', 'x']], ['string', ['get', 'y']], ['collator', {'case-sensitive': true}]]); t.equal(caseSensitive({zoom: 0}, {properties: {x: 'a', y: 'b'}}), false); t.equal(caseSensitive({zoom: 0}, {properties: {x: 'a', y: 'A'}}), false); t.equal(caseSensitive({zoom: 0}, {properties: {x: 'a', y: 'a'}}), true); - const caseInsensitive = createFilter(['==', ['string', ['get', 'x']], ['string', ['get', 'y']], ['collator', { 'case-sensitive': false }]]); + const caseInsensitive = createFilter(['==', ['string', ['get', 'x']], ['string', ['get', 'y']], ['collator', {'case-sensitive': false}]]); t.equal(caseInsensitive({zoom: 0}, {properties: {x: 'a', y: 'b'}}), false); t.equal(caseInsensitive({zoom: 0}, {properties: {x: 'a', y: 'A'}}), true); t.equal(caseInsensitive({zoom: 0}, {properties: {x: 'a', y: 'a'}}), true); diff --git a/test/unit/style-spec/format.test.js b/test/unit/style-spec/format.test.js index 0d29b43f02a..bfd619084ba 100644 --- a/test/unit/style-spec/format.test.js +++ b/test/unit/style-spec/format.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import format from '../../../src/style-spec/format'; function roundtrip(style) { diff --git a/test/unit/style-spec/function.test.js b/test/unit/style-spec/function.test.js index f77e6ee33e0..9fa3facf1fe 100644 --- a/test/unit/style-spec/function.test.js +++ b/test/unit/style-spec/function.test.js @@ -1,8 +1,8 @@ -import { test } from '../../util/test'; -import { createFunction } from '../../../src/style-spec/function'; +import {test} from '../../util/test'; +import {createFunction} from '../../../src/style-spec/function'; import Color from '../../../src/style-spec/util/color'; import Formatted from '../../../src/style-spec/expression/types/formatted'; -import { equalWithPrecision } from '../../util'; +import {equalWithPrecision} from '../../util'; test('binary search', (t) => { t.test('will eventually terminate.', (t) => { @@ -329,20 +329,20 @@ test('exponential function', (t) => { const f = createFunction({ type: 'exponential', property: 'prop', - stops: [[{ zoom: 1, value: 1 }, 2]] + stops: [[{zoom: 1, value: 1}, 2]] }, { type: 'number' }).evaluate; - t.equal(f({zoom: 0}, {properties: { prop: 0 }}), 2); - t.equal(f({zoom: 1}, {properties: { prop: 0 }}), 2); - t.equal(f({zoom: 2}, {properties: { prop: 0 }}), 2); - t.equal(f({zoom: 0}, {properties: { prop: 1 }}), 2); - t.equal(f({zoom: 1}, {properties: { prop: 1 }}), 2); - t.equal(f({zoom: 2}, {properties: { prop: 1 }}), 2); - t.equal(f({zoom: 0}, {properties: { prop: 2 }}), 2); - t.equal(f({zoom: 1}, {properties: { prop: 2 }}), 2); - t.equal(f({zoom: 2}, {properties: { prop: 2 }}), 2); + t.equal(f({zoom: 0}, {properties: {prop: 0}}), 2); + t.equal(f({zoom: 1}, {properties: {prop: 0}}), 2); + t.equal(f({zoom: 2}, {properties: {prop: 0}}), 2); + t.equal(f({zoom: 0}, {properties: {prop: 1}}), 2); + t.equal(f({zoom: 1}, {properties: {prop: 1}}), 2); + t.equal(f({zoom: 2}, {properties: {prop: 1}}), 2); + t.equal(f({zoom: 0}, {properties: {prop: 2}}), 2); + t.equal(f({zoom: 1}, {properties: {prop: 2}}), 2); + t.equal(f({zoom: 2}, {properties: {prop: 2}}), 2); t.end(); }); @@ -353,24 +353,24 @@ test('exponential function', (t) => { property: 'prop', base: 1, stops: [ - [{ zoom: 1, value: 0 }, 0], - [{ zoom: 1, value: 2 }, 4], - [{ zoom: 3, value: 0 }, 0], - [{ zoom: 3, value: 2 }, 12]] + [{zoom: 1, value: 0}, 0], + [{zoom: 1, value: 2}, 4], + [{zoom: 3, value: 0}, 0], + [{zoom: 3, value: 2}, 12]] }, { type: 'number' }).evaluate; - t.equal(f({zoom: 0}, {properties: { prop: 1 }}), 2); - t.equal(f({zoom: 1}, {properties: { prop: 1 }}), 2); - t.equal(f({zoom: 2}, {properties: { prop: 1 }}), 4); - t.equal(f({zoom: 3}, {properties: { prop: 1 }}), 6); - t.equal(f({zoom: 4}, {properties: { prop: 1 }}), 6); + t.equal(f({zoom: 0}, {properties: {prop: 1}}), 2); + t.equal(f({zoom: 1}, {properties: {prop: 1}}), 2); + t.equal(f({zoom: 2}, {properties: {prop: 1}}), 4); + t.equal(f({zoom: 3}, {properties: {prop: 1}}), 6); + t.equal(f({zoom: 4}, {properties: {prop: 1}}), 6); - t.equal(f({zoom: 2}, {properties: { prop: -1}}), 0); - t.equal(f({zoom: 2}, {properties: { prop: 0}}), 0); - t.equal(f({zoom: 2}, {properties: { prop: 2}}), 8); - t.equal(f({zoom: 2}, {properties: { prop: 3}}), 8); + t.equal(f({zoom: 2}, {properties: {prop: -1}}), 0); + t.equal(f({zoom: 2}, {properties: {prop: 0}}), 0); + t.equal(f({zoom: 2}, {properties: {prop: 2}}), 8); + t.equal(f({zoom: 2}, {properties: {prop: 3}}), 8); t.end(); }); @@ -381,19 +381,19 @@ test('exponential function', (t) => { property: 'prop', base: 1, stops: [ - [{ zoom: 1, value: 0}, 0], - [{ zoom: 1, value: 2}, 4], - [{ zoom: 3, value: 0}, 0], - [{ zoom: 3, value: 2}, 12], - [{ zoom: 5, value: 0}, 0], - [{ zoom: 5, value: 2}, 20]] + [{zoom: 1, value: 0}, 0], + [{zoom: 1, value: 2}, 4], + [{zoom: 3, value: 0}, 0], + [{zoom: 3, value: 2}, 12], + [{zoom: 5, value: 0}, 0], + [{zoom: 5, value: 2}, 20]] }, { type: 'number' }).evaluate; - t.equal(f({zoom: 0}, {properties: { prop: 1 }}), 2); - t.equal(f({zoom: 1}, {properties: { prop: 1 }}), 2); - t.equal(f({zoom: 2}, {properties: { prop: 1 }}), 4); + t.equal(f({zoom: 0}, {properties: {prop: 1}}), 2); + t.equal(f({zoom: 1}, {properties: {prop: 1}}), 2); + t.equal(f({zoom: 2}, {properties: {prop: 1}}), 4); t.end(); }); @@ -404,16 +404,16 @@ test('exponential function', (t) => { property: 'prop', base: 1, stops: [ - [{ zoom: 1.9, value: 0 }, 4], - [{ zoom: 2.1, value: 0 }, 8] + [{zoom: 1.9, value: 0}, 4], + [{zoom: 2.1, value: 0}, 8] ] }, { type: 'number' }).evaluate; - t.equal(f({zoom: 1.9}, {properties: { prop: 1 }}), 4); - t.equal(f({zoom: 2}, {properties: { prop: 1 }}), 6); - t.equal(f({zoom: 2.1}, {properties: { prop: 1 }}), 8); + t.equal(f({zoom: 1.9}, {properties: {prop: 1}}), 4); + t.equal(f({zoom: 2}, {properties: {prop: 1}}), 6); + t.equal(f({zoom: 2.1}, {properties: {prop: 1}}), 8); t.end(); }); @@ -424,19 +424,19 @@ test('exponential function', (t) => { property: 'prop', base: 1, stops: [ - [{ zoom: 1, value: 0 }, 0], - [{ zoom: 1.5, value: 0 }, 1], - [{ zoom: 2, value: 0 }, 10], - [{ zoom: 2.5, value: 0 }, 20] + [{zoom: 1, value: 0}, 0], + [{zoom: 1.5, value: 0}, 1], + [{zoom: 2, value: 0}, 10], + [{zoom: 2.5, value: 0}, 20] ] }, { type: 'number' }).evaluate; - t.equal(f({zoom: 1}, {properties: { prop: 0 }}), 0); - t.equal(f({zoom: 1.5}, {properties: { prop: 0 }}), 1); - t.equal(f({zoom: 2}, {properties: { prop: 0 }}), 10); - t.equal(f({zoom: 2.5}, {properties: { prop: 0 }}), 20); + t.equal(f({zoom: 1}, {properties: {prop: 0}}), 0); + t.equal(f({zoom: 1.5}, {properties: {prop: 0}}), 1); + t.equal(f({zoom: 2}, {properties: {prop: 0}}), 10); + t.equal(f({zoom: 2.5}, {properties: {prop: 0}}), 20); t.end(); }); @@ -449,8 +449,8 @@ test('exponential function', (t) => { property: 'prop', base: 1, stops: [ - [{ zoom: 0, value: 1 }, 'red'], - [{ zoom: 1, value: 1 }, 'red'] + [{zoom: 0, value: 1}, 'red'], + [{zoom: 1, value: 1}, 'red'] ] }, { type: 'color' @@ -1043,7 +1043,7 @@ test('kind', (t) => { t.test('composite', (t) => { const f = createFunction({ - stops: [[{ zoom: 1, value: 1 }, 1]], + stops: [[{zoom: 1, value: 1}, 1]], property: 'mapbox' }, { type: 'number' diff --git a/test/unit/style-spec/group_by_layout.test.js b/test/unit/style-spec/group_by_layout.test.js index 3ffe880761f..cd5f5d457ba 100644 --- a/test/unit/style-spec/group_by_layout.test.js +++ b/test/unit/style-spec/group_by_layout.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import group from '../../../src/style-spec/group_by_layout'; test('group layers whose ref properties are identical', (t) => { diff --git a/test/unit/style-spec/interpolate.test.js b/test/unit/style-spec/interpolate.test.js index 896927d32ab..996fead20d0 100644 --- a/test/unit/style-spec/interpolate.test.js +++ b/test/unit/style-spec/interpolate.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import * as interpolate from '../../../src/style-spec/util/interpolate'; import Color from '../../../src/style-spec/util/color'; diff --git a/test/unit/style-spec/migrate.test.js b/test/unit/style-spec/migrate.test.js index 5b7cd5e96bc..441e9037673 100644 --- a/test/unit/style-spec/migrate.test.js +++ b/test/unit/style-spec/migrate.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import fs from 'fs'; import glob from 'glob'; import path from 'path'; diff --git a/test/unit/style-spec/migrate/v8.js b/test/unit/style-spec/migrate/v8.js index 46e8ad81b3f..0687d3f398a 100644 --- a/test/unit/style-spec/migrate/v8.js +++ b/test/unit/style-spec/migrate/v8.js @@ -1,4 +1,4 @@ -import { test } from '../../../util/test'; +import {test} from '../../../util/test'; import migrate from '../../../../src/style-spec/migrate/v8'; test('split text-font', (t) => { diff --git a/test/unit/style-spec/migrate/v9.js b/test/unit/style-spec/migrate/v9.js index 8cc9fe72b57..51ab4371957 100644 --- a/test/unit/style-spec/migrate/v9.js +++ b/test/unit/style-spec/migrate/v9.js @@ -1,11 +1,11 @@ -import { test } from '../../../util/test'; +import {test} from '../../../util/test'; import migrate from '../../../../src/style-spec/migrate/v9'; test('deref layers', (t) => { const input = { version: 8, sources: { - a: { type: 'vector', tiles: [ 'http://dev/null' ] } + a: {type: 'vector', tiles: [ 'http://dev/null' ]} }, layers: [{ id: 'parent', @@ -21,7 +21,7 @@ test('deref layers', (t) => { t.deepEqual(migrate(input), { version: 9, sources: { - a: { type: 'vector', tiles: [ 'http://dev/null' ] } + a: {type: 'vector', tiles: [ 'http://dev/null' ]} }, layers: [{ id: 'parent', @@ -43,7 +43,7 @@ test('declass style', (t) => { const input = { version: 8, sources: { - a: { type: 'vector', tiles: [ 'http://dev/null' ] } + a: {type: 'vector', tiles: [ 'http://dev/null' ]} }, layers: [{ id: 'a', @@ -62,7 +62,7 @@ test('declass style', (t) => { t.deepEqual(migrate(input), { version: 9, sources: { - a: { type: 'vector', tiles: [ 'http://dev/null' ] } + a: {type: 'vector', tiles: [ 'http://dev/null' ]} }, layers: [{ id: 'a', diff --git a/test/unit/style-spec/spec.test.js b/test/unit/style-spec/spec.test.js index ea30f7a02bd..e0ec6fc0cc1 100644 --- a/test/unit/style-spec/spec.test.js +++ b/test/unit/style-spec/spec.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; /* eslint-disable import/namespace */ import * as spec from '../../../src/style-spec/style-spec'; diff --git a/test/unit/style-spec/stops.test.js b/test/unit/style-spec/stops.test.js index ed989c5af9e..8eaf756606f 100644 --- a/test/unit/style-spec/stops.test.js +++ b/test/unit/style-spec/stops.test.js @@ -1,5 +1,5 @@ -import { test } from '../../util/test'; -import { findStopLessThanOrEqualTo } from '../../../src/style-spec/expression/stops'; +import {test} from '../../util/test'; +import {findStopLessThanOrEqualTo} from '../../../src/style-spec/expression/stops'; test('findStopLessThanOrEqualTo', (t) => { test('When the input > all stops it returns the last stop.', (t) => { diff --git a/test/unit/style-spec/util/color_spaces.test.js b/test/unit/style-spec/util/color_spaces.test.js index 6b2f9d46ff1..979e0a22db2 100644 --- a/test/unit/style-spec/util/color_spaces.test.js +++ b/test/unit/style-spec/util/color_spaces.test.js @@ -1,4 +1,4 @@ -import { test } from '../../../util/test'; +import {test} from '../../../util/test'; import * as colorSpaces from '../../../../src/style-spec/util/color_spaces'; import Color from '../../../../src/style-spec/util/color'; diff --git a/test/unit/style-spec/validate.test.js b/test/unit/style-spec/validate.test.js index 15f92d18c96..64fd3080d92 100644 --- a/test/unit/style-spec/validate.test.js +++ b/test/unit/style-spec/validate.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import glob from 'glob'; import fs from 'fs'; import path from 'path'; diff --git a/test/unit/style/light.test.js b/test/unit/style/light.test.js index eb49f9e5276..584d42cf6aa 100644 --- a/test/unit/style/light.test.js +++ b/test/unit/style/light.test.js @@ -1,8 +1,8 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import Light from '../../../src/style/light'; import styleSpec from '../../../src/style-spec/reference/latest'; import Color from '../../../src/style-spec/util/color'; -import { sphericalToCartesian } from '../../../src/util/util'; +import {sphericalToCartesian} from '../../../src/util/util'; const spec = styleSpec.light; @@ -60,8 +60,8 @@ test('Light#getLight', (t) => { test('Light#setLight', (t) => { t.test('sets light', (t) => { const light = new Light({}); - light.setLight({ color: 'red', "color-transition": { duration: 3000 }}); - light.updateTransitions({ transition: true }, {}); + light.setLight({color: 'red', "color-transition": {duration: 3000}}); + light.updateTransitions({transition: true}, {}); light.recalculate({zoom: 16, zoomHistory: {}, now: 1500}); t.deepEqual(light.properties.get('color'), new Color(1, 0.5, 0.5, 1)); t.end(); @@ -71,8 +71,8 @@ test('Light#setLight', (t) => { const light = new Light({}); const lightSpy = t.spy(light, '_validate'); t.stub(console, 'error'); - light.setLight({ color: 'notacolor'}); - light.updateTransitions({ transition: false}, {}); + light.setLight({color: 'notacolor'}); + light.updateTransitions({transition: false}, {}); light.recalculate({zoom: 16, zoomHistory: {}, now: 10}); t.ok(lightSpy.calledOnce); t.ok(console.error.calledOnce); @@ -84,8 +84,8 @@ test('Light#setLight', (t) => { const light = new Light({}); const lightSpy = t.spy(light, '_validate'); - light.setLight({ color: [999]}, {validate: false}); - light.updateTransitions({ transition: false}, {}); + light.setLight({color: [999]}, {validate: false}); + light.updateTransitions({transition: false}, {}); light.recalculate({zoom: 16, zoomHistory: {}, now: 10}); t.ok(lightSpy.calledOnce); diff --git a/test/unit/style/load_glyph_range.test.js b/test/unit/style/load_glyph_range.test.js index 65cfc2dbb79..ee055e3096c 100644 --- a/test/unit/style/load_glyph_range.test.js +++ b/test/unit/style/load_glyph_range.test.js @@ -1,10 +1,10 @@ // @flow -import { test } from '../../util/test'; +import {test} from '../../util/test'; import fs from 'fs'; import path from 'path'; import window from '../../../src/util/window'; -import { RequestManager } from '../../../src/util/mapbox'; +import {RequestManager} from '../../../src/util/mapbox'; import loadGlyphRange from '../../../src/style/load_glyph_range'; test('loadGlyphRange', (t) => { diff --git a/test/unit/style/style.test.js b/test/unit/style/style.test.js index 7020658e535..2c01e6edf1a 100644 --- a/test/unit/style/style.test.js +++ b/test/unit/style/style.test.js @@ -1,12 +1,12 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import assert from 'assert'; import Style from '../../../src/style/style'; import SourceCache from '../../../src/source/source_cache'; import StyleLayer from '../../../src/style/style_layer'; import Transform from '../../../src/geo/transform'; -import { extend } from '../../../src/util/util'; -import { RequestManager } from '../../../src/util/mapbox'; -import { Event, Evented } from '../../../src/util/evented'; +import {extend} from '../../../src/util/util'; +import {RequestManager} from '../../../src/util/mapbox'; +import {Event, Evented} from '../../../src/util/evented'; import window from '../../../src/util/window'; import { setRTLTextPlugin, @@ -14,7 +14,7 @@ import { evented as rtlTextPluginEvented } from '../../../src/source/rtl_text_plugin'; import browser from '../../../src/util/browser'; -import { OverscaledTileID } from '../../../src/source/tile_id'; +import {OverscaledTileID} from '../../../src/source/tile_id'; function createStyleJSON(properties) { return extend({ @@ -343,7 +343,7 @@ test('Style#loadJSON', (t) => { const style = new Style(new StubMap()); style.loadJSON(createStyleJSON({ sources: { - '-source-id-': { type: "vector", tiles: [] } + '-source-id-': {type: "vector", tiles: []} }, layers: [] })); @@ -352,7 +352,7 @@ test('Style#loadJSON', (t) => { style.removeSource('-source-id-'); const source = createSource(); - source['vector_layers'] = [{ id: 'green' }]; + source['vector_layers'] = [{id: 'green'}]; style.addSource('-source-id-', source); style.addLayer({ 'id': '-layer-id-', @@ -450,8 +450,8 @@ test('Style#update', (t) => { style.on('error', (error) => { t.error(error); }); style.on('style.load', () => { - style.addLayer({id: 'first', source: 'source', type: 'fill', 'source-layer': 'source-layer' }, 'second'); - style.addLayer({id: 'third', source: 'source', type: 'fill', 'source-layer': 'source-layer' }); + style.addLayer({id: 'first', source: 'source', type: 'fill', 'source-layer': 'source-layer'}, 'second'); + style.addLayer({id: 'third', source: 'source', type: 'fill', 'source-layer': 'source-layer'}); style.removeLayer('second'); style.dispatcher.broadcast = function(key, value) { @@ -522,7 +522,7 @@ test('Style#setState', (t) => { sources: { foo: { type: 'geojson', - data: { type: 'FeatureCollection', features: [] } + data: {type: 'FeatureCollection', features: []} } } }); @@ -539,7 +539,7 @@ test('Style#setState', (t) => { t.test('sets GeoJSON source data if different', (t) => { const initialState = createStyleJSON({ - "sources": { "source-id": createGeoJSONSource() } + "sources": {"source-id": createGeoJSONSource()} }); const geoJSONSourceData = { @@ -844,7 +844,7 @@ test('Style#addLayer', (t) => { style.loadJSON(createStyleJSON({ sources: { // At least one source must be added to trigger the load event - dummy: { type: "vector", tiles: [] } + dummy: {type: "vector", tiles: []} } })); @@ -901,7 +901,7 @@ test('Style#addLayer', (t) => { "coordinates": [ 0, 0] } }; - const layer = {id: 'inline-source-layer', type: 'circle', source }; + const layer = {id: 'inline-source-layer', type: 'circle', source}; style.addLayer(layer); t.deepEqual(layer.source, source); t.end(); @@ -1105,7 +1105,7 @@ test('Style#addLayer', (t) => { sources: { dummy: { type: 'geojson', - data: { type: 'FeatureCollection', features: [] } + data: {type: 'FeatureCollection', features: []} } } })); @@ -1118,7 +1118,7 @@ test('Style#addLayer', (t) => { }; style.on('style.load', () => { - style.on('error', ({ error }) => { + style.on('error', ({error}) => { t.match(error.message, /does not exist on source/); t.end(); }); @@ -1181,7 +1181,7 @@ test('Style#removeLayer', (t) => { style.loadJSON(createStyleJSON()); style.on('style.load', () => { - style.on('error', ({ error }) => { + style.on('error', ({error}) => { t.match(error.message, /does not exist in the map\'s style and cannot be removed/); t.end(); }); @@ -1257,7 +1257,7 @@ test('Style#moveLayer', (t) => { style.loadJSON(createStyleJSON()); style.on('style.load', () => { - style.on('error', ({ error }) => { + style.on('error', ({error}) => { t.match(error.message, /does not exist in the map\'s style and cannot be moved/); t.end(); }); @@ -1594,7 +1594,7 @@ test('Style#setFilter', (t) => { geojson: createGeoJSONSource() }, layers: [ - { id: 'symbol', type: 'symbol', source: 'geojson', filter: ['==', 'id', 0] } + {id: 'symbol', type: 'symbol', source: 'geojson', filter: ['==', 'id', 0]} ] }); return style; @@ -1678,7 +1678,7 @@ test('Style#setFilter', (t) => { const style = createStyle(); style.on('style.load', () => { - style.on('error', ({ error }) => { + style.on('error', ({error}) => { t.match(error.message, /does not exist in the map\'s style and cannot be filtered/); t.end(); }); @@ -1760,7 +1760,7 @@ test('Style#setLayerZoomRange', (t) => { t.test('fires an error if layer not found', (t) => { const style = createStyle(); style.on('style.load', () => { - style.on('error', ({ error }) => { + style.on('error', ({error}) => { t.match(error.message, /does not exist in the map\'s style and cannot have zoom extent/); t.end(); }); @@ -1803,7 +1803,7 @@ test('Style#queryRenderedFeatures', (t) => { // format result to shape of tile.queryRenderedFeatures result for (const layer in features) { features[layer] = features[layer].map((feature, featureIndex) => - ({ feature, featureIndex })); + ({feature, featureIndex})); } if (params.layers) { @@ -1822,11 +1822,11 @@ test('Style#queryRenderedFeatures', (t) => { "sources": { "mapbox": { "type": "geojson", - "data": { type: "FeatureCollection", features: [] } + "data": {type: "FeatureCollection", features: []} }, "other": { "type": "geojson", - "data": { type: "FeatureCollection", features: [] } + "data": {type: "FeatureCollection", features: []} } }, "layers": [{ @@ -1869,7 +1869,7 @@ test('Style#queryRenderedFeatures', (t) => { style.on('style.load', () => { style.sourceCaches.mapbox.tilesIn = () => { return [{ - tile: { queryRenderedFeatures: queryMapboxFeatures }, + tile: {queryRenderedFeatures: queryMapboxFeatures}, tileID: new OverscaledTileID(0, 0, 0, 0, 0), queryGeometry: [], scale: 1 @@ -1973,9 +1973,9 @@ test('Style defers expensive methods', (t) => { t.spy(style, '_reloadSource'); t.spy(style, '_updateWorkerLayers'); - style.addLayer({ id: 'first', type: 'symbol', source: 'streets' }); - style.addLayer({ id: 'second', type: 'symbol', source: 'streets' }); - style.addLayer({ id: 'third', type: 'symbol', source: 'terrain' }); + style.addLayer({id: 'first', type: 'symbol', source: 'streets'}); + style.addLayer({id: 'second', type: 'symbol', source: 'streets'}); + style.addLayer({id: 'third', type: 'symbol', source: 'terrain'}); style.setPaintProperty('first', 'text-color', 'black'); style.setPaintProperty('first', 'text-halo-color', 'white'); @@ -2072,7 +2072,7 @@ test('Style#query*Features', (t) => { }); test('Style#addSourceType', (t) => { - const _types = { 'existing' () {} }; + const _types = {'existing' () {}}; t.stub(Style, 'getSourceType').callsFake(name => _types[name]); t.stub(Style, 'setSourceType').callsFake((name, create) => { @@ -2144,7 +2144,7 @@ test('Style#hasTransitions', (t) => { style.on('style.load', () => { style.setPaintProperty("background", "background-color", "blue"); - style.update({transition: { duration: 300, delay: 0 }}); + style.update({transition: {duration: 300, delay: 0}}); t.equal(style.hasTransitions(), true); t.end(); }); @@ -2163,7 +2163,7 @@ test('Style#hasTransitions', (t) => { style.on('style.load', () => { style.setPaintProperty("background", "background-color", "blue"); - style.update({transition: { duration: 0, delay: 0 }}); + style.update({transition: {duration: 0, delay: 0}}); t.equal(style.hasTransitions(), false); t.end(); }); diff --git a/test/unit/style/style_layer.test.js b/test/unit/style/style_layer.test.js index 63411e748c1..9152dc82f34 100644 --- a/test/unit/style/style_layer.test.js +++ b/test/unit/style/style_layer.test.js @@ -1,7 +1,7 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import createStyleLayer from '../../../src/style/create_style_layer'; import FillStyleLayer from '../../../src/style/style_layer/fill_style_layer'; -import { extend } from '../../../src/util/util'; +import {extend} from '../../../src/util/util'; import Color from '../../../src/style-spec/util/color'; test('StyleLayer', (t) => { @@ -289,7 +289,7 @@ test('StyleLayer#serialize', (t) => { }; t.deepEqual( - createStyleLayer(createSymbolLayer({ paint: layerPaint })).serialize().paint, + createStyleLayer(createSymbolLayer({paint: layerPaint})).serialize().paint, layerPaint ); t.end(); @@ -377,7 +377,7 @@ test('StyleLayer#serialize', (t) => { }; t.deepEqual( - createStyleLayer(createSymbolLayer({ paint: layerPaint })).serialize().paint, + createStyleLayer(createSymbolLayer({paint: layerPaint})).serialize().paint, layerPaint ); t.end(); diff --git a/test/unit/style/style_layer_index.test.js b/test/unit/style/style_layer_index.test.js index 027d2ae430d..90f9aa32bf9 100644 --- a/test/unit/style/style_layer_index.test.js +++ b/test/unit/style/style_layer_index.test.js @@ -1,12 +1,12 @@ -import { test } from '../../util/test'; -import { mapObject } from '../../../src/util/util'; +import {test} from '../../util/test'; +import {mapObject} from '../../../src/util/util'; import StyleLayerIndex from '../../../src/style/style_layer_index'; test('StyleLayerIndex#replace', (t) => { const index = new StyleLayerIndex([ - { id: '1', type: 'fill', source: 'source', 'source-layer': 'layer', paint: { 'fill-color': 'red' } }, - { id: '2', type: 'circle', source: 'source', 'source-layer': 'layer', paint: { 'circle-color': 'green' } }, - { id: '3', type: 'circle', source: 'source', 'source-layer': 'layer', paint: { 'circle-color': 'blue' } } + {id: '1', type: 'fill', source: 'source', 'source-layer': 'layer', paint: {'fill-color': 'red'}}, + {id: '2', type: 'circle', source: 'source', 'source-layer': 'layer', paint: {'circle-color': 'green'}}, + {id: '3', type: 'circle', source: 'source', 'source-layer': 'layer', paint: {'circle-color': 'blue'}} ]); const families = index.familiesBySource['source']['layer']; @@ -25,15 +25,15 @@ test('StyleLayerIndex#replace', (t) => { test('StyleLayerIndex#update', (t) => { const index = new StyleLayerIndex([ - { id: '1', type: 'fill', source: 'foo', 'source-layer': 'layer', paint: { 'fill-color': 'red' } }, - { id: '2', type: 'circle', source: 'foo', 'source-layer': 'layer', paint: { 'circle-color': 'green' } }, - { id: '3', type: 'circle', source: 'foo', 'source-layer': 'layer', paint: { 'circle-color': 'blue' } } + {id: '1', type: 'fill', source: 'foo', 'source-layer': 'layer', paint: {'fill-color': 'red'}}, + {id: '2', type: 'circle', source: 'foo', 'source-layer': 'layer', paint: {'circle-color': 'green'}}, + {id: '3', type: 'circle', source: 'foo', 'source-layer': 'layer', paint: {'circle-color': 'blue'}} ]); index.update([ - { id: '1', type: 'fill', source: 'bar', 'source-layer': 'layer', paint: { 'fill-color': 'cyan' } }, - { id: '2', type: 'circle', source: 'bar', 'source-layer': 'layer', paint: { 'circle-color': 'magenta' } }, - { id: '3', type: 'circle', source: 'bar', 'source-layer': 'layer', paint: { 'circle-color': 'yellow' } } + {id: '1', type: 'fill', source: 'bar', 'source-layer': 'layer', paint: {'fill-color': 'cyan'}}, + {id: '2', type: 'circle', source: 'bar', 'source-layer': 'layer', paint: {'circle-color': 'magenta'}}, + {id: '3', type: 'circle', source: 'bar', 'source-layer': 'layer', paint: {'circle-color': 'yellow'}} ], []); const families = index.familiesBySource['bar']['layer']; @@ -51,13 +51,13 @@ test('StyleLayerIndex#update', (t) => { test('StyleLayerIndex#familiesBySource', (t) => { const index = new StyleLayerIndex([ - { id: '0', type: 'fill', 'source': 'A', 'source-layer': 'foo' }, - { id: '1', type: 'fill', 'source': 'A', 'source-layer': 'foo' }, - { id: '2', type: 'fill', 'source': 'A', 'source-layer': 'foo', 'minzoom': 1 }, - { id: '3', type: 'fill', 'source': 'A', 'source-layer': 'bar' }, - { id: '4', type: 'fill', 'source': 'B', 'source-layer': 'foo' }, - { id: '5', type: 'fill', 'source': 'geojson' }, - { id: '6', type: 'background' } + {id: '0', type: 'fill', 'source': 'A', 'source-layer': 'foo'}, + {id: '1', type: 'fill', 'source': 'A', 'source-layer': 'foo'}, + {id: '2', type: 'fill', 'source': 'A', 'source-layer': 'foo', 'minzoom': 1}, + {id: '3', type: 'fill', 'source': 'A', 'source-layer': 'bar'}, + {id: '4', type: 'fill', 'source': 'B', 'source-layer': 'foo'}, + {id: '5', type: 'fill', 'source': 'geojson'}, + {id: '6', type: 'background'} ]); const ids = mapObject(index.familiesBySource, (bySource) => { @@ -89,10 +89,10 @@ test('StyleLayerIndex#familiesBySource', (t) => { test('StyleLayerIndex groups families even if layout key order differs', (t) => { const index = new StyleLayerIndex([ - { id: '0', type: 'line', 'source': 'source', 'source-layer': 'layer', - 'layout': {'line-cap': 'butt', 'line-join': 'miter'} }, - { id: '1', type: 'line', 'source': 'source', 'source-layer': 'layer', - 'layout': {'line-join': 'miter', 'line-cap': 'butt'} } + {id: '0', type: 'line', 'source': 'source', 'source-layer': 'layer', + 'layout': {'line-cap': 'butt', 'line-join': 'miter'}}, + {id: '1', type: 'line', 'source': 'source', 'source-layer': 'layer', + 'layout': {'line-join': 'miter', 'line-cap': 'butt'}} ]); const families = index.familiesBySource['source']['layer']; diff --git a/test/unit/symbol/anchor.test.js b/test/unit/symbol/anchor.test.js index d604d06f9de..1c97500f71f 100644 --- a/test/unit/symbol/anchor.test.js +++ b/test/unit/symbol/anchor.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import Anchor from '../../../src/symbol/anchor'; test('Anchor', (t) => { diff --git a/test/unit/symbol/check_max_angle.test.js b/test/unit/symbol/check_max_angle.test.js index 41dc350d054..addce67cab7 100644 --- a/test/unit/symbol/check_max_angle.test.js +++ b/test/unit/symbol/check_max_angle.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import Point from '@mapbox/point-geometry'; import checkMaxAngle from '../../../src/symbol/check_max_angle'; import Anchor from '../../../src/symbol/anchor'; diff --git a/test/unit/symbol/collision_feature.js b/test/unit/symbol/collision_feature.js index 368e0b7a470..eff6d362ebd 100644 --- a/test/unit/symbol/collision_feature.js +++ b/test/unit/symbol/collision_feature.js @@ -1,8 +1,8 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import CollisionFeature from '../../../src/symbol/collision_feature'; import Anchor from '../../../src/symbol/anchor'; import Point from '@mapbox/point-geometry'; -import { CollisionBoxArray } from '../../../src/data/array_types'; +import {CollisionBoxArray} from '../../../src/data/array_types'; test('CollisionFeature', (t) => { @@ -36,26 +36,26 @@ test('CollisionFeature', (t) => { const cf = new CollisionFeature(collisionBoxArray, line, anchor, 0, 0, 0, shapedText, 1, 0, true, 1); const boxPoints = pluckAnchorPoints(cf); t.deepEqual(boxPoints, [ - { x: 370, y: 74}, - { x: 389, y: 78}, - { x: 409, y: 82}, - { x: 428, y: 86}, - { x: 448, y: 90}, - { x: 468, y: 94}, - { x: 478, y: 96}, - { x: 487, y: 97}, - { x: 497, y: 99}, - { x: 505, y: 95}, - { x: 513, y: 89}, - { x: 522, y: 84}, - { x: 531, y: 80}, - { x: 540, y: 76}, - { x: 549, y: 72}, - { x: 558, y: 67}, - { x: 576, y: 59}, - { x: 594, y: 50}, - { x: 612, y: 42}, - { x: 630, y: 33} ]); + {x: 370, y: 74}, + {x: 389, y: 78}, + {x: 409, y: 82}, + {x: 428, y: 86}, + {x: 448, y: 90}, + {x: 468, y: 94}, + {x: 478, y: 96}, + {x: 487, y: 97}, + {x: 497, y: 99}, + {x: 505, y: 95}, + {x: 513, y: 89}, + {x: 522, y: 84}, + {x: 531, y: 80}, + {x: 540, y: 76}, + {x: 549, y: 72}, + {x: 558, y: 67}, + {x: 576, y: 59}, + {x: 594, y: 50}, + {x: 612, y: 42}, + {x: 630, y: 33} ]); t.end(); }); @@ -94,21 +94,21 @@ test('CollisionFeature', (t) => { const cf = new CollisionFeature(collisionBoxArray, line, anchor, 0, 0, 0, shapedText, 1, 0, true, 1); const boxPoints = pluckAnchorPoints(cf); t.deepEqual(boxPoints, [ - { x: 0, y: 10 }, - { x: 0, y: 30 }, - { x: 0, y: 50 }, - { x: 0, y: 70 }, - { x: 0, y: 80 }, - { x: 0, y: 90 }, - { x: 0, y: 100 }, - { x: 0, y: 110 }, - { x: 0, y: 120 }, - { x: 0, y: 130 }, - { x: 0, y: 140 }, - { x: 0, y: 150 }, - { x: 0, y: 160 }, - { x: 0, y: 170 }, - { x: 0, y: 190 } ]); + {x: 0, y: 10}, + {x: 0, y: 30}, + {x: 0, y: 50}, + {x: 0, y: 70}, + {x: 0, y: 80}, + {x: 0, y: 90}, + {x: 0, y: 100}, + {x: 0, y: 110}, + {x: 0, y: 120}, + {x: 0, y: 130}, + {x: 0, y: 140}, + {x: 0, y: 150}, + {x: 0, y: 160}, + {x: 0, y: 170}, + {x: 0, y: 190} ]); t.end(); }); @@ -160,7 +160,7 @@ test('CollisionFeature', (t) => { test('height is big enough that first box can be placed *after* anchor', (t) => { const line = [new Point(3103, 4068), new Point(3225.6206896551726, 4096)]; const anchor = new Anchor(3144.5959947505007, 4077.498298013894, 0.22449735614507618, 0); - const shaping = { right: 256, left: 0, bottom: 256, top: 0 }; + const shaping = {right: 256, left: 0, bottom: 256, top: 0}; const cf = new CollisionFeature(collisionBoxArray, line, anchor, 0, 0, 0, shaping, 1, 0, true, 1); t.equal(cf.boxEndIndex - cf.boxStartIndex, 1); t.end(); diff --git a/test/unit/symbol/cross_tile_symbol_index.js b/test/unit/symbol/cross_tile_symbol_index.js index 4bd3bd35e54..492a6aafb91 100644 --- a/test/unit/symbol/cross_tile_symbol_index.js +++ b/test/unit/symbol/cross_tile_symbol_index.js @@ -1,6 +1,6 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import CrossTileSymbolIndex from '../../../src/symbol/cross_tile_symbol_index'; -import { OverscaledTileID } from '../../../src/source/tile_id'; +import {OverscaledTileID} from '../../../src/source/tile_id'; const styleLayer = { id: 'test' diff --git a/test/unit/symbol/format_section_override.test.js b/test/unit/symbol/format_section_override.test.js index be428f96b6e..3364ba2fb06 100644 --- a/test/unit/symbol/format_section_override.test.js +++ b/test/unit/symbol/format_section_override.test.js @@ -1,5 +1,5 @@ -import { test } from '../../util/test'; -import { createExpression, ZoomConstantExpression } from '../../../src/style-spec/expression'; +import {test} from '../../util/test'; +import {createExpression, ZoomConstantExpression} from '../../../src/style-spec/expression'; import EvaluationContext from '../../../src/style-spec/expression/evaluation_context'; import properties from '../../../src/style/style_layer/symbol_style_layer_properties'; import {PossiblyEvaluatedPropertyValue} from '../../../src/style/properties'; @@ -8,11 +8,11 @@ import FormatSectionOverride from '../../../src/style-spec/expression/definition test('evaluate', (t) => { t.test('override constant', (t) => { - const defaultColor = { "r": 0, "g": 1, "b": 0, "a": 1 }; - const overridenColor = { "r": 1, "g": 0, "b": 0, "a": 1 }; + const defaultColor = {"r": 0, "g": 1, "b": 0, "a": 1}; + const overridenColor = {"r": 1, "g": 0, "b": 0, "a": 1}; const overriden = new PossiblyEvaluatedPropertyValue( properties.paint.properties['text-color'], - { kind: 'constant', value: defaultColor }, + {kind: 'constant', value: defaultColor}, {zoom: 0, zoomHistory: {}} ); @@ -31,9 +31,9 @@ test('evaluate', (t) => { t.test('override expression', (t) => { const warn = console.warn; console.warn = (_) => {}; - const defaultColor = { "r": 0, "g": 0, "b": 0, "a": 1 }; - const propertyColor = { "r": 1, "g": 0, "b": 0, "a": 1 }; - const overridenColor = { "r": 0, "g": 0, "b": 1, "a": 1 }; + const defaultColor = {"r": 0, "g": 0, "b": 0, "a": 1}; + const propertyColor = {"r": 1, "g": 0, "b": 0, "a": 1}; + const overridenColor = {"r": 0, "g": 0, "b": 1, "a": 1}; const styleExpr = createExpression( ["get", "color"], properties.paint.properties['text-color'].specification); @@ -47,7 +47,7 @@ test('evaluate', (t) => { const override = new FormatSectionOverride(overriden); const ctx = new EvaluationContext(); - ctx.feature = { properties: {}}; + ctx.feature = {properties: {}}; ctx.featureState = {}; t.deepEqual(override.evaluate(ctx), defaultColor); diff --git a/test/unit/symbol/get_anchors.test.js b/test/unit/symbol/get_anchors.test.js index 65fb45e7448..1bd083cd39f 100644 --- a/test/unit/symbol/get_anchors.test.js +++ b/test/unit/symbol/get_anchors.test.js @@ -1,6 +1,6 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import Point from '@mapbox/point-geometry'; -import { getAnchors, getCenterAnchor } from '../../../src/symbol/get_anchors'; +import {getAnchors, getCenterAnchor} from '../../../src/symbol/get_anchors'; const TILE_EXTENT = 4096; @@ -18,8 +18,8 @@ test('getAnchors', (t) => { const smallSpacing = 2; const bigSpacing = 3; - const shapedText = { left: -1, right: 1, top: -0.5, bottom: 0.5 }; - const shapedIcon = { left: -0.5, right: 0.5, top: -0.25, bottom: 0.25 }; + const shapedText = {left: -1, right: 1, top: -0.5, bottom: 0.5}; + const shapedIcon = {left: -0.5, right: 0.5, top: -0.25, bottom: 0.25}; const labelLength = Math.max( shapedText ? shapedText.right - shapedText.left : 0, shapedIcon ? shapedIcon.right - shapedIcon.left : 0); @@ -30,9 +30,9 @@ test('getAnchors', (t) => { const anchors = getAnchors(nonContinuedLine, bigSpacing, Math.PI, shapedText, shapedIcon, glyphSize, 1, 1, TILE_EXTENT); t.deepEqual(anchors, [ - { x: 1, y: 2, angle: 1.5707963267948966, segment: 1 }, - { x: 1, y: 5, angle: 1.5707963267948966, segment: 4 }, - { x: 1, y: 8, angle: 1.5707963267948966, segment: 7 } ]); + {x: 1, y: 2, angle: 1.5707963267948966, segment: 1}, + {x: 1, y: 5, angle: 1.5707963267948966, segment: 4}, + {x: 1, y: 8, angle: 1.5707963267948966, segment: 7} ]); t.ok(labelLength / 2 + 1 <= anchors[0].y && anchors[0].y < labelLength / 2 + 3 * glyphSize + 1, 'first label is placed as close to the beginning as possible'); @@ -44,9 +44,9 @@ test('getAnchors', (t) => { const anchors = getAnchors(nonContinuedLine, smallSpacing, Math.PI, shapedText, shapedIcon, glyphSize, 1, 1, TILE_EXTENT); t.deepEqual(anchors, [ - { x: 1, y: 2, angle: 1.5707963267948966, segment: 1 }, - { x: 1, y: 5, angle: 1.5707963267948966, segment: 3 }, - { x: 1, y: 7, angle: 1.5707963267948966, segment: 6 } ]); + {x: 1, y: 2, angle: 1.5707963267948966, segment: 1}, + {x: 1, y: 5, angle: 1.5707963267948966, segment: 3}, + {x: 1, y: 7, angle: 1.5707963267948966, segment: 6} ]); t.end(); }); @@ -55,9 +55,9 @@ test('getAnchors', (t) => { const anchors = getAnchors(continuedLine, bigSpacing, Math.PI, shapedText, shapedIcon, glyphSize, 1, 1, TILE_EXTENT); t.deepEqual(anchors, [ - { x: 1, y: 2, angle: 1.5707963267948966, segment: 1 }, - { x: 1, y: 5, angle: 1.5707963267948966, segment: 4 }, - { x: 1, y: 8, angle: 1.5707963267948966, segment: 7 } ]); + {x: 1, y: 2, angle: 1.5707963267948966, segment: 1}, + {x: 1, y: 5, angle: 1.5707963267948966, segment: 4}, + {x: 1, y: 8, angle: 1.5707963267948966, segment: 7} ]); t.end(); }); @@ -66,9 +66,9 @@ test('getAnchors', (t) => { const anchors = getAnchors(continuedLine, smallSpacing, Math.PI, shapedText, shapedIcon, glyphSize, 1, 1, TILE_EXTENT); t.deepEqual(anchors, [ - { x: 1, y: 1, angle: 1.5707963267948966, segment: 1 }, - { x: 1, y: 4, angle: 1.5707963267948966, segment: 3 }, - { x: 1, y: 6, angle: 1.5707963267948966, segment: 6 } ]); + {x: 1, y: 1, angle: 1.5707963267948966, segment: 1}, + {x: 1, y: 4, angle: 1.5707963267948966, segment: 3}, + {x: 1, y: 6, angle: 1.5707963267948966, segment: 6} ]); t.end(); }); @@ -95,7 +95,7 @@ test('getAnchors', (t) => { const line = [new Point(1, 1), new Point(1, 3.1)]; const anchors = getAnchors(line, 2, Math.PI, shapedText, shapedIcon, glyphSize, 1, 1, TILE_EXTENT); t.deepEqual(anchors, [ - { x: 1, y: 2, angle: 1.5707963267948966, segment: 0 }]); + {x: 1, y: 2, angle: 1.5707963267948966, segment: 0}]); t.end(); }); @@ -103,7 +103,7 @@ test('getAnchors', (t) => { const line = [new Point(1, 1), new Point(1, 3.1), new Point(3, 6), new Point(4, 7)]; const anchor = getCenterAnchor(line, Math.PI, shapedText, shapedIcon, glyphSize, 1); t.deepEqual(anchor, - { x: 2, y: 4, angle: 0.9670469933974603, segment: 1 }); + {x: 2, y: 4, angle: 0.9670469933974603, segment: 1}); t.end(); }); @@ -111,7 +111,7 @@ test('getAnchors', (t) => { const line = [new Point(-10, -10), new Point(5, 5)]; const anchor = getCenterAnchor(line, 2, Math.PI, shapedText, shapedIcon, glyphSize, 1); t.deepEqual(anchor, - { x: -2, y: -2, angle: 0.7853981633974483, segment: 0 }); + {x: -2, y: -2, angle: 0.7853981633974483, segment: 0}); t.end(); }); diff --git a/test/unit/symbol/grid_index.test.js b/test/unit/symbol/grid_index.test.js index c4ef0c75905..7c6073b14e9 100644 --- a/test/unit/symbol/grid_index.test.js +++ b/test/unit/symbol/grid_index.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import GridIndex from '../../../src/symbol/grid_index'; test('GridIndex', (t) => { diff --git a/test/unit/symbol/mergelines.test.js b/test/unit/symbol/mergelines.test.js index c9c8bf12455..dfdb420df09 100644 --- a/test/unit/symbol/mergelines.test.js +++ b/test/unit/symbol/mergelines.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import mergeLines from '../../../src/symbol/mergelines'; import Point from '@mapbox/point-geometry'; diff --git a/test/unit/symbol/quads.test.js b/test/unit/symbol/quads.test.js index fd5d7846992..380e5f12df0 100644 --- a/test/unit/symbol/quads.test.js +++ b/test/unit/symbol/quads.test.js @@ -1,5 +1,5 @@ -import { test } from '../../util/test'; -import { getIconQuads } from '../../../src/symbol/quads'; +import {test} from '../../util/test'; +import {getIconQuads} from '../../../src/symbol/quads'; import Anchor from '../../../src/symbol/anchor'; import SymbolStyleLayer from '../../../src/style/style_layer/symbol_style_layer'; @@ -17,7 +17,7 @@ function createShapedIcon() { right: 8, image: { pixelRatio: 1, - paddedRect: { x: 0, y: 0, w: 17, h: 13} + paddedRect: {x: 0, y: 0, w: 17, h: 13} } }; } @@ -31,11 +31,11 @@ test('getIconQuads', (t) => { }); t.deepEqual(getIconQuads(anchor, createShapedIcon(), layer, false), [ { - tl: { x: -8, y: -6 }, - tr: { x: 9, y: -6 }, - bl: { x: -8, y: 7 }, - br: { x: 9, y: 7 }, - tex: { x: 0, y: 0, w: 17, h: 13 }, + tl: {x: -8, y: -6}, + tr: {x: 9, y: -6}, + bl: {x: -8, y: 7}, + br: {x: 9, y: 7}, + tex: {x: 0, y: 0, w: 17, h: 13}, writingMode: null, glyphOffset: [0, 0], sectionIndex: 0 @@ -50,11 +50,11 @@ test('getIconQuads', (t) => { }); t.deepEqual(getIconQuads(anchor, createShapedIcon(), layer, false), [ { - tl: { x: -8, y: -6 }, - tr: { x: 9, y: -6 }, - bl: { x: -8, y: 7 }, - br: { x: 9, y: 7 }, - tex: { x: 0, y: 0, w: 17, h: 13 }, + tl: {x: -8, y: -6}, + tr: {x: 9, y: -6}, + bl: {x: -8, y: 7}, + br: {x: 9, y: 7}, + tex: {x: 0, y: 0, w: 17, h: 13}, writingMode: null, glyphOffset: [0, 0], sectionIndex: 0 @@ -74,7 +74,7 @@ test('getIconQuads text-fit', (t) => { right: 10, image: { pixelRatio: 1, - paddedRect: { x: 0, y: 0, w: 22, h: 22 } + paddedRect: {x: 0, y: 0, w: 22, h: 22} } }; } @@ -94,10 +94,10 @@ test('getIconQuads text-fit', (t) => { 'icon-text-fit': 'none' } }), false, createshapedText()); - t.deepEqual(quads[0].tl, { x: -11, y: -11 }); - t.deepEqual(quads[0].tr, { x: 11, y: -11 }); - t.deepEqual(quads[0].bl, { x: -11, y: 11 }); - t.deepEqual(quads[0].br, { x: 11, y: 11 }); + t.deepEqual(quads[0].tl, {x: -11, y: -11}); + t.deepEqual(quads[0].tr, {x: 11, y: -11}); + t.deepEqual(quads[0].bl, {x: -11, y: 11}); + t.deepEqual(quads[0].br, {x: 11, y: 11}); t.deepEqual(quads, getIconQuads(anchor, createShapedIcon(), createLayer({ layout: { @@ -119,10 +119,10 @@ test('getIconQuads text-fit', (t) => { 'icon-text-fit-padding': [ 0, 0, 0, 0 ] } }), false, createshapedText()); - t.deepEqual(quads[0].tl, { x: -60, y: -1 }); - t.deepEqual(quads[0].tr, { x: 20, y: -1 }); - t.deepEqual(quads[0].bl, { x: -60, y: 21 }); - t.deepEqual(quads[0].br, { x: 20, y: 21 }); + t.deepEqual(quads[0].tl, {x: -60, y: -1}); + t.deepEqual(quads[0].tr, {x: 20, y: -1}); + t.deepEqual(quads[0].bl, {x: -60, y: 21}); + t.deepEqual(quads[0].br, {x: 20, y: 21}); t.end(); }); @@ -136,10 +136,10 @@ test('getIconQuads text-fit', (t) => { 'icon-text-fit-padding': [ 0, 0, 0, 0 ] } }), false, createshapedText()); - t.deepEqual(quads[0].tl, { x: -30, y: -6 }); - t.deepEqual(quads[0].tr, { x: 10, y: -6 }); - t.deepEqual(quads[0].bl, { x: -30, y: 16 }); - t.deepEqual(quads[0].br, { x: 10, y: 16 }); + t.deepEqual(quads[0].tl, {x: -30, y: -6}); + t.deepEqual(quads[0].tr, {x: 10, y: -6}); + t.deepEqual(quads[0].bl, {x: -30, y: 16}); + t.deepEqual(quads[0].br, {x: 10, y: 16}); t.end(); }); @@ -154,10 +154,10 @@ test('getIconQuads text-fit', (t) => { 'icon-text-fit-padding': [ 5, 10, 5, 10 ] } }), false, createshapedText()); - t.deepEqual(quads[0].tl, { x: -40, y: -11 }); - t.deepEqual(quads[0].tr, { x: 20, y: -11 }); - t.deepEqual(quads[0].bl, { x: -40, y: 21 }); - t.deepEqual(quads[0].br, { x: 20, y: 21 }); + t.deepEqual(quads[0].tl, {x: -40, y: -11}); + t.deepEqual(quads[0].tr, {x: 20, y: -11}); + t.deepEqual(quads[0].bl, {x: -40, y: 21}); + t.deepEqual(quads[0].br, {x: 20, y: 21}); t.end(); }); @@ -171,10 +171,10 @@ test('getIconQuads text-fit', (t) => { 'icon-text-fit-padding': [ 0, 0, 0, 0 ] } }), false, createshapedText()); - t.deepEqual(quads[0].tl, { x: -31, y: -10 }); - t.deepEqual(quads[0].tr, { x: -9, y: -10 }); - t.deepEqual(quads[0].bl, { x: -31, y: 30 }); - t.deepEqual(quads[0].br, { x: -9, y: 30 }); + t.deepEqual(quads[0].tl, {x: -31, y: -10}); + t.deepEqual(quads[0].tr, {x: -9, y: -10}); + t.deepEqual(quads[0].bl, {x: -31, y: 30}); + t.deepEqual(quads[0].br, {x: -9, y: 30}); t.end(); }); @@ -188,10 +188,10 @@ test('getIconQuads text-fit', (t) => { 'icon-text-fit-padding': [ 0, 0, 0, 0 ] } }), false, createshapedText()); - t.deepEqual(quads[0].tl, { x: -21, y: -5 }); - t.deepEqual(quads[0].tr, { x: 1, y: -5 }); - t.deepEqual(quads[0].bl, { x: -21, y: 15 }); - t.deepEqual(quads[0].br, { x: 1, y: 15 }); + t.deepEqual(quads[0].tl, {x: -21, y: -5}); + t.deepEqual(quads[0].tr, {x: 1, y: -5}); + t.deepEqual(quads[0].bl, {x: -21, y: 15}); + t.deepEqual(quads[0].br, {x: 1, y: 15}); t.end(); }); @@ -206,10 +206,10 @@ test('getIconQuads text-fit', (t) => { 'icon-text-fit-padding': [ 5, 10, 5, 10 ] } }), false, createshapedText()); - t.deepEqual(quads[0].tl, { x: -31, y: -10 }); - t.deepEqual(quads[0].tr, { x: 11, y: -10 }); - t.deepEqual(quads[0].bl, { x: -31, y: 20 }); - t.deepEqual(quads[0].br, { x: 11, y: 20 }); + t.deepEqual(quads[0].tl, {x: -31, y: -10}); + t.deepEqual(quads[0].tr, {x: 11, y: -10}); + t.deepEqual(quads[0].bl, {x: -31, y: 20}); + t.deepEqual(quads[0].br, {x: 11, y: 20}); t.end(); }); @@ -222,10 +222,10 @@ test('getIconQuads text-fit', (t) => { 'icon-text-fit-padding': [ 0, 0, 0, 0 ] } }), false, createshapedText()); - t.deepEqual(quads[0].tl, { x: -60, y: -10 }); - t.deepEqual(quads[0].tr, { x: 20, y: -10 }); - t.deepEqual(quads[0].bl, { x: -60, y: 30 }); - t.deepEqual(quads[0].br, { x: 20, y: 30 }); + t.deepEqual(quads[0].tl, {x: -60, y: -10}); + t.deepEqual(quads[0].tr, {x: 20, y: -10}); + t.deepEqual(quads[0].bl, {x: -60, y: 30}); + t.deepEqual(quads[0].br, {x: 20, y: 30}); t.end(); }); @@ -238,10 +238,10 @@ test('getIconQuads text-fit', (t) => { 'icon-text-fit-padding': [ 0, 0, 0, 0 ] } }), false, createshapedText()); - t.deepEqual(quads[0].tl, { x: -30, y: -5 }); - t.deepEqual(quads[0].tr, { x: 10, y: -5 }); - t.deepEqual(quads[0].bl, { x: -30, y: 15 }); - t.deepEqual(quads[0].br, { x: 10, y: 15 }); + t.deepEqual(quads[0].tl, {x: -30, y: -5}); + t.deepEqual(quads[0].tr, {x: 10, y: -5}); + t.deepEqual(quads[0].bl, {x: -30, y: 15}); + t.deepEqual(quads[0].br, {x: 10, y: 15}); t.end(); }); @@ -255,10 +255,10 @@ test('getIconQuads text-fit', (t) => { 'icon-text-fit-padding': [ 5, 10, 5, 10 ] } }), false, createshapedText()); - t.deepEqual(quads[0].tl, { x: -40, y: -10 }); - t.deepEqual(quads[0].tr, { x: 20, y: -10 }); - t.deepEqual(quads[0].bl, { x: -40, y: 20 }); - t.deepEqual(quads[0].br, { x: 20, y: 20 }); + t.deepEqual(quads[0].tl, {x: -40, y: -10}); + t.deepEqual(quads[0].tr, {x: 20, y: -10}); + t.deepEqual(quads[0].bl, {x: -40, y: 20}); + t.deepEqual(quads[0].br, {x: 20, y: 20}); t.end(); }); @@ -272,10 +272,10 @@ test('getIconQuads text-fit', (t) => { 'icon-text-fit-padding': [ 0, 5, 10, 15 ] } }), false, createshapedText()); - t.deepEqual(quads[0].tl, { x: -45, y: -5 }); - t.deepEqual(quads[0].tr, { x: 15, y: -5 }); - t.deepEqual(quads[0].bl, { x: -45, y: 25 }); - t.deepEqual(quads[0].br, { x: 15, y: 25 }); + t.deepEqual(quads[0].tl, {x: -45, y: -5}); + t.deepEqual(quads[0].tr, {x: 15, y: -5}); + t.deepEqual(quads[0].bl, {x: -45, y: 25}); + t.deepEqual(quads[0].br, {x: 15, y: 25}); t.end(); }); diff --git a/test/unit/symbol/shaping.test.js b/test/unit/symbol/shaping.test.js index ad2ae98407b..a3a9eeed4a4 100644 --- a/test/unit/symbol/shaping.test.js +++ b/test/unit/symbol/shaping.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import fs from 'fs'; import path from 'path'; import * as shaping from '../../../src/symbol/shaping'; diff --git a/test/unit/symbol/symbol_style_layer.test.js b/test/unit/symbol/symbol_style_layer.test.js index 4696d41a397..eeefcba2562 100644 --- a/test/unit/symbol/symbol_style_layer.test.js +++ b/test/unit/symbol/symbol_style_layer.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import SymbolStyleLayer from '../../../src/style/style_layer/symbol_style_layer'; import FormatSectionOverride from '../../../src/style-spec/expression/definitions/format_section_override'; import properties from '../../../src/style/style_layer/symbol_style_layer_properties'; @@ -27,7 +27,7 @@ test('setPaintOverrides', (t) => { }); t.test('setPaintOverrides, format expression, overriden text-color', (t) => { - const props = { layout: {'text-field': ["format", "text", {"text-color": "yellow"}]} }; + const props = {layout: {'text-field': ["format", "text", {"text-color": "yellow"}]}}; const layer = createSymbolLayer(props); layer._setPaintOverrides(); t.equal(isOverriden(layer.paint.get('text-color')), true); @@ -35,7 +35,7 @@ test('setPaintOverrides', (t) => { }); t.test('setPaintOverrides, format expression, no overrides', (t) => { - const props = { layout: {'text-field': ["format", "text", {}]} }; + const props = {layout: {'text-field': ["format", "text", {}]}}; const layer = createSymbolLayer(props); layer._setPaintOverrides(); t.equal(isOverriden(layer.paint.get('text-color')), false); @@ -53,28 +53,28 @@ test('hasPaintOverrides', (t) => { }); t.test('constant, Formatted type, overriden text-color', (t) => { - const props = { layout: {'text-field': ["format", "text", {"text-color": "red"}]} }; + const props = {layout: {'text-field': ["format", "text", {"text-color": "red"}]}}; const layer = createSymbolLayer(props); t.equal(SymbolStyleLayer.hasPaintOverrides(layer.layout), true); t.end(); }); t.test('constant, Formatted type, no overrides', (t) => { - const props = { layout: {'text-field': ["format", "text", {"font-scale": 0.8}]} }; + const props = {layout: {'text-field': ["format", "text", {"font-scale": 0.8}]}}; const layer = createSymbolLayer(props); t.equal(SymbolStyleLayer.hasPaintOverrides(layer.layout), false); t.end(); }); t.test('format expression, overriden text-color', (t) => { - const props = { layout: {'text-field': ["format", ["get", "name"], {"text-color":"red"}]} }; + const props = {layout: {'text-field': ["format", ["get", "name"], {"text-color":"red"}]}}; const layer = createSymbolLayer(props); t.equal(SymbolStyleLayer.hasPaintOverrides(layer.layout), true); t.end(); }); t.test('format expression, no overrides', (t) => { - const props = { layout: {'text-field': ["format", ["get", "name"], {}]} }; + const props = {layout: {'text-field': ["format", ["get", "name"], {}]}}; const layer = createSymbolLayer(props); t.equal(SymbolStyleLayer.hasPaintOverrides(layer.layout), false); t.end(); @@ -84,7 +84,7 @@ test('hasPaintOverrides', (t) => { const matchExpr = ["match", ["get", "case"], "one", ["format", "color", {"text-color": "blue"}], "default"]; - const props = { layout: {'text-field': matchExpr} }; + const props = {layout: {'text-field': matchExpr}}; const layer = createSymbolLayer(props); t.equal(SymbolStyleLayer.hasPaintOverrides(layer.layout), true); t.end(); @@ -94,7 +94,7 @@ test('hasPaintOverrides', (t) => { const matchExpr = ["match", ["get", "case"], "one", ["format", "b&w", {}], "default"]; - const props = { layout: {'text-field': matchExpr} }; + const props = {layout: {'text-field': matchExpr}}; const layer = createSymbolLayer(props); t.equal(SymbolStyleLayer.hasPaintOverrides(layer.layout), false); t.end(); diff --git a/test/unit/ui/camera.test.js b/test/unit/ui/camera.test.js index 3fd18fe85f2..49f7af4be7e 100644 --- a/test/unit/ui/camera.test.js +++ b/test/unit/ui/camera.test.js @@ -1,10 +1,10 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import Camera from '../../../src/ui/camera'; import Transform from '../../../src/geo/transform'; import TaskQueue from '../../../src/util/task_queue'; import browser from '../../../src/util/browser'; import {fixedLngLat, fixedNum} from '../../util/fixed'; -import { equalWithPrecision } from '../../util'; +import {equalWithPrecision} from '../../util'; test('camera', (t) => { function attachSimulateFrame(camera) { @@ -47,7 +47,7 @@ test('camera', (t) => { t.test('sets center', (t) => { camera.jumpTo({center: [1, 2]}); - t.deepEqual(camera.getCenter(), { lng: 1, lat: 2 }); + t.deepEqual(camera.getCenter(), {lng: 1, lat: 2}); t.end(); }); @@ -60,7 +60,7 @@ test('camera', (t) => { t.test('keeps current center if not specified', (t) => { camera.jumpTo({}); - t.deepEqual(camera.getCenter(), { lng: 1, lat: 2 }); + t.deepEqual(camera.getCenter(), {lng: 1, lat: 2}); t.end(); }); @@ -107,7 +107,7 @@ test('camera', (t) => { bearing: 180, pitch: 60 }); - t.deepEqual(camera.getCenter(), { lng: 10, lat: 20 }); + t.deepEqual(camera.getCenter(), {lng: 10, lat: 20}); t.deepEqual(camera.getZoom(), 10); t.deepEqual(camera.getBearing(), 180); t.deepEqual(camera.getPitch(), 60); @@ -116,7 +116,7 @@ test('camera', (t) => { t.test('emits move events, preserving eventData', (t) => { let started, moved, ended; - const eventData = { data: 'ok'}; + const eventData = {data: 'ok'}; camera .on('movestart', (d) => { started = d.data; }) @@ -132,7 +132,7 @@ test('camera', (t) => { t.test('emits zoom events, preserving eventData', (t) => { let started, zoomed, ended; - const eventData = { data: 'ok'}; + const eventData = {data: 'ok'}; camera .on('zoomstart', (d) => { started = d.data; }) @@ -148,7 +148,7 @@ test('camera', (t) => { t.test('emits rotate events, preserving eventData', (t) => { let started, rotated, ended; - const eventData = { data: 'ok'}; + const eventData = {data: 'ok'}; camera .on('rotatestart', (d) => { started = d.data; }) @@ -164,7 +164,7 @@ test('camera', (t) => { t.test('emits pitch events, preserving eventData', (t) => { let started, pitched, ended; - const eventData = { data: 'ok'}; + const eventData = {data: 'ok'}; camera .on('pitchstart', (d) => { started = d.data; }) @@ -195,7 +195,7 @@ test('camera', (t) => { t.test('sets center', (t) => { camera.setCenter([1, 2]); - t.deepEqual(camera.getCenter(), { lng: 1, lat: 2 }); + t.deepEqual(camera.getCenter(), {lng: 1, lat: 2}); t.end(); }); @@ -208,7 +208,7 @@ test('camera', (t) => { t.test('emits move events, preserving eventData', (t) => { let started, moved, ended; - const eventData = { data: 'ok'}; + const eventData = {data: 'ok'}; camera.on('movestart', (d) => { started = d.data; }) .on('move', (d) => { moved = d.data; }) @@ -243,7 +243,7 @@ test('camera', (t) => { t.test('emits move and zoom events, preserving eventData', (t) => { let movestarted, moved, moveended, zoomstarted, zoomed, zoomended; - const eventData = { data: 'ok' }; + const eventData = {data: 'ok'}; camera .on('movestart', (d) => { movestarted = d.data; }) @@ -285,7 +285,7 @@ test('camera', (t) => { t.test('emits move and rotate events, preserving eventData', (t) => { let movestarted, moved, moveended, rotatestarted, rotated, rotateended; - const eventData = { data: 'ok' }; + const eventData = {data: 'ok'}; camera .on('movestart', (d) => { movestarted = d.data; }) @@ -319,22 +319,22 @@ test('camera', (t) => { t.test('#panBy', (t) => { t.test('pans by specified amount', (t) => { const camera = createCamera(); - camera.panBy([100, 0], { duration: 0 }); - t.deepEqual(fixedLngLat(camera.getCenter()), { lng: 70.3125, lat: 0 }); + camera.panBy([100, 0], {duration: 0}); + t.deepEqual(fixedLngLat(camera.getCenter()), {lng: 70.3125, lat: 0}); t.end(); }); t.test('pans relative to viewport on a rotated camera', (t) => { const camera = createCamera({bearing: 180}); - camera.panBy([100, 0], { duration: 0 }); - t.deepEqual(fixedLngLat(camera.getCenter()), { lng: -70.3125, lat: 0 }); + camera.panBy([100, 0], {duration: 0}); + t.deepEqual(fixedLngLat(camera.getCenter()), {lng: -70.3125, lat: 0}); t.end(); }); t.test('emits move events, preserving eventData', (t) => { const camera = createCamera(); let started, moved; - const eventData = { data: 'ok' }; + const eventData = {data: 'ok'}; camera .on('movestart', (d) => { started = d.data; }) @@ -346,7 +346,7 @@ test('camera', (t) => { t.end(); }); - camera.panBy([100, 0], { duration: 0 }, eventData); + camera.panBy([100, 0], {duration: 0}, eventData); }); t.test('supresses movestart if noMoveStart option is true', (t) => { @@ -360,7 +360,7 @@ test('camera', (t) => { t.end(); }); - camera.panBy([100, 0], { duration: 0, noMoveStart: true }); + camera.panBy([100, 0], {duration: 0, noMoveStart: true}); }); t.end(); @@ -369,8 +369,8 @@ test('camera', (t) => { t.test('#panTo', (t) => { t.test('pans to specified location', (t) => { const camera = createCamera(); - camera.panTo([100, 0], { duration: 0 }); - t.deepEqual(camera.getCenter(), { lng: 100, lat: 0 }); + camera.panTo([100, 0], {duration: 0}); + t.deepEqual(camera.getCenter(), {lng: 100, lat: 0}); t.end(); }); @@ -384,22 +384,22 @@ test('camera', (t) => { t.test('pans with specified offset', (t) => { const camera = createCamera(); - camera.panTo([100, 0], { offset: [100, 0], duration: 0 }); - t.deepEqual(fixedLngLat(camera.getCenter()), { lng: 29.6875, lat: 0 }); + camera.panTo([100, 0], {offset: [100, 0], duration: 0}); + t.deepEqual(fixedLngLat(camera.getCenter()), {lng: 29.6875, lat: 0}); t.end(); }); t.test('pans with specified offset relative to viewport on a rotated camera', (t) => { const camera = createCamera({bearing: 180}); - camera.panTo([100, 0], { offset: [100, 0], duration: 0 }); - t.deepEqual(fixedLngLat(camera.getCenter()), { lng: 170.3125, lat: 0 }); + camera.panTo([100, 0], {offset: [100, 0], duration: 0}); + t.deepEqual(fixedLngLat(camera.getCenter()), {lng: 170.3125, lat: 0}); t.end(); }); t.test('emits move events, preserving eventData', (t) => { const camera = createCamera(); let started, moved; - const eventData = { data: 'ok' }; + const eventData = {data: 'ok'}; camera .on('movestart', (d) => { started = d.data; }) @@ -411,7 +411,7 @@ test('camera', (t) => { t.end(); }); - camera.panTo([100, 0], { duration: 0 }, eventData); + camera.panTo([100, 0], {duration: 0}, eventData); }); t.test('supresses movestart if noMoveStart option is true', (t) => { @@ -425,7 +425,7 @@ test('camera', (t) => { t.end(); }); - camera.panTo([100, 0], { duration: 0, noMoveStart: true }); + camera.panTo([100, 0], {duration: 0, noMoveStart: true}); }); t.end(); @@ -434,39 +434,39 @@ test('camera', (t) => { t.test('#zoomTo', (t) => { t.test('zooms to specified level', (t) => { const camera = createCamera(); - camera.zoomTo(3.2, { duration: 0 }); + camera.zoomTo(3.2, {duration: 0}); t.equal(camera.getZoom(), 3.2); t.end(); }); t.test('zooms around specified location', (t) => { const camera = createCamera(); - camera.zoomTo(3.2, { around: [5, 0], duration: 0 }); + camera.zoomTo(3.2, {around: [5, 0], duration: 0}); t.equal(camera.getZoom(), 3.2); - t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({ lng: 4.455905897939886, lat: 0 })); + t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({lng: 4.455905897939886, lat: 0})); t.end(); }); t.test('zooms with specified offset', (t) => { const camera = createCamera(); - camera.zoomTo(3.2, { offset: [100, 0], duration: 0 }); + camera.zoomTo(3.2, {offset: [100, 0], duration: 0}); t.equal(camera.getZoom(), 3.2); - t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({ lng: 62.66117668978015, lat: 0 })); + t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({lng: 62.66117668978015, lat: 0})); t.end(); }); t.test('zooms with specified offset relative to viewport on a rotated camera', (t) => { const camera = createCamera({bearing: 180}); - camera.zoomTo(3.2, { offset: [100, 0], duration: 0 }); + camera.zoomTo(3.2, {offset: [100, 0], duration: 0}); t.equal(camera.getZoom(), 3.2); - t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({ lng: -62.66117668978012, lat: 0 })); + t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({lng: -62.66117668978012, lat: 0})); t.end(); }); t.test('emits move and zoom events, preserving eventData', (t) => { const camera = createCamera(); let movestarted, moved, zoomstarted, zoomed; - const eventData = { data: 'ok' }; + const eventData = {data: 'ok'}; t.plan(6); @@ -488,7 +488,7 @@ test('camera', (t) => { t.equal(d.data, 'ok'); }); - camera.zoomTo(5, { duration: 0 }, eventData); + camera.zoomTo(5, {duration: 0}, eventData); }); t.end(); @@ -497,55 +497,55 @@ test('camera', (t) => { t.test('#rotateTo', (t) => { t.test('rotates to specified bearing', (t) => { const camera = createCamera(); - camera.rotateTo(90, { duration: 0 }); + camera.rotateTo(90, {duration: 0}); t.equal(camera.getBearing(), 90); t.end(); }); t.test('rotates around specified location', (t) => { - const camera = createCamera({ zoom: 3 }); - camera.rotateTo(90, { around: [5, 0], duration: 0 }); + const camera = createCamera({zoom: 3}); + camera.rotateTo(90, {around: [5, 0], duration: 0}); t.equal(camera.getBearing(), 90); - t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({ lng: 4.999999999999972, lat: 4.993665859353271 })); + t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({lng: 4.999999999999972, lat: 4.993665859353271})); t.end(); }); t.test('rotates around specified location, constrained to fit the view', (t) => { - const camera = createCamera({ zoom: 0 }); - camera.rotateTo(90, { around: [5, 0], duration: 0 }); + const camera = createCamera({zoom: 0}); + camera.rotateTo(90, {around: [5, 0], duration: 0}); t.equal(camera.getBearing(), 90); - t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({ lng: 4.999999999999972, lat: 0.000002552471840999715 })); + t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({lng: 4.999999999999972, lat: 0.000002552471840999715})); t.end(); }); t.test('rotates with specified offset', (t) => { - const camera = createCamera({ zoom: 1 }); - camera.rotateTo(90, { offset: [200, 0], duration: 0 }); + const camera = createCamera({zoom: 1}); + camera.rotateTo(90, {offset: [200, 0], duration: 0}); t.equal(camera.getBearing(), 90); - t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({ lng: 70.3125, lat: 57.3265212252 })); + t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({lng: 70.3125, lat: 57.3265212252})); t.end(); }); t.test('rotates with specified offset, constrained to fit the view', (t) => { - const camera = createCamera({ zoom: 0 }); - camera.rotateTo(90, { offset: [100, 0], duration: 0 }); + const camera = createCamera({zoom: 0}); + camera.rotateTo(90, {offset: [100, 0], duration: 0}); t.equal(camera.getBearing(), 90); - t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({ lng: 70.3125, lat: 0.000002552471840999715 })); + t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({lng: 70.3125, lat: 0.000002552471840999715})); t.end(); }); t.test('rotates with specified offset relative to viewport on a rotated camera', (t) => { - const camera = createCamera({ bearing: 180, zoom: 1 }); - camera.rotateTo(90, { offset: [200, 0], duration: 0 }); + const camera = createCamera({bearing: 180, zoom: 1}); + camera.rotateTo(90, {offset: [200, 0], duration: 0}); t.equal(camera.getBearing(), 90); - t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({ lng: -70.3125, lat: 57.3265212252 })); + t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({lng: -70.3125, lat: 57.3265212252})); t.end(); }); t.test('emits move and rotate events, preserving eventData', (t) => { const camera = createCamera(); let movestarted, moved, rotatestarted, rotated; - const eventData = { data: 'ok' }; + const eventData = {data: 'ok'}; t.plan(6); @@ -567,7 +567,7 @@ test('camera', (t) => { t.equal(d.data, 'ok'); }); - camera.rotateTo(90, { duration: 0 }, eventData); + camera.rotateTo(90, {duration: 0}, eventData); }); t.end(); @@ -576,59 +576,59 @@ test('camera', (t) => { t.test('#easeTo', (t) => { t.test('pans to specified location', (t) => { const camera = createCamera(); - camera.easeTo({ center: [100, 0], duration: 0 }); - t.deepEqual(camera.getCenter(), { lng: 100, lat: 0 }); + camera.easeTo({center: [100, 0], duration: 0}); + t.deepEqual(camera.getCenter(), {lng: 100, lat: 0}); t.end(); }); t.test('zooms to specified level', (t) => { const camera = createCamera(); - camera.easeTo({ zoom: 3.2, duration: 0 }); + camera.easeTo({zoom: 3.2, duration: 0}); t.equal(camera.getZoom(), 3.2); t.end(); }); t.test('rotates to specified bearing', (t) => { const camera = createCamera(); - camera.easeTo({ bearing: 90, duration: 0 }); + camera.easeTo({bearing: 90, duration: 0}); t.equal(camera.getBearing(), 90); t.end(); }); t.test('pitches to specified pitch', (t) => { const camera = createCamera(); - camera.easeTo({ pitch: 45, duration: 0 }); + camera.easeTo({pitch: 45, duration: 0}); t.equal(camera.getPitch(), 45); t.end(); }); t.test('pans and zooms', (t) => { const camera = createCamera(); - camera.easeTo({ center: [100, 0], zoom: 3.2, duration: 0 }); - t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({ lng: 100, lat: 0 })); + camera.easeTo({center: [100, 0], zoom: 3.2, duration: 0}); + t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({lng: 100, lat: 0})); t.equal(camera.getZoom(), 3.2); t.end(); }); t.test('zooms around a point', (t) => { const camera = createCamera(); - camera.easeTo({ around: [100, 0], zoom: 3, duration: 0 }); - t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({ lng: 87.5, lat: 0 })); + camera.easeTo({around: [100, 0], zoom: 3, duration: 0}); + t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({lng: 87.5, lat: 0})); t.equal(camera.getZoom(), 3); t.end(); }); t.test('pans and rotates', (t) => { const camera = createCamera(); - camera.easeTo({ center: [100, 0], bearing: 90, duration: 0 }); - t.deepEqual(camera.getCenter(), { lng: 100, lat: 0 }); + camera.easeTo({center: [100, 0], bearing: 90, duration: 0}); + t.deepEqual(camera.getCenter(), {lng: 100, lat: 0}); t.equal(camera.getBearing(), 90); t.end(); }); t.test('zooms and rotates', (t) => { const camera = createCamera(); - camera.easeTo({ zoom: 3.2, bearing: 90, duration: 0 }); + camera.easeTo({zoom: 3.2, bearing: 90, duration: 0}); t.equal(camera.getZoom(), 3.2); t.equal(camera.getBearing(), 90); t.end(); @@ -636,8 +636,8 @@ test('camera', (t) => { t.test('pans, zooms, and rotates', (t) => { const camera = createCamera({bearing: -90}); - camera.easeTo({ center: [100, 0], zoom: 3.2, bearing: 90, duration: 0 }); - t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({ lng: 100, lat: 0 })); + camera.easeTo({center: [100, 0], zoom: 3.2, bearing: 90, duration: 0}); + t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({lng: 100, lat: 0})); t.equal(camera.getZoom(), 3.2); t.equal(camera.getBearing(), 90); t.end(); @@ -645,8 +645,8 @@ test('camera', (t) => { t.test('noop', (t) => { const camera = createCamera(); - camera.easeTo({ duration: 0 }); - t.deepEqual(fixedLngLat(camera.getCenter()), { lng: 0, lat: 0 }); + camera.easeTo({duration: 0}); + t.deepEqual(fixedLngLat(camera.getCenter()), {lng: 0, lat: 0}); t.equal(camera.getZoom(), 0); t.equal(camera.getBearing(), 0); t.end(); @@ -654,8 +654,8 @@ test('camera', (t) => { t.test('noop with offset', (t) => { const camera = createCamera(); - camera.easeTo({ offset: [100, 0], duration: 0 }); - t.deepEqual(fixedLngLat(camera.getCenter()), { lng: 0, lat: 0 }); + camera.easeTo({offset: [100, 0], duration: 0}); + t.deepEqual(fixedLngLat(camera.getCenter()), {lng: 0, lat: 0}); t.equal(camera.getZoom(), 0); t.equal(camera.getBearing(), 0); t.end(); @@ -663,54 +663,54 @@ test('camera', (t) => { t.test('pans with specified offset', (t) => { const camera = createCamera(); - camera.easeTo({ center: [100, 0], offset: [100, 0], duration: 0 }); - t.deepEqual(fixedLngLat(camera.getCenter()), { lng: 29.6875, lat: 0 }); + camera.easeTo({center: [100, 0], offset: [100, 0], duration: 0}); + t.deepEqual(fixedLngLat(camera.getCenter()), {lng: 29.6875, lat: 0}); t.end(); }); t.test('pans with specified offset relative to viewport on a rotated camera', (t) => { - const camera = createCamera({ bearing: 180 }); - camera.easeTo({ center: [100, 0], offset: [100, 0], duration: 0 }); - t.deepEqual(fixedLngLat(camera.getCenter()), { lng: 170.3125, lat: 0 }); + const camera = createCamera({bearing: 180}); + camera.easeTo({center: [100, 0], offset: [100, 0], duration: 0}); + t.deepEqual(fixedLngLat(camera.getCenter()), {lng: 170.3125, lat: 0}); t.end(); }); t.test('zooms with specified offset', (t) => { const camera = createCamera(); - camera.easeTo({ zoom: 3.2, offset: [100, 0], duration: 0 }); + camera.easeTo({zoom: 3.2, offset: [100, 0], duration: 0}); t.equal(camera.getZoom(), 3.2); - t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({ lng: 62.66117668978015, lat: 0 })); + t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({lng: 62.66117668978015, lat: 0})); t.end(); }); t.test('zooms with specified offset relative to viewport on a rotated camera', (t) => { const camera = createCamera({bearing: 180}); - camera.easeTo({ zoom: 3.2, offset: [100, 0], duration: 0 }); + camera.easeTo({zoom: 3.2, offset: [100, 0], duration: 0}); t.equal(camera.getZoom(), 3.2); - t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({ lng: -62.66117668978012, lat: 0 })); + t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({lng: -62.66117668978012, lat: 0})); t.end(); }); t.test('rotates with specified offset', (t) => { const camera = createCamera(); - camera.easeTo({ bearing: 90, offset: [100, 0], duration: 0 }); + camera.easeTo({bearing: 90, offset: [100, 0], duration: 0}); t.equal(camera.getBearing(), 90); - t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({ lng: 70.3125, lat: 0.000002552471840999715 })); + t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({lng: 70.3125, lat: 0.000002552471840999715})); t.end(); }); t.test('rotates with specified offset relative to viewport on a rotated camera', (t) => { const camera = createCamera({bearing: 180}); - camera.easeTo({ bearing: 90, offset: [100, 0], duration: 0 }); + camera.easeTo({bearing: 90, offset: [100, 0], duration: 0}); t.equal(camera.getBearing(), 90); - t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({ lng: -70.3125, lat: 0.000002552471840999715 })); + t.deepEqual(fixedLngLat(camera.getCenter()), fixedLngLat({lng: -70.3125, lat: 0.000002552471840999715})); t.end(); }); t.test('emits move, zoom, rotate, and pitch events, preserving eventData', (t) => { const camera = createCamera(); let movestarted, moved, zoomstarted, zoomed, rotatestarted, rotated, pitchstarted, pitched; - const eventData = { data: 'ok' }; + const eventData = {data: 'ok'}; t.plan(18); @@ -758,7 +758,7 @@ test('camera', (t) => { }); camera.easeTo( - { center: [100, 0], zoom: 3.2, bearing: 90, duration: 0, pitch: 45 }, + {center: [100, 0], zoom: 3.2, bearing: 90, duration: 0, pitch: 45}, eventData); }); @@ -776,9 +776,9 @@ test('camera', (t) => { t.test('stops existing ease', (t) => { const camera = createCamera(); - camera.easeTo({ center: [200, 0], duration: 100 }); - camera.easeTo({ center: [100, 0], duration: 0 }); - t.deepEqual(camera.getCenter(), { lng: 100, lat: 0 }); + camera.easeTo({center: [200, 0], duration: 100}); + camera.easeTo({center: [100, 0], duration: 0}); + t.deepEqual(camera.getCenter(), {lng: 100, lat: 0}); t.end(); }); @@ -787,12 +787,12 @@ test('camera', (t) => { const stub = t.stub(browser, 'now'); stub.callsFake(() => 0); - camera.easeTo({ center: [100, 0], duration: 10 }); + camera.easeTo({center: [100, 0], duration: 10}); camera.once('moveend', () => { - camera.easeTo({ center: [200, 0], duration: 10 }); + camera.easeTo({center: [200, 0], duration: 10}); camera.once('moveend', () => { - camera.easeTo({ center: [300, 0], duration: 10 }); + camera.easeTo({center: [300, 0], duration: 10}); camera.once('moveend', () => { t.end(); }); @@ -836,7 +836,7 @@ test('camera', (t) => { }); stub.callsFake(() => 0); - camera.easeTo({ center: [-170, 0], duration: 10 }); + camera.easeTo({center: [-170, 0], duration: 10}); setTimeout(() => { stub.callsFake(() => 1); @@ -868,7 +868,7 @@ test('camera', (t) => { }); stub.callsFake(() => 0); - camera.easeTo({ center: [170, 0], duration: 10 }); + camera.easeTo({center: [170, 0], duration: 10}); setTimeout(() => { stub.callsFake(() => 1); @@ -886,7 +886,7 @@ test('camera', (t) => { const stub = t.stub(browser, 'prefersReducedMotion'); stub.get(() => true); assertTransitionTime(t, camera, 0, 10); - camera.easeTo({ center: [100, 0], zoom: 3.2, bearing: 90, duration: 1000 }); + camera.easeTo({center: [100, 0], zoom: 3.2, bearing: 90, duration: 1000}); }); t.end(); @@ -895,8 +895,8 @@ test('camera', (t) => { t.test('#flyTo', (t) => { t.test('pans to specified location', (t) => { const camera = createCamera(); - camera.flyTo({ center: [100, 0], animate: false }); - t.deepEqual(fixedLngLat(camera.getCenter()), { lng: 100, lat: 0 }); + camera.flyTo({center: [100, 0], animate: false}); + t.deepEqual(fixedLngLat(camera.getCenter()), {lng: 100, lat: 0}); t.end(); }); @@ -926,20 +926,20 @@ test('camera', (t) => { t.test('zooms to specified level', (t) => { const camera = createCamera(); - camera.flyTo({ zoom: 3.2, animate: false }); + camera.flyTo({zoom: 3.2, animate: false}); t.equal(fixedNum(camera.getZoom()), 3.2); t.end(); }); t.test('zooms to integer level without floating point errors', (t) => { const camera = createCamera({zoom: 0.6}); - camera.flyTo({ zoom: 2, animate: false }); + camera.flyTo({zoom: 2, animate: false}); t.equal(camera.getZoom(), 2); t.end(); }); t.test('Zoom out from the same position to the same position with animation', (t) => { - const pos = { lng: 0, lat: 0 }; + const pos = {lng: 0, lat: 0}; const camera = createCamera({zoom: 20, center: pos}); const stub = t.stub(browser, 'now'); @@ -950,7 +950,7 @@ test('camera', (t) => { }); stub.callsFake(() => 0); - camera.flyTo({ zoom: 19, center: pos, duration: 2 }); + camera.flyTo({zoom: 19, center: pos, duration: 2}); stub.callsFake(() => 3); camera.simulateFrame(); @@ -958,37 +958,37 @@ test('camera', (t) => { t.test('rotates to specified bearing', (t) => { const camera = createCamera(); - camera.flyTo({ bearing: 90, animate: false }); + camera.flyTo({bearing: 90, animate: false}); t.equal(camera.getBearing(), 90); t.end(); }); t.test('tilts to specified pitch', (t) => { const camera = createCamera(); - camera.flyTo({ pitch: 45, animate: false }); + camera.flyTo({pitch: 45, animate: false}); t.equal(camera.getPitch(), 45); t.end(); }); t.test('pans and zooms', (t) => { const camera = createCamera(); - camera.flyTo({ center: [100, 0], zoom: 3.2, animate: false }); - t.deepEqual(fixedLngLat(camera.getCenter()), { lng: 100, lat: 0 }); + camera.flyTo({center: [100, 0], zoom: 3.2, animate: false}); + t.deepEqual(fixedLngLat(camera.getCenter()), {lng: 100, lat: 0}); t.equal(fixedNum(camera.getZoom()), 3.2); t.end(); }); t.test('pans and rotates', (t) => { const camera = createCamera(); - camera.flyTo({ center: [100, 0], bearing: 90, animate: false }); - t.deepEqual(fixedLngLat(camera.getCenter()), { lng: 100, lat: 0 }); + camera.flyTo({center: [100, 0], bearing: 90, animate: false}); + t.deepEqual(fixedLngLat(camera.getCenter()), {lng: 100, lat: 0}); t.equal(camera.getBearing(), 90); t.end(); }); t.test('zooms and rotates', (t) => { const camera = createCamera(); - camera.flyTo({ zoom: 3.2, bearing: 90, animate: false }); + camera.flyTo({zoom: 3.2, bearing: 90, animate: false}); t.equal(fixedNum(camera.getZoom()), 3.2); t.equal(camera.getBearing(), 90); t.end(); @@ -996,8 +996,8 @@ test('camera', (t) => { t.test('pans, zooms, and rotates', (t) => { const camera = createCamera(); - camera.flyTo({ center: [100, 0], zoom: 3.2, bearing: 90, duration: 0, animate: false }); - t.deepEqual(fixedLngLat(camera.getCenter()), { lng: 100, lat: 0 }); + camera.flyTo({center: [100, 0], zoom: 3.2, bearing: 90, duration: 0, animate: false}); + t.deepEqual(fixedLngLat(camera.getCenter()), {lng: 100, lat: 0}); t.equal(fixedNum(camera.getZoom()), 3.2); t.equal(camera.getBearing(), 90); t.end(); @@ -1005,8 +1005,8 @@ test('camera', (t) => { t.test('noop', (t) => { const camera = createCamera(); - camera.flyTo({ animate: false }); - t.deepEqual(fixedLngLat(camera.getCenter()), { lng: 0, lat: 0 }); + camera.flyTo({animate: false}); + t.deepEqual(fixedLngLat(camera.getCenter()), {lng: 0, lat: 0}); t.equal(camera.getZoom(), 0); t.equal(camera.getBearing(), 0); t.end(); @@ -1014,8 +1014,8 @@ test('camera', (t) => { t.test('noop with offset', (t) => { const camera = createCamera(); - camera.flyTo({ offset: [100, 0], animate: false }); - t.deepEqual(fixedLngLat(camera.getCenter()), { lng: 0, lat: 0 }); + camera.flyTo({offset: [100, 0], animate: false}); + t.deepEqual(fixedLngLat(camera.getCenter()), {lng: 0, lat: 0}); t.equal(camera.getZoom(), 0); t.equal(camera.getBearing(), 0); t.end(); @@ -1023,15 +1023,15 @@ test('camera', (t) => { t.test('pans with specified offset', (t) => { const camera = createCamera(); - camera.flyTo({ center: [100, 0], offset: [100, 0], animate: false }); - t.deepEqual(fixedLngLat(camera.getCenter()), { lng: 29.6875, lat: 0 }); + camera.flyTo({center: [100, 0], offset: [100, 0], animate: false}); + t.deepEqual(fixedLngLat(camera.getCenter()), {lng: 29.6875, lat: 0}); t.end(); }); t.test('pans with specified offset relative to viewport on a rotated camera', (t) => { - const camera = createCamera({ bearing: 180 }); - camera.easeTo({ center: [100, 0], offset: [100, 0], animate: false }); - t.deepEqual(fixedLngLat(camera.getCenter()), { lng: 170.3125, lat: 0 }); + const camera = createCamera({bearing: 180}); + camera.easeTo({center: [100, 0], offset: [100, 0], animate: false}); + t.deepEqual(fixedLngLat(camera.getCenter()), {lng: 170.3125, lat: 0}); t.end(); }); @@ -1040,7 +1040,7 @@ test('camera', (t) => { const camera = createCamera(); let movestarted, moved, zoomstarted, zoomed, rotatestarted, rotated, pitchstarted, pitched; - const eventData = { data: 'ok' }; + const eventData = {data: 'ok'}; camera .on('movestart', (d) => { movestarted = d.data; }) @@ -1088,19 +1088,19 @@ test('camera', (t) => { }); camera.flyTo( - { center: [100, 0], zoom: 3.2, bearing: 90, duration: 0, pitch: 45, animate: false }, + {center: [100, 0], zoom: 3.2, bearing: 90, duration: 0, pitch: 45, animate: false}, eventData); }); t.test('for short flights, emits (solely) move events, preserving eventData', (t) => { //As I type this, the code path for guiding super-short flights is (and will probably remain) different. //As such; it deserves a separate test case. This test case flies the map from A to A. - const camera = createCamera({ center: [100, 0] }); + const camera = createCamera({center: [100, 0]}); let movestarted, moved, zoomstarted, zoomed, zoomended, rotatestarted, rotated, rotateended, pitchstarted, pitched, pitchended; - const eventData = { data: 'ok' }; + const eventData = {data: 'ok'}; camera .on('movestart', (d) => { movestarted = d.data; }) @@ -1137,7 +1137,7 @@ test('camera', (t) => { const stub = t.stub(browser, 'now'); stub.callsFake(() => 0); - camera.flyTo({ center: [100, 0], duration: 10 }, eventData); + camera.flyTo({center: [100, 0], duration: 10}, eventData); setTimeout(() => { stub.callsFake(() => 1); @@ -1152,9 +1152,9 @@ test('camera', (t) => { t.test('stops existing ease', (t) => { const camera = createCamera(); - camera.flyTo({ center: [200, 0], duration: 100 }); - camera.flyTo({ center: [100, 0], duration: 0 }); - t.deepEqual(fixedLngLat(camera.getCenter()), { lng: 100, lat: 0 }); + camera.flyTo({center: [200, 0], duration: 100}); + camera.flyTo({center: [100, 0], duration: 0}); + t.deepEqual(fixedLngLat(camera.getCenter()), {lng: 100, lat: 0}); t.end(); }); @@ -1163,11 +1163,11 @@ test('camera', (t) => { const stub = t.stub(browser, 'now'); stub.callsFake(() => 0); - camera.flyTo({ center: [100, 0], duration: 10 }); + camera.flyTo({center: [100, 0], duration: 10}); camera.once('moveend', () => { - camera.flyTo({ center: [200, 0], duration: 10 }); + camera.flyTo({center: [200, 0], duration: 10}); camera.once('moveend', () => { - camera.flyTo({ center: [300, 0], duration: 10 }); + camera.flyTo({center: [300, 0], duration: 10}); camera.once('moveend', () => { t.end(); }); @@ -1209,7 +1209,7 @@ test('camera', (t) => { const stub = t.stub(browser, 'now'); stub.callsFake(() => 0); - camera.flyTo({ center: [100, 0], zoom: 18, duration: 10 }); + camera.flyTo({center: [100, 0], zoom: 18, duration: 10}); setTimeout(() => { stub.callsFake(() => 1); @@ -1241,7 +1241,7 @@ test('camera', (t) => { }); stub.callsFake(() => 0); - camera.flyTo({ center: [10, 0], duration: 20 }); + camera.flyTo({center: [10, 0], duration: 20}); setTimeout(() => { stub.callsFake(() => 1); @@ -1273,7 +1273,7 @@ test('camera', (t) => { }); stub.callsFake(() => 0); - camera.flyTo({ center: [-10, 0], duration: 20 }); + camera.flyTo({center: [-10, 0], duration: 20}); setTimeout(() => { stub.callsFake(() => 1); @@ -1305,7 +1305,7 @@ test('camera', (t) => { }); stub.callsFake(() => 0); - camera.flyTo({ center: [-170, 0], duration: 20 }); + camera.flyTo({center: [-170, 0], duration: 20}); setTimeout(() => { stub.callsFake(() => 1); @@ -1337,7 +1337,7 @@ test('camera', (t) => { }); stub.callsFake(() => 0); - camera.flyTo({ center: [170, 0], duration: 10 }); + camera.flyTo({center: [170, 0], duration: 10}); setTimeout(() => { stub.callsFake(() => 1); @@ -1369,7 +1369,7 @@ test('camera', (t) => { }); stub.callsFake(() => 0); - camera.flyTo({ center: [-170, 0], duration: 10 }); + camera.flyTo({center: [-170, 0], duration: 10}); setTimeout(() => { stub.callsFake(() => 1); @@ -1401,7 +1401,7 @@ test('camera', (t) => { }); stub.callsFake(() => 0); - camera.flyTo({ center: [170, 0], duration: 10 }); + camera.flyTo({center: [170, 0], duration: 10}); setTimeout(() => { stub.callsFake(() => 1); @@ -1432,7 +1432,7 @@ test('camera', (t) => { }); stub.callsFake(() => 0); - camera.flyTo({ center: [170, 0], duration: 10 }); + camera.flyTo({center: [170, 0], duration: 10}); setTimeout(() => { stub.callsFake(() => 1); @@ -1469,7 +1469,7 @@ test('camera', (t) => { }); stub.callsFake(() => 0); - camera.flyTo({ center: [1, 0], zoom: 20, minZoom, duration: 10 }); + camera.flyTo({center: [1, 0], zoom: 20, minZoom, duration: 10}); setTimeout(() => { stub.callsFake(() => 3); @@ -1491,7 +1491,7 @@ test('camera', (t) => { camera.on('moveend', () => { equalWithPrecision(t, camera.getZoom(), 10, 1e-10); - const { lng, lat } = camera.getCenter(); + const {lng, lat} = camera.getCenter(); equalWithPrecision(t, lng, 12, 1e-10); equalWithPrecision(t, lat, 34, 1e-10); @@ -1500,7 +1500,7 @@ test('camera', (t) => { const stub = t.stub(browser, 'now'); stub.callsFake(() => 0); - camera.flyTo({ center: [12, 34], zoom: 30, duration: 10 }); + camera.flyTo({center: [12, 34], zoom: 30, duration: 10}); setTimeout(() => { stub.callsFake(() => 10); @@ -1517,7 +1517,7 @@ test('camera', (t) => { camera.on('moveend', () => { equalWithPrecision(t, camera.getZoom(), 2, 1e-10); - const { lng, lat } = camera.getCenter(); + const {lng, lat} = camera.getCenter(); equalWithPrecision(t, lng, 12, 1e-10); equalWithPrecision(t, lat, 34, 1e-10); @@ -1526,7 +1526,7 @@ test('camera', (t) => { const stub = t.stub(browser, 'now'); stub.callsFake(() => 0); - camera.flyTo({ center: [12, 34], zoom: 1, duration: 10 }); + camera.flyTo({center: [12, 34], zoom: 1, duration: 10}); setTimeout(() => { stub.callsFake(() => 10); @@ -1536,7 +1536,7 @@ test('camera', (t) => { t.test('resets duration to 0 if it exceeds maxDuration', (t) => { let startTime, endTime, timeDiff; - const camera = createCamera({ center: [37.63454, 55.75868], zoom: 18}); + const camera = createCamera({center: [37.63454, 55.75868], zoom: 18}); camera .on('movestart', () => { startTime = new Date(); }) @@ -1547,7 +1547,7 @@ test('camera', (t) => { t.end(); }); - camera.flyTo({ center: [-122.3998631, 37.7884307], maxDuration: 100 }); + camera.flyTo({center: [-122.3998631, 37.7884307], maxDuration: 100}); }); t.test('flys instantly when prefers-reduce-motion:reduce is set', (t) => { @@ -1555,7 +1555,7 @@ test('camera', (t) => { const stub = t.stub(browser, 'prefersReducedMotion'); stub.get(() => true); assertTransitionTime(t, camera, 0, 10); - camera.flyTo({ center: [100, 0], bearing: 90, animate: true }); + camera.flyTo({center: [100, 0], bearing: 90, animate: true}); }); t.end(); @@ -1656,7 +1656,7 @@ test('camera', (t) => { t.test('emits moveend if panning, preserving eventData', (t) => { const camera = createCamera(); - const eventData = { data: 'ok' }; + const eventData = {data: 'ok'}; camera.on('moveend', (d) => { t.equal(d.data, 'ok'); @@ -1669,7 +1669,7 @@ test('camera', (t) => { t.test('emits moveend if zooming, preserving eventData', (t) => { const camera = createCamera(); - const eventData = { data: 'ok' }; + const eventData = {data: 'ok'}; camera.on('moveend', (d) => { t.equal(d.data, 'ok'); @@ -1682,7 +1682,7 @@ test('camera', (t) => { t.test('emits moveend if rotating, preserving eventData', (t) => { const camera = createCamera(); - const eventData = { data: 'ok' }; + const eventData = {data: 'ok'}; camera.on('moveend', (d) => { t.equal(d.data, 'ok'); @@ -1695,7 +1695,7 @@ test('camera', (t) => { t.test('does not emit moveend if not moving', (t) => { const camera = createCamera(); - const eventData = { data: 'ok' }; + const eventData = {data: 'ok'}; camera.on('moveend', (d) => { t.equal(d.data, 'ok'); @@ -1722,7 +1722,7 @@ test('camera', (t) => { const bb = [[-133, 16], [-68, 50]]; const transform = camera.cameraForBounds(bb); - t.deepEqual(fixedLngLat(transform.center, 4), { lng: -100.5, lat: 34.7171 }, 'correctly calculates coordinates for new bounds'); + t.deepEqual(fixedLngLat(transform.center, 4), {lng: -100.5, lat: 34.7171}, 'correctly calculates coordinates for new bounds'); t.equal(fixedNum(transform.zoom, 3), 2.469); t.end(); }); @@ -1731,8 +1731,8 @@ test('camera', (t) => { const camera = createCamera(); const bb = [[-133, 16], [-68, 50]]; - const transform = camera.cameraForBounds(bb, { padding: 15 }); - t.deepEqual(fixedLngLat(transform.center, 4), { lng: -100.5, lat: 34.7171 }, 'correctly calculates coordinates for bounds with padding option as number applied'); + const transform = camera.cameraForBounds(bb, {padding: 15}); + t.deepEqual(fixedLngLat(transform.center, 4), {lng: -100.5, lat: 34.7171}, 'correctly calculates coordinates for bounds with padding option as number applied'); t.equal(fixedNum(transform.zoom, 3), 2.382); t.end(); }); @@ -1741,8 +1741,8 @@ test('camera', (t) => { const camera = createCamera(); const bb = [[-133, 16], [-68, 50]]; - const transform = camera.cameraForBounds(bb, { padding: {top: 15, right: 15, bottom: 15, left: 15}, duration: 0 }); - t.deepEqual(fixedLngLat(transform.center, 4), { lng: -100.5, lat: 34.7171 }, 'correctly calculates coordinates for bounds with padding option as object applied'); + const transform = camera.cameraForBounds(bb, {padding: {top: 15, right: 15, bottom: 15, left: 15}, duration: 0}); + t.deepEqual(fixedLngLat(transform.center, 4), {lng: -100.5, lat: 34.7171}, 'correctly calculates coordinates for bounds with padding option as object applied'); t.end(); }); @@ -1750,8 +1750,8 @@ test('camera', (t) => { const camera = createCamera(); const bb = [[-133, 16], [-68, 50]]; - const transform = camera.cameraForBounds(bb, { padding: {top: 10, right: 75, bottom: 50, left: 25}, duration: 0 }); - t.deepEqual(fixedLngLat(transform.center, 4), { lng: -96.5558, lat: 32.0833 }, 'correctly calculates coordinates for bounds with padding option as object applied'); + const transform = camera.cameraForBounds(bb, {padding: {top: 10, right: 75, bottom: 50, left: 25}, duration: 0}); + t.deepEqual(fixedLngLat(transform.center, 4), {lng: -96.5558, lat: 32.0833}, 'correctly calculates coordinates for bounds with padding option as object applied'); t.end(); }); @@ -1759,8 +1759,8 @@ test('camera', (t) => { const camera = createCamera(); const bb = [[-133, 16], [-68, 50]]; - const transform = camera.cameraForBounds(bb, { offset: [0, 100] }); - t.deepEqual(fixedLngLat(transform.center, 4), { lng: -100.5, lat: 44.4717 }, 'correctly calculates coordinates for bounds with padding option as object applied'); + const transform = camera.cameraForBounds(bb, {offset: [0, 100]}); + t.deepEqual(fixedLngLat(transform.center, 4), {lng: -100.5, lat: 44.4717}, 'correctly calculates coordinates for bounds with padding option as object applied'); t.end(); }); @@ -1768,8 +1768,8 @@ test('camera', (t) => { const camera = createCamera(); const bb = [[-133, 16], [-68, 50]]; - const transform = camera.cameraForBounds(bb, { offset: { x: 0, y: 100 } }); - t.deepEqual(fixedLngLat(transform.center, 4), { lng: -100.5, lat: 44.4717 }, 'correctly calculates coordinates for bounds with padding option as object applied'); + const transform = camera.cameraForBounds(bb, {offset: {x: 0, y: 100}}); + t.deepEqual(fixedLngLat(transform.center, 4), {lng: -100.5, lat: 44.4717}, 'correctly calculates coordinates for bounds with padding option as object applied'); t.end(); }); @@ -1777,8 +1777,8 @@ test('camera', (t) => { const camera = createCamera(); const bb = [[-133, 16], [-68, 50]]; - const transform = camera.cameraForBounds(bb, { padding: {top: 10, right: 75, bottom: 50, left: 25}, offset: [0, 100] }); - t.deepEqual(fixedLngLat(transform.center, 4), { lng: -96.5558, lat: 44.4189 }, 'correctly calculates coordinates for bounds with padding option as object applied'); + const transform = camera.cameraForBounds(bb, {padding: {top: 10, right: 75, bottom: 50, left: 25}, offset: [0, 100]}); + t.deepEqual(fixedLngLat(transform.center, 4), {lng: -96.5558, lat: 44.4189}, 'correctly calculates coordinates for bounds with padding option as object applied'); t.end(); }); @@ -1791,7 +1791,7 @@ test('camera', (t) => { const bb = [[-133, 16], [-68, 50]]; camera.fitBounds(bb, {duration:0}); - t.deepEqual(fixedLngLat(camera.getCenter(), 4), { lng: -100.5, lat: 34.7171 }, 'pans to coordinates based on fitBounds'); + t.deepEqual(fixedLngLat(camera.getCenter(), 4), {lng: -100.5, lat: 34.7171}, 'pans to coordinates based on fitBounds'); t.equal(fixedNum(camera.getZoom(), 3), 2.469); t.end(); }); @@ -1800,8 +1800,8 @@ test('camera', (t) => { const camera = createCamera(); const bb = [[-133, 16], [-68, 50]]; - camera.fitBounds(bb, { padding: 15, duration:0 }); - t.deepEqual(fixedLngLat(camera.getCenter(), 4), { lng: -100.5, lat: 34.7171 }, 'pans to coordinates based on fitBounds with padding option as number applied'); + camera.fitBounds(bb, {padding: 15, duration:0}); + t.deepEqual(fixedLngLat(camera.getCenter(), 4), {lng: -100.5, lat: 34.7171}, 'pans to coordinates based on fitBounds with padding option as number applied'); t.equal(fixedNum(camera.getZoom(), 3), 2.382); t.end(); }); @@ -1810,8 +1810,8 @@ test('camera', (t) => { const camera = createCamera(); const bb = [[-133, 16], [-68, 50]]; - camera.fitBounds(bb, { padding: {top: 10, right: 75, bottom: 50, left: 25}, duration:0 }); - t.deepEqual(fixedLngLat(camera.getCenter(), 4), { lng: -96.5558, lat: 32.0833 }, 'pans to coordinates based on fitBounds with padding option as object applied'); + camera.fitBounds(bb, {padding: {top: 10, right: 75, bottom: 50, left: 25}, duration:0}); + t.deepEqual(fixedLngLat(camera.getCenter(), 4), {lng: -96.5558, lat: 32.0833}, 'pans to coordinates based on fitBounds with padding option as object applied'); t.end(); }); @@ -1826,7 +1826,7 @@ test('camera', (t) => { const bearing = 225; camera.fitScreenCoordinates(p0, p1, bearing, {duration:0}); - t.deepEqual(fixedLngLat(camera.getCenter(), 4), { lng: -45, lat: 40.9799 }, 'centers, rotates 225 degrees, and zooms based on screen coordinates'); + t.deepEqual(fixedLngLat(camera.getCenter(), 4), {lng: -45, lat: 40.9799}, 'centers, rotates 225 degrees, and zooms based on screen coordinates'); t.equal(fixedNum(camera.getZoom(), 3), 1.5); t.equal(camera.getBearing(), -135); t.end(); @@ -1840,7 +1840,7 @@ test('camera', (t) => { const bearing = 0; camera.fitScreenCoordinates(p0, p1, bearing, {duration:0}); - t.deepEqual(fixedLngLat(camera.getCenter(), 4), { lng: -45, lat: 40.9799 }, 'centers and zooms in based on screen coordinates'); + t.deepEqual(fixedLngLat(camera.getCenter(), 4), {lng: -45, lat: 40.9799}, 'centers and zooms in based on screen coordinates'); t.equal(fixedNum(camera.getZoom(), 3), 2); t.equal(camera.getBearing(), 0); t.end(); @@ -1853,7 +1853,7 @@ test('camera', (t) => { const bearing = 0; camera.fitScreenCoordinates(p0, p1, bearing, {duration:0}); - t.deepEqual(fixedLngLat(camera.getCenter(), 4), { lng: -45, lat: 40.9799 }, 'centers and zooms based on screen coordinates in opposite order'); + t.deepEqual(fixedLngLat(camera.getCenter(), 4), {lng: -45, lat: 40.9799}, 'centers and zooms based on screen coordinates in opposite order'); t.equal(fixedNum(camera.getZoom(), 3), 2); t.equal(camera.getBearing(), 0); t.end(); diff --git a/test/unit/ui/control/attribution.test.js b/test/unit/ui/control/attribution.test.js index 4b537702acd..036f61cd204 100644 --- a/test/unit/ui/control/attribution.test.js +++ b/test/unit/ui/control/attribution.test.js @@ -1,7 +1,7 @@ -import { test } from '../../../util/test'; +import {test} from '../../../util/test'; import config from '../../../../src/util/config'; import AttributionControl from '../../../../src/ui/control/attribution_control'; -import { createMap as globalCreateMap } from '../../../util'; +import {createMap as globalCreateMap} from '../../../util'; function createMap(t) { config.ACCESS_TOKEN = 'pk.123'; @@ -81,20 +81,20 @@ test('AttributionControl dedupes attributions that are substrings of others', (t map.addControl(attribution); map.on('load', () => { - map.addSource('1', { type: 'geojson', data: { type: 'FeatureCollection', features: [] }, attribution: 'World' }); - map.addSource('2', { type: 'geojson', data: { type: 'FeatureCollection', features: [] }, attribution: 'Hello World' }); - map.addSource('3', { type: 'geojson', data: { type: 'FeatureCollection', features: [] }, attribution: 'Another Source' }); - map.addSource('4', { type: 'geojson', data: { type: 'FeatureCollection', features: [] }, attribution: 'Hello' }); - map.addSource('5', { type: 'geojson', data: { type: 'FeatureCollection', features: [] }, attribution: 'Hello World' }); - map.addSource('6', { type: 'geojson', data: { type: 'FeatureCollection', features: [] }, attribution: 'Hello World' }); - map.addSource('7', { type: 'geojson', data: { type: 'FeatureCollection', features: [] }, attribution: 'GeoJSON Source' }); - map.addLayer({ id: '1', type: 'fill', source: '1' }); - map.addLayer({ id: '2', type: 'fill', source: '2' }); - map.addLayer({ id: '3', type: 'fill', source: '3' }); - map.addLayer({ id: '4', type: 'fill', source: '4' }); - map.addLayer({ id: '5', type: 'fill', source: '5' }); - map.addLayer({ id: '6', type: 'fill', source: '6' }); - map.addLayer({ id: '7', type: 'fill', source: '7' }); + map.addSource('1', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'World'}); + map.addSource('2', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Hello World'}); + map.addSource('3', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Another Source'}); + map.addSource('4', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Hello'}); + map.addSource('5', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Hello World'}); + map.addSource('6', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Hello World'}); + map.addSource('7', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'GeoJSON Source'}); + map.addLayer({id: '1', type: 'fill', source: '1'}); + map.addLayer({id: '2', type: 'fill', source: '2'}); + map.addLayer({id: '3', type: 'fill', source: '3'}); + map.addLayer({id: '4', type: 'fill', source: '4'}); + map.addLayer({id: '5', type: 'fill', source: '5'}); + map.addLayer({id: '6', type: 'fill', source: '6'}); + map.addLayer({id: '7', type: 'fill', source: '7'}); }); let times = 0; @@ -114,8 +114,8 @@ test('AttributionControl has the correct edit map link', (t) => { const attribution = new AttributionControl(); map.addControl(attribution); map.on('load', () => { - map.addSource('1', { type: 'geojson', data: { type: 'FeatureCollection', features: [] }, attribution: 'Improve this map'}); - map.addLayer({ id: '1', type: 'fill', source: '1' }); + map.addSource('1', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Improve this map'}); + map.addLayer({id: '1', type: 'fill', source: '1'}); map.on('data', (e) => { if (e.dataType === 'source' && e.sourceDataType === 'metadata') { t.equal(attribution._editLink.rel, 'noopener nofollow'); @@ -133,8 +133,8 @@ test('AttributionControl is hidden if empty', (t) => { const attribution = new AttributionControl(); map.addControl(attribution); map.on('load', () => { - map.addSource('1', { type: 'geojson', data: { type: 'FeatureCollection', features: [] }}); - map.addLayer({ id: '1', type: 'fill', source: '1' }); + map.addSource('1', {type: 'geojson', data: {type: 'FeatureCollection', features: []}}); + map.addLayer({id: '1', type: 'fill', source: '1'}); }); const container = map.getContainer(); @@ -143,8 +143,8 @@ test('AttributionControl is hidden if empty', (t) => { t.equal(attribution._innerContainer.innerHTML, ''); t.equal(container.querySelectorAll('.mapboxgl-attrib-empty').length, 1, 'includes empty class when no attribution strings are provided'); - map.addSource('2', { type: 'geojson', data: { type: 'FeatureCollection', features: [] }, attribution: 'Hello World'}); - map.addLayer({ id: '2', type: 'fill', source: '2' }); + map.addSource('2', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Hello World'}); + map.addLayer({id: '2', type: 'fill', source: '2'}); }; const checkNotEmptyLater = () => { @@ -209,11 +209,11 @@ test('AttributionControl hides attributions for sources that are not currently v map.addControl(attribution); map.on('load', () => { - map.addSource('1', { type: 'geojson', data: { type: 'FeatureCollection', features: [] }, attribution: 'Used' }); - map.addSource('2', { type: 'geojson', data: { type: 'FeatureCollection', features: [] }, attribution: 'Not used' }); - map.addSource('3', { type: 'geojson', data: { type: 'FeatureCollection', features: [] }, attribution: 'Vibility none' }); - map.addLayer({ id: '1', type: 'fill', source: '1' }); - map.addLayer({ id: '3', type: 'fill', source: '3', layout: { visibility: 'none' } }); + map.addSource('1', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Used'}); + map.addSource('2', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Not used'}); + map.addSource('3', {type: 'geojson', data: {type: 'FeatureCollection', features: []}, attribution: 'Vibility none'}); + map.addLayer({id: '1', type: 'fill', source: '1'}); + map.addLayer({id: '3', type: 'fill', source: '3', layout: {visibility: 'none'}}); }); let times = 0; diff --git a/test/unit/ui/control/fullscreen.test.js b/test/unit/ui/control/fullscreen.test.js index f7923cd03f0..c7d52aa63c7 100644 --- a/test/unit/ui/control/fullscreen.test.js +++ b/test/unit/ui/control/fullscreen.test.js @@ -1,6 +1,6 @@ -import { test } from '../../../util/test'; +import {test} from '../../../util/test'; import window from '../../../../src/util/window'; -import { createMap } from '../../../util'; +import {createMap} from '../../../util'; import FullscreenControl from '../../../../src/ui/control/fullscreen_control'; test('FullscreenControl appears when fullscreen is enabled', (t) => { diff --git a/test/unit/ui/control/geolocate.test.js b/test/unit/ui/control/geolocate.test.js index 6ef29a12123..c0c63906749 100644 --- a/test/unit/ui/control/geolocate.test.js +++ b/test/unit/ui/control/geolocate.test.js @@ -1,6 +1,6 @@ -import { test } from '../../../util/test'; +import {test} from '../../../util/test'; import window from '../../../../src/util/window'; -import { createMap } from '../../../util'; +import {createMap} from '../../../util'; import GeolocateControl from '../../../../src/ui/control/geolocate_control'; // window and navigator globals need to be set for mock-geolocation @@ -133,7 +133,7 @@ test('GeolocateControl non-zero bearing', (t) => { const click = new window.Event('click'); map.once('moveend', () => { - t.deepEqual(lngLatAsFixed(map.getCenter(), 4), { lat: 10, lng: 20 }, 'map centered on location'); + t.deepEqual(lngLatAsFixed(map.getCenter(), 4), {lat: 10, lng: 20}, 'map centered on location'); t.equal(map.getBearing(), 45, 'map bearing retained'); t.equal(map.getZoom(), 10, 'geolocate fitBounds maxZoom'); t.end(); @@ -158,7 +158,7 @@ test('GeolocateControl no watching map camera on geolocation', (t) => { const click = new window.Event('click'); map.on('moveend', () => { - t.deepEqual(lngLatAsFixed(map.getCenter(), 4), { lat: 10, lng: 20 }, 'map centered on location'); + t.deepEqual(lngLatAsFixed(map.getCenter(), 4), {lat: 10, lng: 20}, 'map centered on location'); const mapBounds = map.getBounds(); @@ -207,11 +207,11 @@ test('GeolocateControl watching map updates recenter on location with dot', (t) if (moveendCount > 0) return; moveendCount++; - t.deepEqual(lngLatAsFixed(map.getCenter(), 4), { lat: 10, lng: 20 }, 'map centered on location after 1st update'); + t.deepEqual(lngLatAsFixed(map.getCenter(), 4), {lat: 10, lng: 20}, 'map centered on location after 1st update'); t.ok(geolocate._userLocationDotMarker._map, 'userLocation dot marker on map'); t.false(geolocate._userLocationDotMarker._element.classList.contains('mapboxgl-user-location-dot-stale'), 'userLocation does not have stale class'); map.once('moveend', () => { - t.deepEqual(lngLatAsFixed(map.getCenter(), 4), { lat: 40, lng: 50 }, 'map centered on location after 2nd update'); + t.deepEqual(lngLatAsFixed(map.getCenter(), 4), {lat: 40, lng: 50}, 'map centered on location after 2nd update'); geolocate.once('error', () => { t.ok(geolocate._userLocationDotMarker._map, 'userLocation dot marker on map'); t.ok(geolocate._userLocationDotMarker._element.classList.contains('mapboxgl-user-location-dot-stale'), 'userLocation has stale class'); diff --git a/test/unit/ui/control/logo.test.js b/test/unit/ui/control/logo.test.js index f28ff8d3701..0d133794dba 100644 --- a/test/unit/ui/control/logo.test.js +++ b/test/unit/ui/control/logo.test.js @@ -1,5 +1,5 @@ -import { test } from '../../../util/test'; -import { createMap as globalCreateMap } from '../../../util'; +import {test} from '../../../util/test'; +import {createMap as globalCreateMap} from '../../../util'; import VectorTileSource from '../../../../src/source/vector_tile_source'; function createMap(t, logoPosition, logoRequired) { @@ -23,10 +23,10 @@ function createMap(t, logoPosition, logoRequired) { } function createSource(options, logoRequired) { - const source = new VectorTileSource('id', options, { send () {} }); + const source = new VectorTileSource('id', options, {send () {}}); source.onAdd({ _requestManager: {_skuToken: '1234567890123'}, - transform: { angle: 0, pitch: 0, showCollisionBoxes: false }, + transform: {angle: 0, pitch: 0, showCollisionBoxes: false}, _getMapId: () => 1 }); source.on('error', (e) => { diff --git a/test/unit/ui/control/scale.test.js b/test/unit/ui/control/scale.test.js index c92aa7d8557..6197bec03c8 100644 --- a/test/unit/ui/control/scale.test.js +++ b/test/unit/ui/control/scale.test.js @@ -1,6 +1,6 @@ -import { test } from '../../../util/test'; -import { createMap } from '../../../util'; +import {test} from '../../../util/test'; +import {createMap} from '../../../util'; import ScaleControl from '../../../../src/ui/control/scale_control'; test('ScaleControl appears in bottom-left by default', (t) => { @@ -37,7 +37,7 @@ test('ScaleControl should change unit of distance after calling setUnit', (t) => test('ScaleControl should respect the maxWidth regardless of the unit and actual scale', (t) => { const map = createMap(t); const maxWidth = 100; - const scale = new ScaleControl({ maxWidth, unit: 'nautical' }); + const scale = new ScaleControl({maxWidth, unit: 'nautical'}); const selector = '.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl-scale'; map.addControl(scale); map.setZoom(12.5); diff --git a/test/unit/ui/handler/box_zoom.test.js b/test/unit/ui/handler/box_zoom.test.js index 090d0063b2c..3b44a40fb29 100644 --- a/test/unit/ui/handler/box_zoom.test.js +++ b/test/unit/ui/handler/box_zoom.test.js @@ -1,4 +1,4 @@ -import { test } from '../../../util/test'; +import {test} from '../../../util/test'; import window from '../../../../src/util/window'; import Map from '../../../../src/ui/map'; import DOM from '../../../../src/util/dom'; @@ -6,7 +6,7 @@ import simulate from '../../../util/simulate_interaction'; function createMap(t, clickTolerance) { t.stub(Map.prototype, '_detectMissingCSS'); - return new Map({ container: DOM.create('div', '', window.document.body), clickTolerance }); + return new Map({container: DOM.create('div', '', window.document.body), clickTolerance}); } test('BoxZoomHandler fires boxzoomstart and boxzoomend events at appropriate times', (t) => { diff --git a/test/unit/ui/handler/dblclick_zoom.test.js b/test/unit/ui/handler/dblclick_zoom.test.js index 57fd814b4ff..f5014c0f811 100644 --- a/test/unit/ui/handler/dblclick_zoom.test.js +++ b/test/unit/ui/handler/dblclick_zoom.test.js @@ -1,4 +1,4 @@ -import { test } from '../../../util/test'; +import {test} from '../../../util/test'; import window from '../../../../src/util/window'; import Map from '../../../../src/ui/map'; import DOM from '../../../../src/util/dom'; @@ -6,7 +6,7 @@ import simulate from '../../../util/simulate_interaction'; function createMap(t) { t.stub(Map.prototype, '_detectMissingCSS'); - return new Map({ container: DOM.create('div', '', window.document.body) }); + return new Map({container: DOM.create('div', '', window.document.body)}); } function simulateDoubleTap(map, delay = 100) { @@ -145,7 +145,7 @@ test('DoubleClickZoomHandler zooms on the second touchend event of a double tap' map._renderTaskQueue.run(); t.ok(zoom.called, 'should trigger zoom after second touchend'); - t.deepEquals(zoom.getCall(0).args[0].point, { x: 0.5, y: 0.5 }, 'should zoom to correct point'); + t.deepEquals(zoom.getCall(0).args[0].point, {x: 0.5, y: 0.5}, 'should zoom to correct point'); t.end(); }); diff --git a/test/unit/ui/handler/drag_pan.test.js b/test/unit/ui/handler/drag_pan.test.js index 34cd2e515ac..dd8e19acd41 100644 --- a/test/unit/ui/handler/drag_pan.test.js +++ b/test/unit/ui/handler/drag_pan.test.js @@ -1,4 +1,4 @@ -import { test } from '../../../util/test'; +import {test} from '../../../util/test'; import window from '../../../../src/util/window'; import Map from '../../../../src/ui/map'; import DOM from '../../../../src/util/dom'; @@ -6,7 +6,7 @@ import simulate from '../../../util/simulate_interaction'; function createMap(t, clickTolerance) { t.stub(Map.prototype, '_detectMissingCSS'); - return new Map({ container: DOM.create('div', '', window.document.body), clickTolerance: clickTolerance || 0 }); + return new Map({container: DOM.create('div', '', window.document.body), clickTolerance: clickTolerance || 0}); } test('DragPanHandler fires dragstart, drag, and dragend events at appropriate times in response to a mouse-triggered drag', (t) => { diff --git a/test/unit/ui/handler/drag_rotate.test.js b/test/unit/ui/handler/drag_rotate.test.js index 626bdef2e7a..1c4a459629a 100644 --- a/test/unit/ui/handler/drag_rotate.test.js +++ b/test/unit/ui/handler/drag_rotate.test.js @@ -1,5 +1,5 @@ -import { test } from '../../../util/test'; -import { extend } from '../../../../src/util/util'; +import {test} from '../../../util/test'; +import {extend} from '../../../../src/util/util'; import window from '../../../../src/util/window'; import Map from '../../../../src/ui/map'; import DOM from '../../../../src/util/dom'; @@ -8,7 +8,7 @@ import browser from '../../../../src/util/browser'; function createMap(t, options) { t.stub(Map.prototype, '_detectMissingCSS'); - return new Map(extend({ container: DOM.create('div', '', window.document.body) }, options)); + return new Map(extend({container: DOM.create('div', '', window.document.body)}, options)); } test('DragRotateHandler fires rotatestart, rotate, and rotateend events at appropriate times in response to a right-click drag', (t) => { diff --git a/test/unit/ui/handler/scroll_zoom.test.js b/test/unit/ui/handler/scroll_zoom.test.js index 077bd7c793d..4e6932ce5b5 100644 --- a/test/unit/ui/handler/scroll_zoom.test.js +++ b/test/unit/ui/handler/scroll_zoom.test.js @@ -1,10 +1,10 @@ -import { test } from '../../../util/test'; +import {test} from '../../../util/test'; import browser from '../../../../src/util/browser'; import window from '../../../../src/util/window'; import Map from '../../../../src/ui/map'; import DOM from '../../../../src/util/dom'; import simulate from '../../../util/simulate_interaction'; -import { equalWithPrecision } from '../../../util'; +import {equalWithPrecision} from '../../../util'; import sinon from 'sinon'; function createMap(t) { diff --git a/test/unit/ui/handler/touch_zoom_rotate.test.js b/test/unit/ui/handler/touch_zoom_rotate.test.js index 49bc68c834c..27ac39b2360 100644 --- a/test/unit/ui/handler/touch_zoom_rotate.test.js +++ b/test/unit/ui/handler/touch_zoom_rotate.test.js @@ -1,4 +1,4 @@ -import { test } from '../../../util/test'; +import {test} from '../../../util/test'; import window from '../../../../src/util/window'; import Map from '../../../../src/ui/map'; import DOM from '../../../../src/util/dom'; @@ -6,7 +6,7 @@ import simulate from '../../../util/simulate_interaction'; function createMap(t) { t.stub(Map.prototype, '_detectMissingCSS'); - return new Map({ container: DOM.create('div', '', window.document.body) }); + return new Map({container: DOM.create('div', '', window.document.body)}); } test('TouchZoomRotateHandler fires zoomstart, zoom, and zoomend events at appropriate times in response to a pinch-zoom gesture', (t) => { diff --git a/test/unit/ui/hash.test.js b/test/unit/ui/hash.test.js index d3cf7306e58..6cbe190a7ae 100644 --- a/test/unit/ui/hash.test.js +++ b/test/unit/ui/hash.test.js @@ -1,7 +1,7 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import Hash from '../../../src/ui/hash'; import window from '../../../src/util/window'; -import { createMap as globalCreateMap } from '../../util'; +import {createMap as globalCreateMap} from '../../util'; test('hash', (t) => { function createHash() { @@ -153,7 +153,7 @@ test('hash', (t) => { Object.defineProperty(container, 'clientWidth', {value: 512}); Object.defineProperty(container, 'clientHeight', {value: 512}); - const map = createMap(t, { hash: true }); + const map = createMap(t, {hash: true}); map.remove(); diff --git a/test/unit/ui/map.test.js b/test/unit/ui/map.test.js index c1b21e73be9..23a5ea1c719 100755 --- a/test/unit/ui/map.test.js +++ b/test/unit/ui/map.test.js @@ -1,12 +1,12 @@ -import { test } from '../../util/test'; -import { extend } from '../../../src/util/util'; +import {test} from '../../util/test'; +import {extend} from '../../../src/util/util'; import window from '../../../src/util/window'; import Map from '../../../src/ui/map'; -import { createMap } from '../../util'; +import {createMap} from '../../util'; import LngLat from '../../../src/geo/lng_lat'; import Tile from '../../../src/source/tile'; -import { OverscaledTileID } from '../../../src/source/tile_id'; -import { Event, ErrorEvent } from '../../../src/util/evented'; +import {OverscaledTileID} from '../../../src/source/tile_id'; +import {Event, ErrorEvent} from '../../../src/util/evented'; import simulate from '../../util/simulate_interaction'; import {fixedLngLat, fixedNum} from '../../util/fixed'; @@ -67,7 +67,7 @@ test('Map', (t) => { const bounds = [[-133, 16], [-68, 50]]; const map = createMap(t, {container, bounds}); - t.deepEqual(fixedLngLat(map.getCenter(), 4), { lng: -100.5, lat: 34.7171 }); + t.deepEqual(fixedLngLat(map.getCenter(), 4), {lng: -100.5, lat: 34.7171}); t.equal(fixedNum(map.getZoom(), 3), 2.113); t.end(); @@ -80,11 +80,11 @@ test('Map', (t) => { const container = window.document.createElement('div'); Object.defineProperty(container, 'offsetWidth', {value: 512}); Object.defineProperty(container, 'offsetHeight', {value: 512}); - return createMap(t, { skipCSSStub, container, bounds, fitBoundsOptions }); + return createMap(t, {skipCSSStub, container, bounds, fitBoundsOptions}); }; const unpadded = map(undefined, false); - const padded = map({ padding: 100 }, true); + const padded = map({padding: 100}, true); t.ok(unpadded.getZoom() > padded.getZoom()); @@ -132,7 +132,7 @@ test('Map', (t) => { t.test('emits load event after a style is set', (t) => { t.stub(Map.prototype, '_detectMissingCSS'); - const map = new Map({ container: window.document.createElement('div') }); + const map = new Map({container: window.document.createElement('div')}); map.on('load', fail); @@ -149,7 +149,7 @@ test('Map', (t) => { t.test('#setStyle', (t) => { t.test('returns self', (t) => { t.stub(Map.prototype, '_detectMissingCSS'); - const map = new Map({ container: window.document.createElement('div') }); + const map = new Map({container: window.document.createElement('div')}); t.equal(map.setStyle({ version: 8, sources: {}, @@ -236,7 +236,7 @@ test('Map', (t) => { t.ok(map.transform.unmodified, 'map transform is not modified'); map.setStyle(createStyle()); map.on('style.load', () => { - t.deepEqual(fixedLngLat(map.transform.center), fixedLngLat({ lng: -73.9749, lat: 40.7736 })); + t.deepEqual(fixedLngLat(map.transform.center), fixedLngLat({lng: -73.9749, lat: 40.7736})); t.equal(fixedNum(map.transform.zoom), 12.5); t.equal(fixedNum(map.transform.bearing), 29); t.equal(fixedNum(map.transform.pitch), 50); @@ -250,7 +250,7 @@ test('Map', (t) => { t.notOk(map.transform.unmodified, 'map transform is modified by options'); map.setStyle(createStyle()); map.on('style.load', () => { - t.deepEqual(fixedLngLat(map.transform.center), fixedLngLat({ lng: -77.0186, lat: 38.8888 })); + t.deepEqual(fixedLngLat(map.transform.center), fixedLngLat({lng: -77.0186, lat: 38.8888})); t.equal(fixedNum(map.transform.zoom), 10); t.equal(fixedNum(map.transform.bearing), 0); t.equal(fixedNum(map.transform.pitch), 0); @@ -267,7 +267,7 @@ test('Map', (t) => { t.notOk(map.transform.unmodified, 'map transform is modified via setters'); map.setStyle(createStyle()); map.on('style.load', () => { - t.deepEqual(fixedLngLat(map.transform.center), fixedLngLat({ lng: -77.0186, lat: 38.8888 })); + t.deepEqual(fixedLngLat(map.transform.center), fixedLngLat({lng: -77.0186, lat: 38.8888})); t.equal(fixedNum(map.transform.zoom), 10); t.equal(fixedNum(map.transform.bearing), 0); t.equal(fixedNum(map.transform.pitch), 0); @@ -363,7 +363,7 @@ test('Map', (t) => { const map = createMap(t, {style}); map.on('load', () => { - map.on('error', ({ error }) => { + map.on('error', ({error}) => { t.match(error.message, /There is no source with ID/); t.end(); }); @@ -402,7 +402,7 @@ test('Map', (t) => { map.addSource('fill', source); map.addLayer(layer); t.deepEqual(map.getStyle(), extend(createStyle(), { - sources: { fill: source }, + sources: {fill: source}, layers: [layer] })); t.end(); @@ -411,7 +411,7 @@ test('Map', (t) => { t.test('creates a new Style if diff fails', (t) => { const style = createStyle(); - const map = createMap(t, { style }); + const map = createMap(t, {style}); t.stub(map.style, 'setState').callsFake(() => { throw new Error('Dummy error'); }); @@ -425,7 +425,7 @@ test('Map', (t) => { t.test('creates a new Style if diff option is false', (t) => { const style = createStyle(); - const map = createMap(t, { style }); + const map = createMap(t, {style}); t.stub(map.style, 'setState').callsFake(() => { t.fail(); }); @@ -580,7 +580,7 @@ test('Map', (t) => { }); t.test('#getBounds', (t) => { - const map = createMap(t, { zoom: 0 }); + const map = createMap(t, {zoom: 0}); t.deepEqual(parseFloat(map.getBounds().getCenter().lng.toFixed(10)), 0, 'getBounds'); t.deepEqual(parseFloat(map.getBounds().getCenter().lat.toFixed(10)), 0, 'getBounds'); @@ -589,7 +589,7 @@ test('Map', (t) => { [ 70.31249999999977, 57.32652122521695 ] ])); t.test('rotated bounds', (t) => { - const map = createMap(t, { zoom: 1, bearing: 45, skipCSSStub: true }); + const map = createMap(t, {zoom: 1, bearing: 45, skipCSSStub: true}); t.deepEqual( toFixed([[-49.718445552178764, -44.44541580601936], [49.7184455522, 44.445415806019355]]), toFixed(map.getBounds().toArray()) @@ -908,13 +908,13 @@ test('Map', (t) => { t.test('#project', (t) => { const map = createMap(t); - t.deepEqual(map.project([0, 0]), { x: 100, y: 100 }); + t.deepEqual(map.project([0, 0]), {x: 100, y: 100}); t.end(); }); t.test('#unproject', (t) => { const map = createMap(t); - t.deepEqual(fixedLngLat(map.unproject([100, 100])), { lng: 0, lat: 0 }); + t.deepEqual(fixedLngLat(map.unproject([100, 100])), {lng: 0, lat: 0}); t.end(); }); @@ -967,7 +967,7 @@ test('Map', (t) => { const output = map.queryRenderedFeatures(map.project(new LngLat(0, 0))); const args = map.style.queryRenderedFeatures.getCall(0).args; - t.deepEqual(args[0], [{ x: 100, y: 100 }]); // query geometry + t.deepEqual(args[0], [{x: 100, y: 100}]); // query geometry t.deepEqual(args[1], {}); // params t.deepEqual(args[2], map.transform); // transform t.deepEqual(output, []); @@ -1093,7 +1093,7 @@ test('Map', (t) => { }); map.on('style.load', () => { - map.on('error', ({ error }) => { + map.on('error', ({error}) => { t.match(error.message, /does not exist in the map\'s style and cannot be styled/); t.end(); }); @@ -1264,7 +1264,7 @@ test('Map', (t) => { }); map.on('style.load', () => { - map.on('error', ({ error }) => { + map.on('error', ({error}) => { t.match(error.message, /does not exist in the map\'s style/); t.end(); }); @@ -1321,7 +1321,7 @@ test('Map', (t) => { }); map.on('style.load', () => { - map.on('error', ({ error }) => { + map.on('error', ({error}) => { t.match(error.message, /does not exist in the map\'s style and cannot be styled/); t.end(); }); @@ -1344,8 +1344,8 @@ test('Map', (t) => { } }); map.on('load', () => { - map.setFeatureState({ source: 'geojson', id: 12345}, {'hover': true}); - const fState = map.getFeatureState({ source: 'geojson', id: 12345}); + map.setFeatureState({source: 'geojson', id: 12345}, {'hover': true}); + const fState = map.getFeatureState({source: 'geojson', id: 12345}); t.equal(fState.hover, true); t.end(); }); @@ -1361,8 +1361,8 @@ test('Map', (t) => { } }); map.on('load', () => { - map.setFeatureState({ source: 'geojson', id: '12345'}, {'hover': true}); - const fState = map.getFeatureState({ source: 'geojson', id: 12345}); + map.setFeatureState({source: 'geojson', id: '12345'}, {'hover': true}); + const fState = map.getFeatureState({source: 'geojson', id: 12345}); t.equal(fState.hover, true); t.end(); }); @@ -1378,7 +1378,7 @@ test('Map', (t) => { } }); t.throws(() => { - map.setFeatureState({ source: 'geojson', id: 12345}, {'hover': true}); + map.setFeatureState({source: 'geojson', id: 12345}, {'hover': true}); }, Error, /load/i); t.end(); @@ -1394,11 +1394,11 @@ test('Map', (t) => { } }); map.on('load', () => { - map.on('error', ({ error }) => { + map.on('error', ({error}) => { t.match(error.message, /source/); t.end(); }); - map.setFeatureState({ source: 'vector', id: 12345}, {'hover': true}); + map.setFeatureState({source: 'vector', id: 12345}, {'hover': true}); }); }); t.test('fires an error if sourceLayer not provided for a vector source', (t) => { @@ -1415,11 +1415,11 @@ test('Map', (t) => { } }); map.on('load', () => { - map.on('error', ({ error }) => { + map.on('error', ({error}) => { t.match(error.message, /sourceLayer/); t.end(); }); - map.setFeatureState({ source: 'vector', sourceLayer: 0, id: 12345}, {'hover': true}); + map.setFeatureState({source: 'vector', sourceLayer: 0, id: 12345}, {'hover': true}); }); }); t.test('fires an error if id not provided', (t) => { @@ -1436,11 +1436,11 @@ test('Map', (t) => { } }); map.on('load', () => { - map.on('error', ({ error }) => { + map.on('error', ({error}) => { t.match(error.message, /id/); t.end(); }); - map.setFeatureState({ source: 'vector', sourceLayer: "1"}, {'hover': true}); + map.setFeatureState({source: 'vector', sourceLayer: "1"}, {'hover': true}); }); }); t.test('fires an error if id is less than zero', (t) => { @@ -1457,11 +1457,11 @@ test('Map', (t) => { } }); map.on('load', () => { - map.on('error', ({ error }) => { + map.on('error', ({error}) => { t.match(error.message, /id/); t.end(); }); - map.setFeatureState({ source: 'vector', sourceLayer: "1", id: -1}, {'hover': true}); + map.setFeatureState({source: 'vector', sourceLayer: "1", id: -1}, {'hover': true}); }); }); t.test('fires an error if id cannot be parsed as an int', (t) => { @@ -1478,11 +1478,11 @@ test('Map', (t) => { } }); map.on('load', () => { - map.on('error', ({ error }) => { + map.on('error', ({error}) => { t.match(error.message, /id/); t.end(); }); - map.setFeatureState({ source: 'vector', sourceLayer: "1", id: 'abc'}, {'hover': true}); + map.setFeatureState({source: 'vector', sourceLayer: "1", id: 'abc'}, {'hover': true}); }); }); t.end(); @@ -1501,9 +1501,9 @@ test('Map', (t) => { } }); map.on('load', () => { - map.setFeatureState({ source: 'geojson', id: 0}, {'hover': true, 'click': true}); - map.removeFeatureState({ source: 'geojson', id: 0}, 'hover'); - const fState = map.getFeatureState({ source: 'geojson', id: 0}); + map.setFeatureState({source: 'geojson', id: 0}, {'hover': true, 'click': true}); + map.removeFeatureState({source: 'geojson', id: 0}, 'hover'); + const fState = map.getFeatureState({source: 'geojson', id: 0}); t.equal(fState.hover, undefined); t.equal(fState.click, true); t.end(); @@ -1520,9 +1520,9 @@ test('Map', (t) => { } }); map.on('load', () => { - map.setFeatureState({ source: 'geojson', id: 12345}, {'hover': true}); - map.removeFeatureState({ source: 'geojson', id: 12345}, 'hover'); - const fState = map.getFeatureState({ source: 'geojson', id: 12345}); + map.setFeatureState({source: 'geojson', id: 12345}, {'hover': true}); + map.removeFeatureState({source: 'geojson', id: 12345}, 'hover'); + const fState = map.getFeatureState({source: 'geojson', id: 12345}); t.equal(fState.hover, undefined); t.end(); }); @@ -1538,10 +1538,10 @@ test('Map', (t) => { } }); map.on('load', () => { - map.setFeatureState({ source: 'geojson', id: 1}, {'hover': true, 'foo': true}); - map.removeFeatureState({ source: 'geojson', id: 1}); + map.setFeatureState({source: 'geojson', id: 1}, {'hover': true, 'foo': true}); + map.removeFeatureState({source: 'geojson', id: 1}); - const fState = map.getFeatureState({ source: 'geojson', id: 1}); + const fState = map.getFeatureState({source: 'geojson', id: 1}); t.equal(fState.hover, undefined); t.equal(fState.foo, undefined); @@ -1559,10 +1559,10 @@ test('Map', (t) => { } }); map.on('load', () => { - map.setFeatureState({ source: 'geojson', id: 0}, {'hover': true, 'foo': true}); - map.removeFeatureState({ source: 'geojson', id: 0}); + map.setFeatureState({source: 'geojson', id: 0}, {'hover': true, 'foo': true}); + map.removeFeatureState({source: 'geojson', id: 0}); - const fState = map.getFeatureState({ source: 'geojson', id: 0}); + const fState = map.getFeatureState({source: 'geojson', id: 0}); t.equal(fState.hover, undefined); t.equal(fState.foo, undefined); @@ -1580,10 +1580,10 @@ test('Map', (t) => { } }); map.on('load', () => { - map.setFeatureState({ source: 'geojson', id: 1}, {'hover': true, 'foo': true}); - map.removeFeatureState({ source: 'geojson', id: 1}, 'hover'); + map.setFeatureState({source: 'geojson', id: 1}, {'hover': true, 'foo': true}); + map.removeFeatureState({source: 'geojson', id: 1}, 'hover'); - const fState = map.getFeatureState({ source: 'geojson', id: 1}); + const fState = map.getFeatureState({source: 'geojson', id: 1}); t.equal(fState.foo, true); t.end(); @@ -1600,16 +1600,16 @@ test('Map', (t) => { } }); map.on('load', () => { - map.setFeatureState({ source: 'geojson', id: 1}, {'hover': true, 'foo': true}); - map.setFeatureState({ source: 'geojson', id: 2}, {'hover': true, 'foo': true}); + map.setFeatureState({source: 'geojson', id: 1}, {'hover': true, 'foo': true}); + map.setFeatureState({source: 'geojson', id: 2}, {'hover': true, 'foo': true}); - map.removeFeatureState({ source: 'geojson'}); + map.removeFeatureState({source: 'geojson'}); - const fState1 = map.getFeatureState({ source: 'geojson', id: 1}); + const fState1 = map.getFeatureState({source: 'geojson', id: 1}); t.equal(fState1.hover, undefined); t.equal(fState1.foo, undefined); - const fState2 = map.getFeatureState({ source: 'geojson', id: 2}); + const fState2 = map.getFeatureState({source: 'geojson', id: 2}); t.equal(fState2.hover, undefined); t.equal(fState2.foo, undefined); @@ -1627,27 +1627,27 @@ test('Map', (t) => { } }); map.on('load', () => { - map.setFeatureState({ source: 'geojson', id: 1}, {'hover': true, 'foo': true}); - map.setFeatureState({ source: 'geojson', id: 2}, {'hover': true, 'foo': true}); + map.setFeatureState({source: 'geojson', id: 1}, {'hover': true, 'foo': true}); + map.setFeatureState({source: 'geojson', id: 2}, {'hover': true, 'foo': true}); - map.removeFeatureState({ source: 'geojson', id: 1}); - map.removeFeatureState({ source: 'geojson', id: 1}, 'foo'); + map.removeFeatureState({source: 'geojson', id: 1}); + map.removeFeatureState({source: 'geojson', id: 1}, 'foo'); - const fState1 = map.getFeatureState({ source: 'geojson', id: 1}); + const fState1 = map.getFeatureState({source: 'geojson', id: 1}); t.equal(fState1.hover, undefined); - map.setFeatureState({ source: 'geojson', id: 1}, {'hover': true, 'foo': true}); - map.removeFeatureState({ source: 'geojson'}); - map.removeFeatureState({ source: 'geojson', id: 1}, 'foo'); + map.setFeatureState({source: 'geojson', id: 1}, {'hover': true, 'foo': true}); + map.removeFeatureState({source: 'geojson'}); + map.removeFeatureState({source: 'geojson', id: 1}, 'foo'); - const fState2 = map.getFeatureState({ source: 'geojson', id: 2}); + const fState2 = map.getFeatureState({source: 'geojson', id: 2}); t.equal(fState2.hover, undefined); - map.setFeatureState({ source: 'geojson', id: 2}, {'hover': true, 'foo': true}); - map.removeFeatureState({ source: 'geojson'}); - map.removeFeatureState({ source: 'geojson', id: 2}, 'foo'); + map.setFeatureState({source: 'geojson', id: 2}, {'hover': true, 'foo': true}); + map.removeFeatureState({source: 'geojson'}); + map.removeFeatureState({source: 'geojson', id: 2}, 'foo'); - const fState3 = map.getFeatureState({ source: 'geojson', id: 2}); + const fState3 = map.getFeatureState({source: 'geojson', id: 2}); t.equal(fState3.hover, undefined); t.end(); @@ -1664,17 +1664,17 @@ test('Map', (t) => { } }); map.on('load', () => { - map.setFeatureState({ source: 'geojson', id: 12345}, {'hover': true}); + map.setFeatureState({source: 'geojson', id: 12345}, {'hover': true}); - map.removeFeatureState({ source: 'geojson', id: 12345}); - map.setFeatureState({ source: 'geojson', id: 12345}, {'hover': true}); + map.removeFeatureState({source: 'geojson', id: 12345}); + map.setFeatureState({source: 'geojson', id: 12345}, {'hover': true}); - const fState1 = map.getFeatureState({ source: 'geojson', id: 12345}); + const fState1 = map.getFeatureState({source: 'geojson', id: 12345}); t.equal(fState1.hover, true); - map.removeFeatureState({ source: 'geojson', id: 12345}); + map.removeFeatureState({source: 'geojson', id: 12345}); - const fState2 = map.getFeatureState({ source: 'geojson', id: 12345}); + const fState2 = map.getFeatureState({source: 'geojson', id: 12345}); t.equal(fState2.hover, undefined); t.end(); @@ -1691,7 +1691,7 @@ test('Map', (t) => { } }); t.throws(() => { - map.removeFeatureState({ source: 'geojson', id: 12345}, {'hover': true}); + map.removeFeatureState({source: 'geojson', id: 12345}, {'hover': true}); }, Error, /load/i); t.end(); @@ -1707,11 +1707,11 @@ test('Map', (t) => { } }); map.on('load', () => { - map.on('error', ({ error }) => { + map.on('error', ({error}) => { t.match(error.message, /source/); t.end(); }); - map.removeFeatureState({ source: 'vector', id: 12345}, {'hover': true}); + map.removeFeatureState({source: 'vector', id: 12345}, {'hover': true}); }); }); t.test('fires an error if sourceLayer not provided for a vector source', (t) => { @@ -1728,11 +1728,11 @@ test('Map', (t) => { } }); map.on('load', () => { - map.on('error', ({ error }) => { + map.on('error', ({error}) => { t.match(error.message, /sourceLayer/); t.end(); }); - map.removeFeatureState({ source: 'vector', sourceLayer: 0, id: 12345}, {'hover': true}); + map.removeFeatureState({source: 'vector', sourceLayer: 0, id: 12345}, {'hover': true}); }); }); t.test('fires an error if state property is provided without a feature id', (t) => { @@ -1749,11 +1749,11 @@ test('Map', (t) => { } }); map.on('load', () => { - map.on('error', ({ error }) => { + map.on('error', ({error}) => { t.match(error.message, /id/); t.end(); }); - map.removeFeatureState({ source: 'vector', sourceLayer: "1"}, {'hover': true}); + map.removeFeatureState({source: 'vector', sourceLayer: "1"}, {'hover': true}); }); }); t.test('removeFeatureState fires an error if id is less than zero', (t) => { @@ -1770,11 +1770,11 @@ test('Map', (t) => { } }); map.on('load', () => { - map.on('error', ({ error }) => { + map.on('error', ({error}) => { t.match(error.message, /id/); t.end(); }); - map.removeFeatureState({ source: 'vector', sourceLayer: "1", id: -1}, {'hover': true}); + map.removeFeatureState({source: 'vector', sourceLayer: "1", id: -1}, {'hover': true}); }); }); t.test('fires an error if id cannot be parsed as an int', (t) => { @@ -1791,11 +1791,11 @@ test('Map', (t) => { } }); map.on('load', () => { - map.on('error', ({ error }) => { + map.on('error', ({error}) => { t.match(error.message, /id/); t.end(); }); - map.removeFeatureState({ source: 'vector', sourceLayer: "1", id: 'abc'}, {'hover': true}); + map.removeFeatureState({source: 'vector', sourceLayer: "1", id: 'abc'}, {'hover': true}); }); }); t.end(); @@ -1841,7 +1841,7 @@ test('Map', (t) => { }); let timer; - const map = createMap(t, { style }); + const map = createMap(t, {style}); map.on('render', () => { if (timer) clearTimeout(timer); timer = setTimeout(() => { @@ -1855,7 +1855,7 @@ test('Map', (t) => { t.test('no render after idle event', (t) => { const style = createStyle(); - const map = createMap(t, { style }); + const map = createMap(t, {style}); map.on('idle', () => { map.on('render', t.fail); setTimeout(() => { @@ -1866,9 +1866,9 @@ test('Map', (t) => { t.test('no idle event during move', (t) => { const style = createStyle(); - const map = createMap(t, { style, fadeDuration: 0 }); + const map = createMap(t, {style, fadeDuration: 0}); map.once('idle', () => { - map.zoomTo(0.5, { duration: 100 }); + map.zoomTo(0.5, {duration: 100}); t.ok(map.isMoving(), "map starts moving immediately after zoomTo"); map.once('idle', () => { t.ok(!map.isMoving(), "map stops moving before firing idle event"); @@ -1910,7 +1910,7 @@ test('Map', (t) => { t.test('stops camera animation on mousedown when interactive', (t) => { const map = createMap(t, {interactive: true}); - map.flyTo({ center: [200, 0], duration: 100 }); + map.flyTo({center: [200, 0], duration: 100}); simulate.mousedown(map.getCanvasContainer()); t.equal(map.isEasing(), false); @@ -1921,7 +1921,7 @@ test('Map', (t) => { t.test('continues camera animation on mousedown when non-interactive', (t) => { const map = createMap(t, {interactive: false}); - map.flyTo({ center: [200, 0], duration: 100 }); + map.flyTo({center: [200, 0], duration: 100}); simulate.mousedown(map.getCanvasContainer()); t.equal(map.isEasing(), true); @@ -1932,7 +1932,7 @@ test('Map', (t) => { t.test('stops camera animation on touchstart when interactive', (t) => { const map = createMap(t, {interactive: true}); - map.flyTo({ center: [200, 0], duration: 100 }); + map.flyTo({center: [200, 0], duration: 100}); simulate.touchstart(map.getCanvasContainer()); t.equal(map.isEasing(), false); @@ -1943,7 +1943,7 @@ test('Map', (t) => { t.test('continues camera animation on touchstart when non-interactive', (t) => { const map = createMap(t, {interactive: false}); - map.flyTo({ center: [200, 0], duration: 100 }); + map.flyTo({center: [200, 0], duration: 100}); simulate.touchstart(map.getCanvasContainer()); t.equal(map.isEasing(), true); @@ -1960,7 +1960,7 @@ test('Map', (t) => { window.document.styleSheets[0] = styleSheet; window.document.styleSheets.length = 1; - new Map({ container: window.document.createElement('div') }); + new Map({container: window.document.createElement('div')}); t.notok(stub.calledOnce); t.end(); @@ -1968,7 +1968,7 @@ test('Map', (t) => { t.test('should warn when CSS is missing', (t) => { const stub = t.stub(console, 'warn'); - new Map({ container: window.document.createElement('div') }); + new Map({container: window.document.createElement('div')}); t.ok(stub.calledOnce); @@ -1979,7 +1979,7 @@ test('Map', (t) => { const map = createMap(t), container = map.getContainer(); - map.flyTo({ center: [200, 0], duration: 100 }); + map.flyTo({center: [200, 0], duration: 100}); Object.defineProperty(container, 'clientWidth', {value: 250}); Object.defineProperty(container, 'clientHeight', {value: 250}); diff --git a/test/unit/ui/map/isMoving.test.js b/test/unit/ui/map/isMoving.test.js index e59f3e955fd..adfd483dc9e 100644 --- a/test/unit/ui/map/isMoving.test.js +++ b/test/unit/ui/map/isMoving.test.js @@ -1,4 +1,4 @@ -import { test } from '../../../util/test'; +import {test} from '../../../util/test'; import browser from '../../../../src/util/browser'; import window from '../../../../src/util/window'; import Map from '../../../../src/ui/map'; @@ -7,7 +7,7 @@ import simulate from '../../../util/simulate_interaction'; function createMap(t) { t.stub(Map.prototype, '_detectMissingCSS'); - return new Map({ container: DOM.create('div', '', window.document.body) }); + return new Map({container: DOM.create('div', '', window.document.body)}); } test('Map#isMoving returns false by default', (t) => { @@ -30,7 +30,7 @@ test('Map#isMoving returns true during a camera zoom animation', (t) => { t.end(); }); - map.zoomTo(5, { duration: 0 }); + map.zoomTo(5, {duration: 0}); }); test('Map#isMoving returns true when drag panning', (t) => { diff --git a/test/unit/ui/map/isRotating.test.js b/test/unit/ui/map/isRotating.test.js index 01fe2039bcc..69a6dca56a4 100644 --- a/test/unit/ui/map/isRotating.test.js +++ b/test/unit/ui/map/isRotating.test.js @@ -1,4 +1,4 @@ -import { test } from '../../../util/test'; +import {test} from '../../../util/test'; import window from '../../../../src/util/window'; import Map from '../../../../src/ui/map'; import DOM from '../../../../src/util/dom'; @@ -7,7 +7,7 @@ import browser from '../../../../src/util/browser'; function createMap(t) { t.stub(Map.prototype, '_detectMissingCSS'); - return new Map({ container: DOM.create('div', '', window.document.body) }); + return new Map({container: DOM.create('div', '', window.document.body)}); } test('Map#isRotating returns false by default', (t) => { @@ -30,7 +30,7 @@ test('Map#isRotating returns true during a camera rotate animation', (t) => { t.end(); }); - map.rotateTo(5, { duration: 0 }); + map.rotateTo(5, {duration: 0}); }); test('Map#isRotating returns true when drag rotating', (t) => { diff --git a/test/unit/ui/map/isZooming.test.js b/test/unit/ui/map/isZooming.test.js index 9b8cdfb24e7..7e2d6436a65 100644 --- a/test/unit/ui/map/isZooming.test.js +++ b/test/unit/ui/map/isZooming.test.js @@ -1,4 +1,4 @@ -import { test } from '../../../util/test'; +import {test} from '../../../util/test'; import browser from '../../../../src/util/browser'; import window from '../../../../src/util/window'; import Map from '../../../../src/ui/map'; @@ -7,7 +7,7 @@ import simulate from '../../../util/simulate_interaction'; function createMap(t) { t.stub(Map.prototype, '_detectMissingCSS'); - return new Map({ container: DOM.create('div', '', window.document.body) }); + return new Map({container: DOM.create('div', '', window.document.body)}); } test('Map#isZooming returns false by default', (t) => { @@ -30,7 +30,7 @@ test('Map#isZooming returns true during a camera zoom animation', (t) => { t.end(); }); - map.zoomTo(5, { duration: 0 }); + map.zoomTo(5, {duration: 0}); }); test('Map#isZooming returns true when scroll zooming', (t) => { diff --git a/test/unit/ui/map/requestRenderFrame.test.js b/test/unit/ui/map/requestRenderFrame.test.js index ea0eb8061f5..8799ee0b46a 100644 --- a/test/unit/ui/map/requestRenderFrame.test.js +++ b/test/unit/ui/map/requestRenderFrame.test.js @@ -1,5 +1,5 @@ -import { test } from '../../../util/test'; -import { createMap } from '../../../util'; +import {test} from '../../../util/test'; +import {createMap} from '../../../util'; test('Map#_requestRenderFrame schedules a new render frame if necessary', (t) => { const map = createMap(t); diff --git a/test/unit/ui/map_events.test.js b/test/unit/ui/map_events.test.js index c836e982277..21e8041fe88 100644 --- a/test/unit/ui/map_events.test.js +++ b/test/unit/ui/map_events.test.js @@ -1,6 +1,6 @@ -import { test } from '../../util/test'; -import { createMap } from '../../util'; -import simulate, { window } from '../../util/simulate_interaction'; +import {test} from '../../util/test'; +import {createMap} from '../../util'; +import simulate, {window} from '../../util/simulate_interaction'; test('Map#on adds a non-delegated event listener', (t) => { const map = createMap(t); @@ -555,7 +555,7 @@ test(`Map#on mousedown doesn't fire subsequent click event if mousepos changes`, }); test(`Map#on mousedown fires subsequent click event if mouse position changes less than click tolerance`, (t) => { - const map = createMap(t, { clickTolerance: 4 }); + const map = createMap(t, {clickTolerance: 4}); map.on('mousedown', e => e.preventDefault()); @@ -571,7 +571,7 @@ test(`Map#on mousedown fires subsequent click event if mouse position changes le }); test(`Map#on mousedown does not fire subsequent click event if mouse position changes more than click tolerance`, (t) => { - const map = createMap(t, { clickTolerance: 4 }); + const map = createMap(t, {clickTolerance: 4}); map.on('mousedown', e => e.preventDefault()); @@ -587,7 +587,7 @@ test(`Map#on mousedown does not fire subsequent click event if mouse position ch }); test(`Map#on click fires subsequent click event if there is no corresponding mousedown/mouseup event`, (t) => { - const map = createMap(t, { clickTolerance: 4 }); + const map = createMap(t, {clickTolerance: 4}); const click = t.spy(); map.on('click', click); diff --git a/test/unit/ui/marker.test.js b/test/unit/ui/marker.test.js index ec2a02624d5..99d2920e225 100644 --- a/test/unit/ui/marker.test.js +++ b/test/unit/ui/marker.test.js @@ -1,6 +1,6 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import window from '../../../src/util/window'; -import { createMap as globalCreateMap } from '../../util'; +import {createMap as globalCreateMap} from '../../util'; import Marker from '../../../src/ui/marker'; import Popup from '../../../src/ui/popup'; import LngLat from '../../../src/geo/lng_lat'; @@ -22,13 +22,13 @@ test('Marker uses a default marker element with an appropriate offset', (t) => { }); test('Marker uses a default marker element with custom color', (t) => { - const marker = new Marker({ color: '#123456' }); + const marker = new Marker({color: '#123456'}); t.ok(marker.getElement().innerHTML.includes('#123456')); t.end(); }); test('Marker uses a default marker with custom offset', (t) => { - const marker = new Marker({ offset: [1, 2] }); + const marker = new Marker({offset: [1, 2]}); t.ok(marker.getElement()); t.ok(marker.getOffset().equals(new Point(1, 2))); t.end(); @@ -152,7 +152,7 @@ test('Marker accepts backward-compatible constructor parameters', (t) => { const m1 = new Marker(element); t.equal(m1.getElement(), element); - const m2 = new Marker(element, { offset: [1, 2] }); + const m2 = new Marker(element, {offset: [1, 2]}); t.equal(m2.getElement(), element); t.ok(m2.getOffset().equals(new Point(1, 2))); t.end(); diff --git a/test/unit/ui/popup.test.js b/test/unit/ui/popup.test.js index c6f5849ba76..c41a4ff714b 100644 --- a/test/unit/ui/popup.test.js +++ b/test/unit/ui/popup.test.js @@ -1,6 +1,6 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import window from '../../../src/util/window'; -import { createMap as globalCreateMap } from '../../util'; +import {createMap as globalCreateMap} from '../../util'; import Popup from '../../../src/ui/popup'; import LngLat from '../../../src/geo/lng_lat'; import Point from '@mapbox/point-geometry'; @@ -14,7 +14,7 @@ function createMap(t, options) { const container = window.document.createElement('div'); Object.defineProperty(container, 'clientWidth', {value: options.width || containerWidth}); Object.defineProperty(container, 'clientHeight', {value: options.height || containerHeight}); - return globalCreateMap(t, { container }); + return globalCreateMap(t, {container}); } test('Popup#getElement returns a .mapboxgl-popup element', (t) => { @@ -396,7 +396,7 @@ test('Popup anchors as specified by the anchor option', (t) => { test('Popup automatically anchors to top if its bottom offset would push it off-screen', (t) => { const map = createMap(t); const point = new Point(containerWidth / 2, containerHeight / 2); - const options = { offset: { + const options = {offset: { 'bottom': [0, -25], 'top': [0, 0] }}; diff --git a/test/unit/util/actor.test.js b/test/unit/util/actor.test.js index 97fdaf6547a..8b91db33244 100644 --- a/test/unit/util/actor.test.js +++ b/test/unit/util/actor.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import Actor from '../../../src/util/actor'; import WebWorker from '../../../src/util/web_worker'; @@ -18,13 +18,13 @@ test('Actor', (t) => { const m2 = new Actor(worker, {}, 2); t.plan(4); - m1.send('test', { value: 1729 }, (err, response) => { + m1.send('test', {value: 1729}, (err, response) => { t.error(err); - t.same(response, { value: 1729 }); + t.same(response, {value: 1729}); }); - m2.send('test', { value: 4104 }, (err, response) => { + m2.send('test', {value: 4104}, (err, response) => { t.error(err); - t.same(response, { value: 4104 }); + t.same(response, {value: 4104}); }); }); diff --git a/test/unit/util/ajax.test.js b/test/unit/util/ajax.test.js index b46b693cd47..f7e5e5133a2 100644 --- a/test/unit/util/ajax.test.js +++ b/test/unit/util/ajax.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import { getArrayBuffer, getJSON, @@ -24,7 +24,7 @@ test('ajax', (t) => { window.server.respondWith(request => { request.respond(404); }); - getArrayBuffer({ url:'' }, (error) => { + getArrayBuffer({url:''}, (error) => { t.equal(error.status, 404); t.end(); }); @@ -35,7 +35,7 @@ test('ajax', (t) => { window.server.respondWith(request => { request.respond(200, {'Content-Type': 'application/json'}, '{"foo": "bar"}'); }); - getJSON({ url:'' }, (error, body) => { + getJSON({url:''}, (error, body) => { t.error(error); t.deepEqual(body, {foo: 'bar'}); t.end(); @@ -47,7 +47,7 @@ test('ajax', (t) => { window.server.respondWith(request => { request.respond(200, {'Content-Type': 'application/json'}, 'how do i even'); }); - getJSON({ url:'' }, (error) => { + getJSON({url:''}, (error) => { t.ok(error); t.end(); }); @@ -58,7 +58,7 @@ test('ajax', (t) => { window.server.respondWith(request => { request.respond(404); }); - getJSON({ url:'' }, (error) => { + getJSON({url:''}, (error) => { t.equal(error.status, 404); t.end(); }); @@ -69,7 +69,7 @@ test('ajax', (t) => { window.server.respondWith(request => { request.respond(401); }); - getJSON({ url:'' }, (error) => { + getJSON({url:''}, (error) => { t.equal(error.status, 401); t.equal(error.message, "Unauthorized"); t.end(); @@ -81,7 +81,7 @@ test('ajax', (t) => { window.server.respondWith(request => { request.respond(401); }); - getJSON({ url:'api.mapbox.com' }, (error) => { + getJSON({url:'api.mapbox.com'}, (error) => { t.equal(error.status, 401); t.equal(error.message, "Unauthorized: you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"); t.end(); @@ -93,7 +93,7 @@ test('ajax', (t) => { window.server.respondWith(request => { request.respond(204); }); - postData({ url:'api.mapbox.com' }, (error) => { + postData({url:'api.mapbox.com'}, (error) => { t.equal(error, null); t.end(); }); @@ -166,7 +166,7 @@ test('ajax', (t) => { t.equals(window.server.requests.length, maxRequests); const queuedURL = 'this-is-the-queued-request'; - const queued = getImage({ url: queuedURL }, () => t.fail()); + const queued = getImage({url: queuedURL}, () => t.fail()); // the new requests is queued because the limit is reached t.equals(window.server.requests.length, maxRequests); diff --git a/test/unit/util/browser.test.js b/test/unit/util/browser.test.js index 1b73e842b2b..4a482d53191 100644 --- a/test/unit/util/browser.test.js +++ b/test/unit/util/browser.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import browser from '../../../src/util/browser'; test('browser', (t) => { diff --git a/test/unit/util/classify_rings.test.js b/test/unit/util/classify_rings.test.js index b8fa8ced0cb..6434d99ac1f 100644 --- a/test/unit/util/classify_rings.test.js +++ b/test/unit/util/classify_rings.test.js @@ -1,8 +1,8 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import fs from 'fs'; import path from 'path'; import Protobuf from 'pbf'; -import { VectorTile } from '@mapbox/vector-tile'; +import {VectorTile} from '@mapbox/vector-tile'; import classifyRings from '../../../src/util/classify_rings'; // Load a fill feature from fixture tile. diff --git a/test/unit/util/color_ramp.test.js b/test/unit/util/color_ramp.test.js index d54d9b2dd8b..22687cf3163 100644 --- a/test/unit/util/color_ramp.test.js +++ b/test/unit/util/color_ramp.test.js @@ -1,7 +1,7 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import renderColorRamp from '../../../src/util/color_ramp'; -import { createPropertyExpression } from '../../../src/style-spec/expression'; +import {createPropertyExpression} from '../../../src/style-spec/expression'; const spec = { 'function': true, diff --git a/test/unit/util/dispatcher.test.js b/test/unit/util/dispatcher.test.js index efcfd1fbf5b..0fc7db0e4a0 100644 --- a/test/unit/util/dispatcher.test.js +++ b/test/unit/util/dispatcher.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import Dispatcher from '../../../src/util/dispatcher'; import WebWorker from '../../../src/util/web_worker'; import WorkerPool from '../../../src/util/worker_pool'; diff --git a/test/unit/util/evented.test.js b/test/unit/util/evented.test.js index 08106e17d41..eb1ed60b33f 100644 --- a/test/unit/util/evented.test.js +++ b/test/unit/util/evented.test.js @@ -1,5 +1,5 @@ -import { test } from '../../util/test'; -import { Event, Evented } from '../../../src/util/evented'; +import {test} from '../../util/test'; +import {Event, Evented} from '../../../src/util/evented'; test('Evented', (t) => { diff --git a/test/unit/util/find_pole_of_inaccessibility.test.js b/test/unit/util/find_pole_of_inaccessibility.test.js index 7d438cef98e..6265119024c 100644 --- a/test/unit/util/find_pole_of_inaccessibility.test.js +++ b/test/unit/util/find_pole_of_inaccessibility.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import Point from '@mapbox/point-geometry'; import findPoleOfInaccessibility from '../../../src/util/find_pole_of_inaccessibility'; diff --git a/test/unit/util/mapbox.test.js b/test/unit/util/mapbox.test.js index 5460aa91a18..785d01c886c 100644 --- a/test/unit/util/mapbox.test.js +++ b/test/unit/util/mapbox.test.js @@ -1,12 +1,12 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import * as mapbox from '../../../src/util/mapbox'; import config from '../../../src/util/config'; import window from '../../../src/util/window'; import webpSupported from '../../../src/util/webp_supported'; -import { uuid } from '../../../src/util/util'; -import { SKU_ID } from '../../../src/util/sku_token'; -import { version } from '../../../package.json'; -import { equalWithPrecision } from '../../util'; +import {uuid} from '../../../src/util/util'; +import {SKU_ID} from '../../../src/util/sku_token'; +import {version} from '../../../package.json'; +import {equalWithPrecision} from '../../util'; const mapboxTileURLs = [ 'https://a.tiles.mapbox.com/v4/mapbox.mapbox-terrain-v2,mapbox.mapbox-streets-v7/{z}/{x}/{y}.vector.pbf', diff --git a/test/unit/util/resolve_tokens.test.js b/test/unit/util/resolve_tokens.test.js index 5d17ddabf74..0b2f63965e1 100644 --- a/test/unit/util/resolve_tokens.test.js +++ b/test/unit/util/resolve_tokens.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import resolveTokens from '../../../src/util/resolve_tokens'; test('resolveToken', (t) => { diff --git a/test/unit/util/sku_token.test.js b/test/unit/util/sku_token.test.js index 7ba8d585644..83c81569c33 100644 --- a/test/unit/util/sku_token.test.js +++ b/test/unit/util/sku_token.test.js @@ -1,5 +1,5 @@ -import { test } from '../../util/test'; -import { createSkuToken, SKU_ID } from '../../../src/util/sku_token'; +import {test} from '../../util/test'; +import {createSkuToken, SKU_ID} from '../../../src/util/sku_token'; test('sku token generation', (t) => { const skuToken = createSkuToken().token; diff --git a/test/unit/util/struct_array.test.js b/test/unit/util/struct_array.test.js index 66c4547d98b..41d195d7de0 100644 --- a/test/unit/util/struct_array.test.js +++ b/test/unit/util/struct_array.test.js @@ -1,7 +1,7 @@ // @flow -import { test } from '../../util/test'; -import { StructArrayLayout3i6, FeatureIndexArray } from '../../../src/data/array_types'; +import {test} from '../../util/test'; +import {StructArrayLayout3i6, FeatureIndexArray} from '../../../src/data/array_types'; test('StructArray', (t) => { class TestArray extends StructArrayLayout3i6 {} diff --git a/test/unit/util/task_queue.test.js b/test/unit/util/task_queue.test.js index c04fa744c52..94430433f5e 100644 --- a/test/unit/util/task_queue.test.js +++ b/test/unit/util/task_queue.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import TaskQueue from '../../../src/util/task_queue'; test('TaskQueue', (t) => { diff --git a/test/unit/util/throttle.test.js b/test/unit/util/throttle.test.js index aea17838414..5c1943097d6 100644 --- a/test/unit/util/throttle.test.js +++ b/test/unit/util/throttle.test.js @@ -1,6 +1,6 @@ // @flow -import { test } from '../../util/test'; +import {test} from '../../util/test'; import throttle from '../../../src/util/throttle'; diff --git a/test/unit/util/tile_cover.test.js b/test/unit/util/tile_cover.test.js index 02a03c3f524..27cf8370f47 100644 --- a/test/unit/util/tile_cover.test.js +++ b/test/unit/util/tile_cover.test.js @@ -1,7 +1,7 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import tileCover from '../../../src/util/tile_cover'; import MercatorCoordinate from '../../../src/geo/mercator_coordinate'; -import { OverscaledTileID } from '../../../src/source/tile_id'; +import {OverscaledTileID} from '../../../src/source/tile_id'; test('tileCover', (t) => { diff --git a/test/unit/util/util.test.js b/test/unit/util/util.test.js index 582274825dd..b858b5b77f5 100644 --- a/test/unit/util/util.test.js +++ b/test/unit/util/util.test.js @@ -1,8 +1,8 @@ // @flow -import { test } from '../../util/test'; +import {test} from '../../util/test'; -import { easeCubicInOut, keysDifference, extend, pick, uniqueId, bindAll, asyncAll, clamp, wrap, bezier, endsWith, mapObject, filterObject, deepEqual, clone, arraysIntersect, isCounterClockwise, isClosedPolygon, parseCacheControl, uuid, validateUuid } from '../../../src/util/util'; +import {easeCubicInOut, keysDifference, extend, pick, uniqueId, bindAll, asyncAll, clamp, wrap, bezier, endsWith, mapObject, filterObject, deepEqual, clone, arraysIntersect, isCounterClockwise, isClosedPolygon, parseCacheControl, uuid, validateUuid} from '../../../src/util/util'; import Point from '@mapbox/point-geometry'; test('util', (t) => { diff --git a/test/unit/util/web_worker_transfer.test.js b/test/unit/util/web_worker_transfer.test.js index 94f289c1d56..2fd5c43f553 100644 --- a/test/unit/util/web_worker_transfer.test.js +++ b/test/unit/util/web_worker_transfer.test.js @@ -1,9 +1,9 @@ // @flow -import { test } from '../../util/test'; -import { register, serialize, deserialize } from '../../../src/util/web_worker_transfer'; +import {test} from '../../util/test'; +import {register, serialize, deserialize} from '../../../src/util/web_worker_transfer'; -import type { Serialized } from '../../../src/util/web_worker_transfer'; +import type {Serialized} from '../../../src/util/web_worker_transfer'; test('round trip', (t) => { class Foo { @@ -26,7 +26,7 @@ test('round trip', (t) => { } } - register('Foo', Foo, { omit: ['_cached'] }); + register('Foo', Foo, {omit: ['_cached']}); const foo = new Foo(10); const transferables = []; diff --git a/test/unit/util/worker_pool.test.js b/test/unit/util/worker_pool.test.js index 43c807ff92d..3918dcf4ce8 100644 --- a/test/unit/util/worker_pool.test.js +++ b/test/unit/util/worker_pool.test.js @@ -1,4 +1,4 @@ -import { test } from '../../util/test'; +import {test} from '../../util/test'; import WorkerPool from '../../../src/util/worker_pool'; test('WorkerPool', (t) => {