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,101 +1,255 @@
import {linearRingIsClockwise, linearRingsAreOriented,
linearRingssAreOriented, orientLinearRings, orientLinearRingsArray} from '../../../../../src/ol/geom/flat/orient.js';
import {
linearRingIsClockwise,
linearRingsAreOriented,
linearRingssAreOriented,
orientLinearRings,
orientLinearRingsArray,
} from '../../../../../src/ol/geom/flat/orient.js';
describe('ol.geom.flat.orient', function() {
describe('ol.geom.flat.orient.linearRingIsClockwise', function() {
it('identifies clockwise rings', function() {
describe('ol.geom.flat.orient', function () {
describe('ol.geom.flat.orient.linearRingIsClockwise', function () {
it('identifies clockwise rings', function () {
const flatCoordinates = [0, 1, 1, 4, 4, 3, 3, 0];
const isClockwise = linearRingIsClockwise(
flatCoordinates, 0, flatCoordinates.length, 2);
flatCoordinates,
0,
flatCoordinates.length,
2
);
expect(isClockwise).to.be(true);
});
it('identifies anti-clockwise rings', function() {
it('identifies anti-clockwise rings', function () {
const flatCoordinates = [2, 2, 3, 2, 3, 3, 2, 3];
const isClockwise = linearRingIsClockwise(
flatCoordinates, 0, flatCoordinates.length, 2);
flatCoordinates,
0,
flatCoordinates.length,
2
);
expect(isClockwise).to.be(false);
});
});
describe('ol.geom.flat.orient.linearRingsAreOriented', function() {
describe('ol.geom.flat.orient.linearRingsAreOriented', function () {
const oriented = linearRingsAreOriented;
const rightCoords = [
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
-100, -45, -100, 45, 100, 45, 100, -45, -100, -45
-180,
-90,
180,
-90,
180,
90,
-180,
90,
-180,
-90,
-100,
-45,
-100,
45,
100,
45,
100,
-45,
-100,
-45,
];
const leftCoords = [
-180, -90, -180, 90, 180, 90, 180, -90, -180, -90,
-100, -45, 100, -45, 100, 45, -100, 45, -100, -45
-180,
-90,
-180,
90,
180,
90,
180,
-90,
-180,
-90,
-100,
-45,
100,
-45,
100,
45,
-100,
45,
-100,
-45,
];
const ends = [10, 20];
it('checks for left-hand orientation by default', function() {
it('checks for left-hand orientation by default', function () {
expect(oriented(rightCoords, 0, ends, 2)).to.be(false);
expect(oriented(leftCoords, 0, ends, 2)).to.be(true);
});
it('can check for right-hand orientation', function() {
it('can check for right-hand orientation', function () {
expect(oriented(rightCoords, 0, ends, 2, true)).to.be(true);
expect(oriented(leftCoords, 0, ends, 2, true)).to.be(false);
});
});
describe('ol.geom.flat.orient.linearRingssAreOriented', function() {
describe('ol.geom.flat.orient.linearRingssAreOriented', function () {
const oriented = linearRingssAreOriented;
const rightCoords = [
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
-100, -45, -100, 45, 100, 45, 100, -45, -100, -45,
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
-100, -45, -100, 45, 100, 45, 100, -45, -100, -45
-180,
-90,
180,
-90,
180,
90,
-180,
90,
-180,
-90,
-100,
-45,
-100,
45,
100,
45,
100,
-45,
-100,
-45,
-180,
-90,
180,
-90,
180,
90,
-180,
90,
-180,
-90,
-100,
-45,
-100,
45,
100,
45,
100,
-45,
-100,
-45,
];
const leftCoords = [
-180, -90, -180, 90, 180, 90, 180, -90, -180, -90,
-100, -45, 100, -45, 100, 45, -100, 45, -100, -45,
-180, -90, -180, 90, 180, 90, 180, -90, -180, -90,
-100, -45, 100, -45, 100, 45, -100, 45, -100, -45
-180,
-90,
-180,
90,
180,
90,
180,
-90,
-180,
-90,
-100,
-45,
100,
-45,
100,
45,
-100,
45,
-100,
-45,
-180,
-90,
-180,
90,
180,
90,
180,
-90,
-180,
-90,
-100,
-45,
100,
-45,
100,
45,
-100,
45,
-100,
-45,
];
const ends = [[10, 20], [30, 40]];
const ends = [
[10, 20],
[30, 40],
];
it('checks for left-hand orientation by default', function() {
it('checks for left-hand orientation by default', function () {
expect(oriented(rightCoords, 0, ends, 2)).to.be(false);
expect(oriented(leftCoords, 0, ends, 2)).to.be(true);
});
it('can check for right-hand orientation', function() {
it('can check for right-hand orientation', function () {
expect(oriented(rightCoords, 0, ends, 2, true)).to.be(true);
expect(oriented(leftCoords, 0, ends, 2, true)).to.be(false);
});
});
describe('ol.geom.flat.orient.orientLinearRings', function() {
describe('ol.geom.flat.orient.orientLinearRings', function () {
const orient = orientLinearRings;
const rightCoords = [
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
-100, -45, -100, 45, 100, 45, 100, -45, -100, -45
-180,
-90,
180,
-90,
180,
90,
-180,
90,
-180,
-90,
-100,
-45,
-100,
45,
100,
45,
100,
-45,
-100,
-45,
];
const leftCoords = [
-180, -90, -180, 90, 180, 90, 180, -90, -180, -90,
-100, -45, 100, -45, 100, 45, -100, 45, -100, -45
-180,
-90,
-180,
90,
180,
90,
180,
-90,
-180,
-90,
-100,
-45,
100,
-45,
100,
45,
-100,
45,
-100,
-45,
];
const ends = [10, 20];
it('orients using the left-hand rule by default', function() {
it('orients using the left-hand rule by default', function () {
const rightClone = rightCoords.slice();
orient(rightClone, 0, ends, 2);
expect(rightClone).to.eql(leftCoords);
@@ -105,7 +259,7 @@ describe('ol.geom.flat.orient', function() {
expect(leftClone).to.eql(leftCoords);
});
it('can orient using the right-hand rule', function() {
it('can orient using the right-hand rule', function () {
const rightClone = rightCoords.slice();
orient(rightClone, 0, ends, 2, true);
expect(rightClone).to.eql(rightCoords);
@@ -114,29 +268,103 @@ describe('ol.geom.flat.orient', function() {
orient(leftClone, 0, ends, 2, true);
expect(leftClone).to.eql(rightCoords);
});
});
describe('ol.geom.flat.orient.orientLinearRingsArray', function() {
describe('ol.geom.flat.orient.orientLinearRingsArray', function () {
const orient = orientLinearRingsArray;
const rightCoords = [
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
-100, -45, -100, 45, 100, 45, 100, -45, -100, -45,
-180, -90, 180, -90, 180, 90, -180, 90, -180, -90,
-100, -45, -100, 45, 100, 45, 100, -45, -100, -45
-180,
-90,
180,
-90,
180,
90,
-180,
90,
-180,
-90,
-100,
-45,
-100,
45,
100,
45,
100,
-45,
-100,
-45,
-180,
-90,
180,
-90,
180,
90,
-180,
90,
-180,
-90,
-100,
-45,
-100,
45,
100,
45,
100,
-45,
-100,
-45,
];
const leftCoords = [
-180, -90, -180, 90, 180, 90, 180, -90, -180, -90,
-100, -45, 100, -45, 100, 45, -100, 45, -100, -45,
-180, -90, -180, 90, 180, 90, 180, -90, -180, -90,
-100, -45, 100, -45, 100, 45, -100, 45, -100, -45
-180,
-90,
-180,
90,
180,
90,
180,
-90,
-180,
-90,
-100,
-45,
100,
-45,
100,
45,
-100,
45,
-100,
-45,
-180,
-90,
-180,
90,
180,
90,
180,
-90,
-180,
-90,
-100,
-45,
100,
-45,
100,
45,
-100,
45,
-100,
-45,
];
const ends = [[10, 20], [30, 40]];
const ends = [
[10, 20],
[30, 40],
];
it('orients using the left-hand rule by default', function() {
it('orients using the left-hand rule by default', function () {
const rightClone = rightCoords.slice();
orient(rightClone, 0, ends, 2);
expect(rightClone).to.eql(leftCoords);
@@ -146,7 +374,7 @@ describe('ol.geom.flat.orient', function() {
expect(leftClone).to.eql(leftCoords);
});
it('can orient using the right-hand rule', function() {
it('can orient using the right-hand rule', function () {
const rightClone = rightCoords.slice();
orient(rightClone, 0, ends, 2, true);
expect(rightClone).to.eql(rightCoords);
@@ -155,8 +383,5 @@ describe('ol.geom.flat.orient', function() {
orient(leftClone, 0, ends, 2, true);
expect(leftClone).to.eql(rightCoords);
});
});
});