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

View File

@@ -1,28 +1,32 @@
import Feature from '../../../src/ol/Feature.js';
import Graticule from '../../../src/ol/layer/Graticule.js';
import Map from '../../../src/ol/Map.js';
import {fromLonLat, get as getProjection} from '../../../src/ol/proj.js';
import Stroke from '../../../src/ol/style/Stroke.js';
import Text from '../../../src/ol/style/Text.js';
import Feature from '../../../src/ol/Feature.js';
import {fromLonLat, get as getProjection} from '../../../src/ol/proj.js';
describe('ol.layer.Graticule', function() {
describe('ol.layer.Graticule', function () {
let graticule;
function createGraticule() {
graticule = new Graticule();
new Map({
layers: [graticule]
layers: [graticule],
});
}
describe('#createGraticule', function() {
it('creates a graticule without labels', function() {
describe('#createGraticule', function () {
it('creates a graticule without labels', function () {
createGraticule();
const extent = [-25614353.926475704, -7827151.696402049,
25614353.926475704, 7827151.696402049];
const extent = [
-25614353.926475704,
-7827151.696402049,
25614353.926475704,
7827151.696402049,
];
const projection = getProjection('EPSG:3857');
const resolution = 39135.75848201024;
const squaredTolerance = resolution * resolution / 4.0;
const squaredTolerance = (resolution * resolution) / 4.0;
graticule.updateProjectionInfo_(projection);
graticule.createGraticule_(extent, [0, 0], resolution, squaredTolerance);
expect(graticule.getMeridians().length).to.be(13);
@@ -31,17 +35,21 @@ describe('ol.layer.Graticule', function() {
expect(graticule.parallelsLabels_).to.be(null);
});
it('creates a graticule with normal world labels', function() {
it('creates a graticule with normal world labels', function () {
const feature = new Feature();
graticule = new Graticule({
showLabels: true,
wrapX: false
wrapX: false,
});
new Map({
layers: [graticule]
layers: [graticule],
});
const extent = [-25614353.926475704, -7827151.696402049,
25614353.926475704, 7827151.696402049];
const extent = [
-25614353.926475704,
-7827151.696402049,
25614353.926475704,
7827151.696402049,
];
const projection = getProjection('EPSG:3857');
const resolution = 39135.75848201024;
graticule.loaderFunction(extent, resolution, projection);
@@ -55,33 +63,45 @@ describe('ol.layer.Graticule', function() {
viewState: {
projection: projection,
resolution: resolution,
rotation: 0
}
}
rotation: 0,
},
},
};
graticule.drawLabels_(event);
expect(graticule.meridiansLabels_.length).to.be(13);
expect(graticule.meridiansLabels_[0].text).to.be('0° 00 00″');
expect(graticule.meridiansLabels_[0].geom.getCoordinates()[0]).to.roughlyEqual(0, 1e-9);
expect(
graticule.meridiansLabels_[0].geom.getCoordinates()[0]
).to.roughlyEqual(0, 1e-9);
expect(graticule.parallelsLabels_.length).to.be(3);
expect(graticule.parallelsLabels_[0].text).to.be('0° 00 00″');
expect(graticule.parallelsLabels_[0].geom.getCoordinates()[1]).to.roughlyEqual(0, 1e-9);
expect(
graticule.parallelsLabels_[0].geom.getCoordinates()[1]
).to.roughlyEqual(0, 1e-9);
feature.set('graticule_label', graticule.meridiansLabels_[0].text);
expect(graticule.lonLabelStyle_(feature).getText().getText()).to.be('0° 00 00″');
expect(graticule.lonLabelStyle_(feature).getText().getText()).to.be(
'0° 00 00″'
);
feature.set('graticule_label', graticule.parallelsLabels_[0].text);
expect(graticule.latLabelStyle_(feature).getText().getText()).to.be('0° 00 00″');
expect(graticule.latLabelStyle_(feature).getText().getText()).to.be(
'0° 00 00″'
);
});
it('creates a graticule with wrapped world labels', function() {
it('creates a graticule with wrapped world labels', function () {
const feature = new Feature();
graticule = new Graticule({
showLabels: true
showLabels: true,
});
new Map({
layers: [graticule]
layers: [graticule],
});
const extent = [-25614353.926475704, -7827151.696402049,
25614353.926475704, 7827151.696402049];
const extent = [
-25614353.926475704,
-7827151.696402049,
25614353.926475704,
7827151.696402049,
];
const projection = getProjection('EPSG:3857');
const resolution = 39135.75848201024;
graticule.loaderFunction(extent, resolution, projection);
@@ -95,25 +115,33 @@ describe('ol.layer.Graticule', function() {
viewState: {
projection: projection,
resolution: resolution,
rotation: 0
}
}
rotation: 0,
},
},
};
graticule.drawLabels_(event);
expect(graticule.meridiansLabels_.length).to.be(13);
expect(graticule.meridiansLabels_[0].text).to.be('0° 00 00″');
const coordinates = fromLonLat([360, 0]);
expect(graticule.meridiansLabels_[0].geom.getCoordinates()[0]).to.roughlyEqual(coordinates[0], 1e-9);
expect(
graticule.meridiansLabels_[0].geom.getCoordinates()[0]
).to.roughlyEqual(coordinates[0], 1e-9);
expect(graticule.parallelsLabels_.length).to.be(3);
expect(graticule.parallelsLabels_[0].text).to.be('0° 00 00″');
expect(graticule.parallelsLabels_[0].geom.getCoordinates()[1]).to.roughlyEqual(0, 1e-9);
expect(
graticule.parallelsLabels_[0].geom.getCoordinates()[1]
).to.roughlyEqual(0, 1e-9);
feature.set('graticule_label', graticule.meridiansLabels_[0].text);
expect(graticule.lonLabelStyle_(feature).getText().getText()).to.be('0° 00 00″');
expect(graticule.lonLabelStyle_(feature).getText().getText()).to.be(
'0° 00 00″'
);
feature.set('graticule_label', graticule.parallelsLabels_[0].text);
expect(graticule.latLabelStyle_(feature).getText().getText()).to.be('0° 00 00″');
expect(graticule.latLabelStyle_(feature).getText().getText()).to.be(
'0° 00 00″'
);
});
it('has a default stroke style', function() {
it('has a default stroke style', function () {
createGraticule();
const actualStyle = graticule.strokeStyle_;
@@ -121,14 +149,14 @@ describe('ol.layer.Graticule', function() {
expect(actualStyle instanceof Stroke).to.be(true);
});
it('can be configured with a stroke style', function() {
it('can be configured with a stroke style', function () {
createGraticule();
const customStrokeStyle = new Stroke({
color: 'rebeccapurple'
color: 'rebeccapurple',
});
const styledGraticule = new Graticule({
map: new Map({}),
strokeStyle: customStrokeStyle
strokeStyle: customStrokeStyle,
});
const actualStyle = styledGraticule.strokeStyle_;
@@ -136,29 +164,33 @@ describe('ol.layer.Graticule', function() {
expect(actualStyle).to.be(customStrokeStyle);
});
it('can be configured with label options', function() {
it('can be configured with label options', function () {
const latLabelStyle = new Text();
const lonLabelStyle = new Text();
const feature = new Feature();
graticule = new Graticule({
map: new Map({}),
showLabels: true,
lonLabelFormatter: function(lon) {
lonLabelFormatter: function (lon) {
return 'lon: ' + lon.toString();
},
latLabelFormatter: function(lat) {
latLabelFormatter: function (lat) {
return 'lat: ' + lat.toString();
},
lonLabelPosition: 0.9,
latLabelPosition: 0.1,
lonLabelStyle: lonLabelStyle,
latLabelStyle: latLabelStyle
latLabelStyle: latLabelStyle,
});
const extent = [-25614353.926475704, -7827151.696402049,
25614353.926475704, 7827151.696402049];
const extent = [
-25614353.926475704,
-7827151.696402049,
25614353.926475704,
7827151.696402049,
];
const projection = getProjection('EPSG:3857');
const resolution = 39135.75848201024;
const squaredTolerance = resolution * resolution / 4.0;
const squaredTolerance = (resolution * resolution) / 4.0;
graticule.updateProjectionInfo_(projection);
graticule.createGraticule_(extent, [0, 0], resolution, squaredTolerance);
expect(graticule.meridiansLabels_[0].text).to.be('lon: 0');
@@ -166,32 +198,40 @@ describe('ol.layer.Graticule', function() {
expect(graticule.lonLabelStyle_(feature).getText()).to.eql(lonLabelStyle);
expect(graticule.latLabelStyle_(feature).getText()).to.eql(latLabelStyle);
feature.set('graticule_label', graticule.meridiansLabels_[0].text);
expect(graticule.lonLabelStyle_(feature).getText().getText()).to.be('lon: 0');
expect(graticule.lonLabelStyle_(feature).getText().getText()).to.be(
'lon: 0'
);
feature.set('graticule_label', graticule.parallelsLabels_[0].text);
expect(graticule.latLabelStyle_(feature).getText().getText()).to.be('lat: 0');
expect(graticule.latLabelStyle_(feature).getText().getText()).to.be(
'lat: 0'
);
expect(graticule.lonLabelPosition_).to.be(0.9);
expect(graticule.latLabelPosition_).to.be(0.1);
});
it('can be configured with interval limits', function() {
it('can be configured with interval limits', function () {
graticule = new Graticule({
showLabels: true,
lonLabelFormatter: function(lon) {
lonLabelFormatter: function (lon) {
return lon.toString();
},
latLabelFormatter: function(lat) {
latLabelFormatter: function (lat) {
return lat.toString();
},
intervals: [10]
intervals: [10],
});
new Map({
layers: [graticule]
layers: [graticule],
});
const extent = [-25614353.926475704, -7827151.696402049,
25614353.926475704, 7827151.696402049];
const extent = [
-25614353.926475704,
-7827151.696402049,
25614353.926475704,
7827151.696402049,
];
const projection = getProjection('EPSG:3857');
const resolution = 4891.96981025128;
const squaredTolerance = resolution * resolution / 4.0;
const squaredTolerance = (resolution * resolution) / 4.0;
graticule.updateProjectionInfo_(projection);
graticule.createGraticule_(extent, [0, 0], resolution, squaredTolerance);
@@ -205,8 +245,5 @@ describe('ol.layer.Graticule', function() {
expect(graticule.getMeridians().length).to.be(37);
expect(graticule.getParallels().length).to.be(11);
});
});
});