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:
@@ -1,20 +1,19 @@
|
||||
import Cluster from '../../../../src/ol/source/Cluster.js';
|
||||
import EventType from '../../../../src/ol/events/EventType.js';
|
||||
import Feature from '../../../../src/ol/Feature.js';
|
||||
import LineString from '../../../../src/ol/geom/LineString.js';
|
||||
import Point from '../../../../src/ol/geom/Point.js';
|
||||
import Polygon from '../../../../src/ol/geom/Polygon.js';
|
||||
import {get as getProjection} from '../../../../src/ol/proj.js';
|
||||
import Cluster from '../../../../src/ol/source/Cluster.js';
|
||||
import Source from '../../../../src/ol/source/Source.js';
|
||||
import VectorSource from '../../../../src/ol/source/Vector.js';
|
||||
import EventType from '../../../../src/ol/events/EventType.js';
|
||||
import {get as getProjection} from '../../../../src/ol/proj.js';
|
||||
|
||||
describe('ol.source.Cluster', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
it('returns a cluster source', function() {
|
||||
describe('ol.source.Cluster', function () {
|
||||
describe('constructor', function () {
|
||||
it('returns a cluster source', function () {
|
||||
const source = new Cluster({
|
||||
projection: getProjection('EPSG:4326'),
|
||||
source: new VectorSource()
|
||||
source: new VectorSource(),
|
||||
});
|
||||
expect(source).to.be.a(Source);
|
||||
expect(source).to.be.a(Cluster);
|
||||
@@ -22,25 +21,25 @@ describe('ol.source.Cluster', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#loadFeatures', function() {
|
||||
describe('#loadFeatures', function () {
|
||||
const extent = [-1, -1, 1, 1];
|
||||
const projection = getProjection('EPSG:3857');
|
||||
it('clusters a source with point features', function() {
|
||||
it('clusters a source with point features', function () {
|
||||
const source = new Cluster({
|
||||
source: new VectorSource({
|
||||
features: [
|
||||
new Feature(new Point([0, 0])),
|
||||
new Feature(new Point([0, 0]))
|
||||
]
|
||||
})
|
||||
new Feature(new Point([0, 0])),
|
||||
],
|
||||
}),
|
||||
});
|
||||
source.loadFeatures(extent, 1, projection);
|
||||
expect(source.getFeatures().length).to.be(1);
|
||||
expect(source.getFeatures()[0].get('features').length).to.be(2);
|
||||
});
|
||||
it('clusters with a custom geometryFunction', function() {
|
||||
it('clusters with a custom geometryFunction', function () {
|
||||
const source = new Cluster({
|
||||
geometryFunction: function(feature) {
|
||||
geometryFunction: function (feature) {
|
||||
const geom = feature.getGeometry();
|
||||
if (geom.getType() == 'Point') {
|
||||
return geom;
|
||||
@@ -52,11 +51,25 @@ describe('ol.source.Cluster', function() {
|
||||
source: new VectorSource({
|
||||
features: [
|
||||
new Feature(new Point([0, 0])),
|
||||
new Feature(new LineString([[0, 0], [1, 1]])),
|
||||
new Feature(new Polygon(
|
||||
[[[-1, -1], [-1, 1], [1, 1], [1, -1], [-1, -1]]]))
|
||||
]
|
||||
})
|
||||
new Feature(
|
||||
new LineString([
|
||||
[0, 0],
|
||||
[1, 1],
|
||||
])
|
||||
),
|
||||
new Feature(
|
||||
new Polygon([
|
||||
[
|
||||
[-1, -1],
|
||||
[-1, 1],
|
||||
[1, 1],
|
||||
[1, -1],
|
||||
[-1, -1],
|
||||
],
|
||||
])
|
||||
),
|
||||
],
|
||||
}),
|
||||
});
|
||||
source.loadFeatures(extent, 1, projection);
|
||||
expect(source.getFeatures().length).to.be(1);
|
||||
@@ -64,36 +77,35 @@ describe('ol.source.Cluster', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setDistance', function() {
|
||||
it('changes the distance value', function() {
|
||||
describe('#setDistance', function () {
|
||||
it('changes the distance value', function () {
|
||||
const source = new Cluster({
|
||||
distance: 100,
|
||||
source: new VectorSource()
|
||||
source: new VectorSource(),
|
||||
});
|
||||
expect(source.getDistance()).to.be(100);
|
||||
source.setDistance(10);
|
||||
expect(source.getDistance()).to.be(10);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setSource', function() {
|
||||
it('removes the change listener from the old source', function() {
|
||||
describe('#setSource', function () {
|
||||
it('removes the change listener from the old source', function () {
|
||||
const source = new VectorSource();
|
||||
const clusterSource = new Cluster({
|
||||
source: source
|
||||
source: source,
|
||||
});
|
||||
expect(source.hasListener(EventType.CHANGE)).to.be(true);
|
||||
clusterSource.setSource(null);
|
||||
expect(source.hasListener(EventType.CHANGE)).to.be(false);
|
||||
});
|
||||
|
||||
it('properly removes the previous features', function() {
|
||||
it('properly removes the previous features', function () {
|
||||
const source = new Cluster({
|
||||
source: new VectorSource({
|
||||
features: [new Feature(new Point([0, 0]))]
|
||||
})
|
||||
features: [new Feature(new Point([0, 0]))],
|
||||
}),
|
||||
});
|
||||
|
||||
const projection = getProjection('EPSG:3857');
|
||||
@@ -104,6 +116,4 @@ describe('#setSource', function() {
|
||||
source.setSource(null);
|
||||
expect(source.features.length).to.be(0);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user