Skip to content

Commit d261787

Browse files
Resolve prettier conflict (#1274)
1 parent 65e3242 commit d261787

17 files changed

+125
-117
lines changed

Diff for: .prettierrc

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ semi: true
33
singleQuote: true
44
trailingComma: none
55
bracketSpacing: false
6+
arrowParens: avoid

Diff for: examples/additional-overlays/src/choropleth-overlay.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ export default class ChoroplethOverlay extends PureComponent {
6161

6262
if (this.props.renderWhileDragging || !isDragging) {
6363
const transform = geoTransform({point: projectPoint});
64-
const path = geoPath()
65-
.projection(transform)
66-
.context(ctx);
64+
const path = geoPath().projection(transform).context(ctx);
6765
this._drawFeatures(ctx, path);
6866
}
6967
};
@@ -76,10 +74,7 @@ export default class ChoroplethOverlay extends PureComponent {
7674
const colorDomain =
7775
this.props.colorDomain || extent(features.toArray(), this.props.valueAccessor);
7876

79-
const colorScale = scaleLinear()
80-
.domain(colorDomain)
81-
.range(this.props.colorRange)
82-
.clamp(true);
77+
const colorScale = scaleLinear().domain(colorDomain).range(this.props.colorRange).clamp(true);
8378

8479
for (const feature of features) {
8580
ctx.beginPath();

Diff for: examples/geojson/src/utils.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import {scaleQuantile} from 'd3-scale';
33

44
export function updatePercentiles(featureCollection, accessor) {
55
const {features} = featureCollection;
6-
const scale = scaleQuantile()
7-
.domain(features.map(accessor))
8-
.range(range(9));
6+
const scale = scaleQuantile().domain(features.map(accessor)).range(range(9));
97
return {
108
type: 'FeatureCollection',
119
features: features.map(f => {

Diff for: examples/zoom-to-bounds/src/app.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,15 @@ export default class App extends Component {
3737
const [minLng, minLat, maxLng, maxLat] = bbox(feature);
3838
// construct a viewport instance from the current state
3939
const viewport = new WebMercatorViewport(this.state.viewport);
40-
const {longitude, latitude, zoom} = viewport.fitBounds([[minLng, minLat], [maxLng, maxLat]], {
41-
padding: 40
42-
});
40+
const {longitude, latitude, zoom} = viewport.fitBounds(
41+
[
42+
[minLng, minLat],
43+
[maxLng, maxLat]
44+
],
45+
{
46+
padding: 40
47+
}
48+
);
4349

4450
this.setState({
4551
viewport: {

Diff for: package.json

-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@
4545
"metrics": "ocular-metrics",
4646
"update-release-branch": "scripts/update-release-branch.sh"
4747
},
48-
"resolutions": {
49-
"prettier": "1.14.3"
50-
},
5148
"dependencies": {
5249
"@babel/runtime": "^7.0.0",
5350
"mapbox-gl": "^2.0.0",

Diff for: src/components/geolocate-control.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ function getBounds(position) {
6363
const radius = position.coords.accuracy;
6464
const bounds = center.toBounds(radius);
6565

66-
return [[bounds._ne.lng, bounds._ne.lat], [bounds._sw.lng, bounds._sw.lat]];
66+
return [
67+
[bounds._ne.lng, bounds._ne.lat],
68+
[bounds._sw.lng, bounds._sw.lat]
69+
];
6770
}
6871

6972
function setupMapboxGeolocateControl(context, props, geolocateButton) {
@@ -154,14 +157,11 @@ function GeolocateControl(props) {
154157
};
155158
}, []);
156159

157-
useEffect(
158-
() => {
159-
if (props.auto) {
160-
triggerGeolocate(context, props, mapboxGeolocateControl);
161-
}
162-
},
163-
[mapboxGeolocateControl, props.auto]
164-
);
160+
useEffect(() => {
161+
if (props.auto) {
162+
triggerGeolocate(context, props, mapboxGeolocateControl);
163+
}
164+
}, [mapboxGeolocateControl, props.auto]);
165165

166166
const {className, style, label, trackUserLocation} = props;
167167
return (

Diff for: src/components/interactive-map.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,10 @@ export default class InteractiveMap extends PureComponent {
235235
if (radius) {
236236
// Radius enables point features, like marker symbols, to be clicked.
237237
const size = radius;
238-
const bbox = [[pos[0] - size, pos[1] + size], [pos[0] + size, pos[1] - size]];
238+
const bbox = [
239+
[pos[0] - size, pos[1] + size],
240+
[pos[0] + size, pos[1] - size]
241+
];
239242
features = map && map.queryRenderedFeatures(bbox, queryParams);
240243
} else {
241244
features = map && map.queryRenderedFeatures(pos, queryParams);

Diff for: src/components/layer.js

+14-17
Original file line numberDiff line numberDiff line change
@@ -120,23 +120,20 @@ function Layer(props) {
120120
const id = useMemo(() => props.id || `jsx-layer-${layerCounter++}`, []);
121121
const {map} = context;
122122

123-
useEffect(
124-
() => {
125-
if (map) {
126-
const forceUpdate = () => setStyleLoaded(version => version + 1);
127-
map.on('styledata', forceUpdate);
128-
129-
return () => {
130-
map.off('styledata', forceUpdate);
131-
if (map.style && map.style._loaded) {
132-
map.removeLayer(id);
133-
}
134-
};
135-
}
136-
return undefined;
137-
},
138-
[map]
139-
);
123+
useEffect(() => {
124+
if (map) {
125+
const forceUpdate = () => setStyleLoaded(version => version + 1);
126+
map.on('styledata', forceUpdate);
127+
128+
return () => {
129+
map.off('styledata', forceUpdate);
130+
if (map.style && map.style._loaded) {
131+
map.removeLayer(id);
132+
}
133+
};
134+
}
135+
return undefined;
136+
}, [map]);
140137

141138
const layer = map && map.style && map.getLayer(id);
142139
if (layer) {

Diff for: src/components/marker.js

+20-23
Original file line numberDiff line numberDiff line change
@@ -73,29 +73,26 @@ function Marker(props) {
7373
const transform = `translate(${crispPixel(x)}px, ${crispPixel(y)}px)`;
7474
const cursor = draggable ? (dragPos ? 'grabbing' : 'grab') : 'auto';
7575

76-
const control = useMemo(
77-
() => {
78-
const containerStyle = {
79-
position: 'absolute',
80-
left: 0,
81-
top: 0,
82-
transform,
83-
cursor
84-
};
85-
86-
return (
87-
<div
88-
className={`mapboxgl-marker ${props.className}`}
89-
ref={thisRef.containerRef}
90-
// @ts-ignore
91-
style={containerStyle}
92-
>
93-
{props.children}
94-
</div>
95-
);
96-
},
97-
[props.className]
98-
);
76+
const control = useMemo(() => {
77+
const containerStyle = {
78+
position: 'absolute',
79+
left: 0,
80+
top: 0,
81+
transform,
82+
cursor
83+
};
84+
85+
return (
86+
<div
87+
className={`mapboxgl-marker ${props.className}`}
88+
ref={thisRef.containerRef}
89+
// @ts-ignore
90+
style={containerStyle}
91+
>
92+
{props.children}
93+
</div>
94+
);
95+
}, [props.className]);
9996

10097
const container = containerRef.current;
10198
if (container) {

Diff for: src/components/popup.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,10 @@ function Popup(props) {
149149
const {context, containerRef} = useMapControl(props, {onClick});
150150
const [, setLoaded] = useState(false);
151151

152-
useEffect(
153-
() => {
154-
// Container just got a size, re-calculate position
155-
setLoaded(true);
156-
},
157-
[contentRef.current]
158-
);
152+
useEffect(() => {
153+
// Container just got a size, re-calculate position
154+
setLoaded(true);
155+
}, [contentRef.current]);
159156

160157
const {viewport} = context;
161158
const {className, longitude, latitude, altitude, tipSize, closeButton, children} = props;

Diff for: src/components/scale-control.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,14 @@ function ScaleControl(props) {
3737
const {context, containerRef} = useMapControl(props);
3838
const [mapboxScaleControl, createMapboxScaleControl] = useState(null);
3939

40-
useEffect(
41-
() => {
42-
if (context.map) {
43-
const control = new mapboxgl.ScaleControl();
44-
control._map = context.map;
45-
control._container = containerRef.current;
46-
createMapboxScaleControl(control);
47-
}
48-
},
49-
[context.map]
50-
);
40+
useEffect(() => {
41+
if (context.map) {
42+
const control = new mapboxgl.ScaleControl();
43+
control._map = context.map;
44+
control._container = containerRef.current;
45+
createMapboxScaleControl(control);
46+
}
47+
}, [context.map]);
5148

5249
if (mapboxScaleControl) {
5350
mapboxScaleControl.options = props;

Diff for: src/components/source.js

+21-24
Original file line numberDiff line numberDiff line change
@@ -101,30 +101,27 @@ function Source(props) {
101101
const id = useMemo(() => props.id || `jsx-source-${sourceCounter++}`, []);
102102
const {map} = context;
103103

104-
useEffect(
105-
() => {
106-
if (map) {
107-
const forceUpdate = () => setStyleLoaded(version => version + 1);
108-
map.on('styledata', forceUpdate);
109-
110-
return () => {
111-
map.off('styledata', forceUpdate);
112-
/* global requestAnimationFrame */
113-
// Do not remove source immediately because the
114-
// dependent <Layer>s' componentWillUnmount() might not have been called
115-
// Removing source before dependent layers will throw error
116-
// TODO - find a more robust solution
117-
requestAnimationFrame(() => {
118-
if (map.style && map.style._loaded) {
119-
map.removeSource(id);
120-
}
121-
});
122-
};
123-
}
124-
return undefined;
125-
},
126-
[map]
127-
);
104+
useEffect(() => {
105+
if (map) {
106+
const forceUpdate = () => setStyleLoaded(version => version + 1);
107+
map.on('styledata', forceUpdate);
108+
109+
return () => {
110+
map.off('styledata', forceUpdate);
111+
/* global requestAnimationFrame */
112+
// Do not remove source immediately because the
113+
// dependent <Layer>s' componentWillUnmount() might not have been called
114+
// Removing source before dependent layers will throw error
115+
// TODO - find a more robust solution
116+
requestAnimationFrame(() => {
117+
if (map.style && map.style._loaded) {
118+
map.removeSource(id);
119+
}
120+
});
121+
};
122+
}
123+
return undefined;
124+
}, [map]);
128125

129126
let source = map && map.style && map.getSource(id);
130127
if (source) {

Diff for: src/utils/debounce.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default function debounce(func, delay) {
1010
return func.apply(_this, _arguments);
1111
};
1212

13-
return function() {
13+
return function () {
1414
_this = this;
1515
_arguments = arguments;
1616

Diff for: test/src/utils/deep-equal.spec.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ test('deepEqual', t => {
7373
'line-color': '#efefef',
7474
'line-width': {
7575
base: 1.55,
76-
stops: [[4, 0.25], [20, 30]]
76+
stops: [
77+
[4, 0.25],
78+
[20, 30]
79+
]
7780
}
7881
},
7982
'source-layer': 'road'
@@ -91,7 +94,10 @@ test('deepEqual', t => {
9194
'line-color': '#efefef',
9295
'line-width': {
9396
base: 1.55,
94-
stops: [[4, 0.25], [20, 30]]
97+
stops: [
98+
[4, 0.25],
99+
[20, 30]
100+
]
95101
}
96102
},
97103
'source-layer': 'road'

Diff for: test/src/utils/style-utils.spec.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ const testStyle = {
4848
'line-color': '#efefef',
4949
'line-width': {
5050
base: 1.55,
51-
stops: [[4, 0.25], [20, 30]]
51+
stops: [
52+
[4, 0.25],
53+
[20, 30]
54+
]
5255
}
5356
},
5457
minzoom: 5,
@@ -72,7 +75,10 @@ const testStyle = {
7275
'line-color': '#efefef',
7376
'line-width': {
7477
base: 2,
75-
stops: [[4, 0.5], [20, 40]]
78+
stops: [
79+
[4, 0.5],
80+
[20, 40]
81+
]
7682
}
7783
}
7884
}
@@ -123,7 +129,10 @@ const expectedStyle = {
123129
'line-color': '#efefef',
124130
'line-width': {
125131
base: 1.55,
126-
stops: [[4, 0.25], [20, 30]]
132+
stops: [
133+
[4, 0.25],
134+
[20, 30]
135+
]
127136
}
128137
},
129138
minzoom: 5,
@@ -156,7 +165,10 @@ const expectedStyle = {
156165
'line-color': '#efefef',
157166
'line-width': {
158167
base: 2,
159-
stops: [[4, 0.5], [20, 40]]
168+
stops: [
169+
[4, 0.5],
170+
[20, 40]
171+
]
160172
}
161173
}
162174
}

Diff for: test/src/utils/transition-manager.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ const easingFunctions = [t => Math.sqrt(t), t => t, t => t * t, t => t * t * t];
210210
const interruptions = [0.2, 0.5, 0.8];
211211
const values = [0, 0.5, 1];
212212

213-
test('TransitionManager#cropEasingFunction', function(t) {
213+
test('TransitionManager#cropEasingFunction', function (t) {
214214
easingFunctions.forEach(func => {
215215
interruptions.forEach(x0 => {
216216
var newEasing = cropEasingFunction(func, x0);

0 commit comments

Comments
 (0)