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 {createSnapToResolutions, createSnapToPower} from '../../../src/ol/resolutionconstraint.js';
|
||||
import {createMinMaxResolution} from '../../../src/ol/resolutionconstraint.js';
|
||||
import {
|
||||
createSnapToPower,
|
||||
createSnapToResolutions,
|
||||
} from '../../../src/ol/resolutionconstraint.js';
|
||||
|
||||
|
||||
describe('ol.resolutionconstraint', function() {
|
||||
|
||||
describe('SnapToResolution', function() {
|
||||
|
||||
describe('ol.resolutionconstraint', function () {
|
||||
describe('SnapToResolution', function () {
|
||||
let resolutionConstraint;
|
||||
|
||||
beforeEach(function() {
|
||||
resolutionConstraint = createSnapToResolutions(
|
||||
[1000, 500, 250, 100]);
|
||||
beforeEach(function () {
|
||||
resolutionConstraint = createSnapToResolutions([1000, 500, 250, 100]);
|
||||
});
|
||||
|
||||
describe('direction 0', function() {
|
||||
it('returns expected resolution value', function() {
|
||||
describe('direction 0', function () {
|
||||
it('returns expected resolution value', function () {
|
||||
expect(resolutionConstraint(1000, 0)).to.eql(1000);
|
||||
expect(resolutionConstraint(500, 0)).to.eql(500);
|
||||
expect(resolutionConstraint(250, 0)).to.eql(250);
|
||||
@@ -22,8 +21,8 @@ describe('ol.resolutionconstraint', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('direction 1', function() {
|
||||
it('returns expected resolution value', function() {
|
||||
describe('direction 1', function () {
|
||||
it('returns expected resolution value', function () {
|
||||
expect(resolutionConstraint(1000, 1)).to.eql(1000);
|
||||
expect(resolutionConstraint(500, 1)).to.eql(500);
|
||||
expect(resolutionConstraint(250, 1)).to.eql(250);
|
||||
@@ -31,8 +30,8 @@ describe('ol.resolutionconstraint', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('direction -1', function() {
|
||||
it('returns expected resolution value', function() {
|
||||
describe('direction -1', function () {
|
||||
it('returns expected resolution value', function () {
|
||||
expect(resolutionConstraint(1000, -1)).to.eql(1000);
|
||||
expect(resolutionConstraint(500, -1)).to.eql(500);
|
||||
expect(resolutionConstraint(250, -1)).to.eql(250);
|
||||
@@ -41,18 +40,15 @@ describe('ol.resolutionconstraint', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('SnapToResolutions Nearest', function() {
|
||||
|
||||
describe('SnapToResolutions Nearest', function () {
|
||||
let resolutionConstraint;
|
||||
|
||||
beforeEach(function() {
|
||||
resolutionConstraint =
|
||||
createSnapToResolutions(
|
||||
[1000, 500, 250, 100]);
|
||||
beforeEach(function () {
|
||||
resolutionConstraint = createSnapToResolutions([1000, 500, 250, 100]);
|
||||
});
|
||||
|
||||
describe('direction 0', function() {
|
||||
it('returns expected resolution value', function() {
|
||||
describe('direction 0', function () {
|
||||
it('returns expected resolution value', function () {
|
||||
expect(resolutionConstraint(1050, 0)).to.eql(1000);
|
||||
expect(resolutionConstraint(950, 0)).to.eql(1000);
|
||||
expect(resolutionConstraint(550, 0)).to.eql(500);
|
||||
@@ -64,8 +60,8 @@ describe('ol.resolutionconstraint', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('direction 1', function() {
|
||||
it('returns expected resolution value', function() {
|
||||
describe('direction 1', function () {
|
||||
it('returns expected resolution value', function () {
|
||||
expect(resolutionConstraint(1050, 1)).to.eql(1000);
|
||||
expect(resolutionConstraint(950, 1)).to.eql(1000);
|
||||
expect(resolutionConstraint(550, 1)).to.eql(1000);
|
||||
@@ -77,8 +73,8 @@ describe('ol.resolutionconstraint', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('direction -1', function() {
|
||||
it('returns expected resolution value', function() {
|
||||
describe('direction -1', function () {
|
||||
it('returns expected resolution value', function () {
|
||||
expect(resolutionConstraint(1050, -1)).to.eql(1000);
|
||||
expect(resolutionConstraint(950, -1)).to.eql(500);
|
||||
expect(resolutionConstraint(550, -1)).to.eql(500);
|
||||
@@ -91,17 +87,15 @@ describe('ol.resolutionconstraint', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('createSnapToPower', function() {
|
||||
|
||||
describe('createSnapToPower', function () {
|
||||
let resolutionConstraint;
|
||||
|
||||
beforeEach(function() {
|
||||
resolutionConstraint =
|
||||
createSnapToPower(2, 1024, 1);
|
||||
beforeEach(function () {
|
||||
resolutionConstraint = createSnapToPower(2, 1024, 1);
|
||||
});
|
||||
|
||||
describe('delta 0', function() {
|
||||
it('returns expected resolution value', function() {
|
||||
describe('delta 0', function () {
|
||||
it('returns expected resolution value', function () {
|
||||
expect(resolutionConstraint(1024, 0)).to.eql(1024);
|
||||
expect(resolutionConstraint(512, 0)).to.eql(512);
|
||||
expect(resolutionConstraint(256, 0)).to.eql(256);
|
||||
@@ -116,8 +110,8 @@ describe('ol.resolutionconstraint', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('direction 1', function() {
|
||||
it('returns expected resolution value', function() {
|
||||
describe('direction 1', function () {
|
||||
it('returns expected resolution value', function () {
|
||||
expect(resolutionConstraint(1024, 1)).to.eql(1024);
|
||||
expect(resolutionConstraint(512, 1)).to.eql(512);
|
||||
expect(resolutionConstraint(256, 1)).to.eql(256);
|
||||
@@ -132,8 +126,8 @@ describe('ol.resolutionconstraint', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('direction -1', function() {
|
||||
it('returns expected resolution value', function() {
|
||||
describe('direction -1', function () {
|
||||
it('returns expected resolution value', function () {
|
||||
expect(resolutionConstraint(1024, -1)).to.eql(1024);
|
||||
expect(resolutionConstraint(512, -1)).to.eql(512);
|
||||
expect(resolutionConstraint(256, -1)).to.eql(256);
|
||||
@@ -149,17 +143,15 @@ describe('ol.resolutionconstraint', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('createSnapToPower Nearest', function() {
|
||||
|
||||
describe('createSnapToPower Nearest', function () {
|
||||
let resolutionConstraint;
|
||||
|
||||
beforeEach(function() {
|
||||
resolutionConstraint =
|
||||
createSnapToPower(2, 1024, 1);
|
||||
beforeEach(function () {
|
||||
resolutionConstraint = createSnapToPower(2, 1024, 1);
|
||||
});
|
||||
|
||||
describe('direction 0', function() {
|
||||
it('returns expected resolution value', function() {
|
||||
describe('direction 0', function () {
|
||||
it('returns expected resolution value', function () {
|
||||
expect(resolutionConstraint(1050, 0)).to.eql(1024);
|
||||
expect(resolutionConstraint(9050, 0)).to.eql(1024);
|
||||
expect(resolutionConstraint(550, 0)).to.eql(512);
|
||||
@@ -185,8 +177,8 @@ describe('ol.resolutionconstraint', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('direction 1', function() {
|
||||
it('returns expected resolution value', function() {
|
||||
describe('direction 1', function () {
|
||||
it('returns expected resolution value', function () {
|
||||
expect(resolutionConstraint(1050, 1)).to.eql(1024);
|
||||
expect(resolutionConstraint(9050, 1)).to.eql(1024);
|
||||
expect(resolutionConstraint(550, 1)).to.eql(1024);
|
||||
@@ -212,8 +204,8 @@ describe('ol.resolutionconstraint', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('direction -1', function() {
|
||||
it('returns expected resolution value', function() {
|
||||
describe('direction -1', function () {
|
||||
it('returns expected resolution value', function () {
|
||||
expect(resolutionConstraint(1050, -1)).to.eql(1024);
|
||||
expect(resolutionConstraint(9050, -1)).to.eql(1024);
|
||||
expect(resolutionConstraint(550, -1)).to.eql(512);
|
||||
@@ -240,27 +232,42 @@ describe('ol.resolutionconstraint', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('SnapToPower smooth constraint', function() {
|
||||
|
||||
describe('snap to power, smooth constraint on', function() {
|
||||
it('returns expected resolution value', function() {
|
||||
describe('SnapToPower smooth constraint', function () {
|
||||
describe('snap to power, smooth constraint on', function () {
|
||||
it('returns expected resolution value', function () {
|
||||
const resolutionConstraint = createSnapToPower(2, 128, 16, true);
|
||||
|
||||
expect(resolutionConstraint(150, 0, [100, 100], true)).to.be.greaterThan(128);
|
||||
expect(resolutionConstraint(150, 0, [100, 100], true)).to.be.lessThan(150);
|
||||
expect(resolutionConstraint(130, 0, [100, 100], true)).to.be.greaterThan(128);
|
||||
expect(resolutionConstraint(130, 0, [100, 100], true)).to.be.lessThan(130);
|
||||
expect(
|
||||
resolutionConstraint(150, 0, [100, 100], true)
|
||||
).to.be.greaterThan(128);
|
||||
expect(resolutionConstraint(150, 0, [100, 100], true)).to.be.lessThan(
|
||||
150
|
||||
);
|
||||
expect(
|
||||
resolutionConstraint(130, 0, [100, 100], true)
|
||||
).to.be.greaterThan(128);
|
||||
expect(resolutionConstraint(130, 0, [100, 100], true)).to.be.lessThan(
|
||||
130
|
||||
);
|
||||
expect(resolutionConstraint(128, 0, [100, 100], true)).to.eql(128);
|
||||
expect(resolutionConstraint(16, 0, [100, 100], true)).to.eql(16);
|
||||
expect(resolutionConstraint(15, 0, [100, 100], true)).to.be.greaterThan(15);
|
||||
expect(resolutionConstraint(15, 0, [100, 100], true)).to.be.lessThan(16);
|
||||
expect(resolutionConstraint(10, 0, [100, 100], true)).to.be.greaterThan(10);
|
||||
expect(resolutionConstraint(10, 0, [100, 100], true)).to.be.lessThan(16);
|
||||
expect(resolutionConstraint(15, 0, [100, 100], true)).to.be.greaterThan(
|
||||
15
|
||||
);
|
||||
expect(resolutionConstraint(15, 0, [100, 100], true)).to.be.lessThan(
|
||||
16
|
||||
);
|
||||
expect(resolutionConstraint(10, 0, [100, 100], true)).to.be.greaterThan(
|
||||
10
|
||||
);
|
||||
expect(resolutionConstraint(10, 0, [100, 100], true)).to.be.lessThan(
|
||||
16
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('snap to power, smooth constraint off', function() {
|
||||
it('returns expected resolution value', function() {
|
||||
describe('snap to power, smooth constraint off', function () {
|
||||
it('returns expected resolution value', function () {
|
||||
const resolutionConstraint = createSnapToPower(2, 128, 16, false);
|
||||
|
||||
expect(resolutionConstraint(150, 0, [100, 100], true)).to.eql(128);
|
||||
@@ -272,26 +279,48 @@ describe('ol.resolutionconstraint', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('snap to resolutions, smooth constraint on', function() {
|
||||
it('returns expected resolution value', function() {
|
||||
const resolutionConstraint = createSnapToResolutions([128, 64, 32, 16], true);
|
||||
describe('snap to resolutions, smooth constraint on', function () {
|
||||
it('returns expected resolution value', function () {
|
||||
const resolutionConstraint = createSnapToResolutions(
|
||||
[128, 64, 32, 16],
|
||||
true
|
||||
);
|
||||
|
||||
expect(resolutionConstraint(150, 0, [100, 100], true)).to.be.greaterThan(128);
|
||||
expect(resolutionConstraint(150, 0, [100, 100], true)).to.be.lessThan(150);
|
||||
expect(resolutionConstraint(130, 0, [100, 100], true)).to.be.greaterThan(128);
|
||||
expect(resolutionConstraint(130, 0, [100, 100], true)).to.be.lessThan(130);
|
||||
expect(
|
||||
resolutionConstraint(150, 0, [100, 100], true)
|
||||
).to.be.greaterThan(128);
|
||||
expect(resolutionConstraint(150, 0, [100, 100], true)).to.be.lessThan(
|
||||
150
|
||||
);
|
||||
expect(
|
||||
resolutionConstraint(130, 0, [100, 100], true)
|
||||
).to.be.greaterThan(128);
|
||||
expect(resolutionConstraint(130, 0, [100, 100], true)).to.be.lessThan(
|
||||
130
|
||||
);
|
||||
expect(resolutionConstraint(128, 0, [100, 100], true)).to.eql(128);
|
||||
expect(resolutionConstraint(16, 0, [100, 100], true)).to.eql(16);
|
||||
expect(resolutionConstraint(15, 0, [100, 100], true)).to.be.greaterThan(15);
|
||||
expect(resolutionConstraint(15, 0, [100, 100], true)).to.be.lessThan(16);
|
||||
expect(resolutionConstraint(10, 0, [100, 100], true)).to.be.greaterThan(10);
|
||||
expect(resolutionConstraint(10, 0, [100, 100], true)).to.be.lessThan(16);
|
||||
expect(resolutionConstraint(15, 0, [100, 100], true)).to.be.greaterThan(
|
||||
15
|
||||
);
|
||||
expect(resolutionConstraint(15, 0, [100, 100], true)).to.be.lessThan(
|
||||
16
|
||||
);
|
||||
expect(resolutionConstraint(10, 0, [100, 100], true)).to.be.greaterThan(
|
||||
10
|
||||
);
|
||||
expect(resolutionConstraint(10, 0, [100, 100], true)).to.be.lessThan(
|
||||
16
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('snap to resolutions, smooth constraint off', function() {
|
||||
it('returns expected resolution value', function() {
|
||||
const resolutionConstraint = createSnapToResolutions([128, 64, 32, 16], false);
|
||||
describe('snap to resolutions, smooth constraint off', function () {
|
||||
it('returns expected resolution value', function () {
|
||||
const resolutionConstraint = createSnapToResolutions(
|
||||
[128, 64, 32, 16],
|
||||
false
|
||||
);
|
||||
|
||||
expect(resolutionConstraint(150, 0, [100, 100], true)).to.eql(128);
|
||||
expect(resolutionConstraint(130, 0, [100, 100], true)).to.eql(128);
|
||||
@@ -302,25 +331,41 @@ describe('ol.resolutionconstraint', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('min/max, smooth constraint on', function() {
|
||||
it('returns expected resolution value', function() {
|
||||
describe('min/max, smooth constraint on', function () {
|
||||
it('returns expected resolution value', function () {
|
||||
const resolutionConstraint = createMinMaxResolution(128, 16, true);
|
||||
|
||||
expect(resolutionConstraint(150, 0, [100, 100], true)).to.be.greaterThan(128);
|
||||
expect(resolutionConstraint(150, 0, [100, 100], true)).to.be.lessThan(150);
|
||||
expect(resolutionConstraint(130, 0, [100, 100], true)).to.be.greaterThan(128);
|
||||
expect(resolutionConstraint(130, 0, [100, 100], true)).to.be.lessThan(130);
|
||||
expect(
|
||||
resolutionConstraint(150, 0, [100, 100], true)
|
||||
).to.be.greaterThan(128);
|
||||
expect(resolutionConstraint(150, 0, [100, 100], true)).to.be.lessThan(
|
||||
150
|
||||
);
|
||||
expect(
|
||||
resolutionConstraint(130, 0, [100, 100], true)
|
||||
).to.be.greaterThan(128);
|
||||
expect(resolutionConstraint(130, 0, [100, 100], true)).to.be.lessThan(
|
||||
130
|
||||
);
|
||||
expect(resolutionConstraint(128, 0, [100, 100], true)).to.eql(128);
|
||||
expect(resolutionConstraint(16, 0, [100, 100], true)).to.eql(16);
|
||||
expect(resolutionConstraint(15, 0, [100, 100], true)).to.be.greaterThan(15);
|
||||
expect(resolutionConstraint(15, 0, [100, 100], true)).to.be.lessThan(16);
|
||||
expect(resolutionConstraint(10, 0, [100, 100], true)).to.be.greaterThan(10);
|
||||
expect(resolutionConstraint(10, 0, [100, 100], true)).to.be.lessThan(16);
|
||||
expect(resolutionConstraint(15, 0, [100, 100], true)).to.be.greaterThan(
|
||||
15
|
||||
);
|
||||
expect(resolutionConstraint(15, 0, [100, 100], true)).to.be.lessThan(
|
||||
16
|
||||
);
|
||||
expect(resolutionConstraint(10, 0, [100, 100], true)).to.be.greaterThan(
|
||||
10
|
||||
);
|
||||
expect(resolutionConstraint(10, 0, [100, 100], true)).to.be.lessThan(
|
||||
16
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('min/max, smooth constraint off', function() {
|
||||
it('returns expected resolution value', function() {
|
||||
describe('min/max, smooth constraint off', function () {
|
||||
it('returns expected resolution value', function () {
|
||||
const resolutionConstraint = createMinMaxResolution(128, 16, false);
|
||||
|
||||
expect(resolutionConstraint(150, 0, [100, 100], true)).to.eql(128);
|
||||
@@ -332,5 +377,4 @@ describe('ol.resolutionconstraint', function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user