Make code prettier

This updates ESLint and our shared eslint-config-openlayers to use Prettier.  Most formatting changes were automatically applied with this:

    npm run lint -- --fix

A few manual changes were required:

 * In `examples/offscreen-canvas.js`, the `//eslint-disable-line` comment needed to be moved to the appropriate line to disable the error about the `'worker-loader!./offscreen-canvas.worker.js'` import.
 * In `examples/webpack/exapmle-builder.js`, spaces could not be added after a couple `function`s for some reason.  While editing this, I reworked `ExampleBuilder` to be a class.
 * In `src/ol/format/WMSGetFeatureInfo.js`, the `// @ts-ignore` comment needed to be moved down one line so it applied to the `parsersNS` argument.
This commit is contained in:
Tim Schaub
2020-04-06 12:25:12 -06:00
parent 53b48baf62
commit 054af09032
790 changed files with 46833 additions and 33765 deletions

41
examples/d3.js vendored
View File

@@ -1,24 +1,23 @@
import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js';
import {getWidth, getCenter} from '../src/ol/extent.js';
import {Layer, Tile as TileLayer} from '../src/ol/layer.js';
import SourceState from '../src/ol/source/State.js';
import {fromLonLat, toLonLat} from '../src/ol/proj.js';
import Stamen from '../src/ol/source/Stamen.js';
import View from '../src/ol/View.js';
import {Layer, Tile as TileLayer} from '../src/ol/layer.js';
import {fromLonLat, toLonLat} from '../src/ol/proj.js';
import {getCenter, getWidth} from '../src/ol/extent.js';
class CanvasLayer extends Layer {
constructor(options) {
super(options);
this.features = options.features;
this.svg = d3.select(document.createElement('div')).append('svg')
this.svg = d3
.select(document.createElement('div'))
.append('svg')
.style('position', 'absolute');
this.svg.append('path')
.datum(this.features)
.attr('class', 'boundary');
this.svg.append('path').datum(this.features).attr('class', 'boundary');
}
getSourceState() {
@@ -51,7 +50,10 @@ class CanvasLayer extends Layer {
const scale = r / frameState.viewState.resolution;
const center = toLonLat(getCenter(frameState.extent), projection);
d3Projection.scale(scale).center(center).translate([width / 2, height / 2]);
d3Projection
.scale(scale)
.center(center)
.translate([width / 2, height / 2]);
d3Path = d3Path.projection(d3Projection);
d3Path(this.features);
@@ -59,8 +61,7 @@ class CanvasLayer extends Layer {
this.svg.attr('width', width);
this.svg.attr('height', height);
this.svg.select('path')
.attr('d', d3Path);
this.svg.select('path').attr('d', d3Path);
return this.svg.node();
}
@@ -70,25 +71,23 @@ const map = new Map({
layers: [
new TileLayer({
source: new Stamen({
layer: 'watercolor'
})
})
layer: 'watercolor',
}),
}),
],
target: 'map',
view: new View({
center: fromLonLat([-97, 38]),
zoom: 4
})
zoom: 4,
}),
});
/**
* Load the topojson data and create an ol/layer/Image for that data.
*/
d3.json('data/topojson/us.json').then(function(us) {
d3.json('data/topojson/us.json').then(function (us) {
const layer = new CanvasLayer({
features: topojson.feature(us, us.objects.counties)
features: topojson.feature(us, us.objects.counties),
});
map.addLayer(layer);