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,52 +1,50 @@
import {
apply,
compose,
create,
invert,
makeInverse,
makeScale,
multiply,
reset,
rotate,
scale,
set,
setFromArray,
translate,
scale,
makeScale,
rotate,
multiply,
compose,
invert,
makeInverse,
apply
} from '../../../src/ol/transform.js';
describe('ol.transform', function() {
describe('ol.transform', function () {
function assertRoughlyEqual(t1, t2) {
t1.forEach(function(item, index) {
t1.forEach(function (item, index) {
expect(item).to.roughlyEqual(t2[index], 1e-8);
});
}
describe('create()', function() {
it('creates an identity transform', function() {
describe('create()', function () {
it('creates an identity transform', function () {
expect(create()).to.eql([1, 0, 0, 1, 0, 0]);
});
});
describe('reset()', function() {
it('resets tansform to an identity transform', function() {
describe('reset()', function () {
it('resets tansform to an identity transform', function () {
const transform = [1, 2, 3, 4, 5, 6];
expect(reset(transform)).to.eql([1, 0, 0, 1, 0, 0]);
expect(transform).to.eql([1, 0, 0, 1, 0, 0]);
});
});
describe('set()', function() {
it('sets the given values', function() {
describe('set()', function () {
it('sets the given values', function () {
const transform = create();
expect(set(transform, 1, 2, 3, 4, 5, 6)).to.eql([1, 2, 3, 4, 5, 6]);
expect(transform).to.eql([1, 2, 3, 4, 5, 6]);
});
});
describe('setFromArray()', function() {
it('sets values of 2nd transform on 1st transform', function() {
describe('setFromArray()', function () {
it('sets values of 2nd transform on 1st transform', function () {
const transform1 = create();
const transform2 = [1, 2, 3, 4, 5, 6];
expect(setFromArray(transform1, transform2)).to.eql(transform2);
@@ -54,46 +52,46 @@ describe('ol.transform', function() {
});
});
describe('translate()', function() {
it('applies translation to a transform', function() {
describe('translate()', function () {
it('applies translation to a transform', function () {
const transform = create();
expect(translate(transform, 3, 4)).to.eql([1, 0, 0, 1, 3, 4]);
expect(transform).to.eql([1, 0, 0, 1, 3, 4]);
});
});
describe('scale()', function() {
it('applies scaling to a transform', function() {
describe('scale()', function () {
it('applies scaling to a transform', function () {
const transform = create();
expect(scale(transform, 3, 4)).to.eql([3, 0, 0, 4, 0, 0]);
expect(transform).to.eql([3, 0, 0, 4, 0, 0]);
});
});
describe('makeScale()', function() {
it('creates a scale transform', function() {
describe('makeScale()', function () {
it('creates a scale transform', function () {
const target = create();
makeScale(target, 2, 3);
expect(target).to.eql([2, 0, 0, 3, 0, 0]);
});
it('returns the target', function() {
it('returns the target', function () {
const target = create();
const transform = makeScale(target, 2, 3);
expect(transform).to.be(target);
});
});
describe('rotate()', function() {
it('applies rotation to a transform', function() {
describe('rotate()', function () {
it('applies rotation to a transform', function () {
const transform = create();
assertRoughlyEqual(rotate(transform, Math.PI / 2), [0, 1, -1, 0, 0, 0]);
assertRoughlyEqual(transform, [0, 1, -1, 0, 0, 0]);
});
});
describe('multiply()', function() {
it('multiplies two transforms', function() {
describe('multiply()', function () {
it('multiplies two transforms', function () {
const transform1 = [1, 2, 1, 2, 1, 2];
const transform2 = [1, 2, 1, 2, 1, 2];
expect(multiply(transform1, transform2)).to.eql([3, 6, 3, 6, 4, 8]);
@@ -101,8 +99,8 @@ describe('ol.transform', function() {
});
});
describe('compose()', function() {
it('composes a translate, scale, rotate, translate transform', function() {
describe('compose()', function () {
it('composes a translate, scale, rotate, translate transform', function () {
const dx1 = 3;
const dy1 = 4;
const sx = 1.5;
@@ -118,26 +116,35 @@ describe('ol.transform', function() {
translate(expected, dx2, dy2);
const composed = create();
const composedReturn = compose(composed, dx1, dy1, sx, sy, angle, dx2, dy2);
const composedReturn = compose(
composed,
dx1,
dy1,
sx,
sy,
angle,
dx2,
dy2
);
expect(composed).to.equal(composedReturn);
expect(composed).to.eql(expected);
});
});
describe('invert()', function() {
it('inverts a transform', function() {
describe('invert()', function () {
it('inverts a transform', function () {
const transform = [1, 1, 1, 2, 2, 0];
expect(invert(transform)).to.eql([2, -1, -1, 1, -4, 2]);
});
it('throws if the transform cannot be inverted', function() {
it('throws if the transform cannot be inverted', function () {
const indeterminant = [1, 0, 1, 0, 1, 0];
expect(function() {
expect(function () {
invert(indeterminant);
}).to.throwException();
});
it('modifies the source', function() {
it('modifies the source', function () {
const source = [1, 1, 1, 2, 2, 0];
const inverted = invert(source);
expect(inverted).to.eql([2, -1, -1, 1, -4, 2]);
@@ -145,8 +152,8 @@ describe('ol.transform', function() {
});
});
describe('makeInverse()', function() {
it('makes the target the inverse of the source', function() {
describe('makeInverse()', function () {
it('makes the target the inverse of the source', function () {
const source = [1, 1, 1, 2, 2, 0];
const target = [1, 0, 0, 1, 0, 0];
makeInverse(target, source);
@@ -154,7 +161,7 @@ describe('ol.transform', function() {
expect(target).to.eql([2, -1, -1, 1, -4, 2]);
});
it('returns the target', function() {
it('returns the target', function () {
const source = [1, 1, 1, 2, 2, 0];
const target = [1, 0, 0, 1, 0, 0];
const inverted = makeInverse(target, source);
@@ -162,13 +169,12 @@ describe('ol.transform', function() {
});
});
describe('apply()', function() {
it('applies a transform to a 2d vector', function() {
describe('apply()', function () {
it('applies a transform to a 2d vector', function () {
const transform = translate(create(), 2, 3);
const point = [1, 2];
expect(apply(transform, point)).to.eql([3, 5]);
expect(point).to.eql([3, 5]);
});
});
});