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,65 +1,62 @@
import Event from '../../../../src/ol/events/Event.js';
import Map from '../../../../src/ol/Map.js';
import MapBrowserPointerEvent from '../../../../src/ol/MapBrowserPointerEvent.js';
import Event from '../../../../src/ol/events/Event.js';
import PointerInteraction from '../../../../src/ol/interaction/Pointer.js';
describe('ol.interaction.Pointer', function() {
describe('#handleEvent', function() {
describe('ol.interaction.Pointer', function () {
describe('#handleEvent', function () {
let event;
let defaultPrevented;
beforeEach(function() {
beforeEach(function () {
const type = 'pointerdown';
const pointerEvent = new Event();
pointerEvent.type = type;
pointerEvent.pointerId = 0;
pointerEvent.preventDefault = function() {
pointerEvent.preventDefault = function () {
defaultPrevented = true;
};
event = new MapBrowserPointerEvent(type, new Map(), pointerEvent);
defaultPrevented = false;
});
it('does not prevent default on handled down event', function() {
it('does not prevent default on handled down event', function () {
const interaction = new PointerInteraction({
handleDownEvent: function() {
handleDownEvent: function () {
return true;
}
},
});
interaction.handleEvent(event);
expect(defaultPrevented).to.be(false);
});
it('does not prevent default on unhandled down event', function() {
it('does not prevent default on unhandled down event', function () {
const interaction = new PointerInteraction({
handleDownEvent: function() {
handleDownEvent: function () {
return false;
}
},
});
interaction.handleEvent(event);
expect(defaultPrevented).to.be(false);
});
});
describe('event handlers', function() {
describe('event handlers', function () {
let handleDownCalled, handleDragCalled, handleMoveCalled, handleUpCalled;
const flagHandleDown = function() {
const flagHandleDown = function () {
handleDownCalled = true;
};
const flagHandleDrag = function() {
const flagHandleDrag = function () {
handleDragCalled = true;
};
const flagHandleMove = function() {
const flagHandleMove = function () {
handleMoveCalled = true;
};
const flagHandleUp = function() {
const flagHandleUp = function () {
handleUpCalled = true;
};
@@ -83,25 +80,25 @@ describe('ol.interaction.Pointer', function() {
}
}
beforeEach(function() {
beforeEach(function () {
handleDownCalled = false;
handleDragCalled = false;
handleMoveCalled = false;
handleUpCalled = false;
});
it('has default event handlers', function() {
it('has default event handlers', function () {
const interaction = new PointerInteraction({});
expect(interaction.handleDownEvent()).to.be(false);
expect(interaction.handleUpEvent()).to.be(false);
});
it('allows event handler overrides via options', function() {
it('allows event handler overrides via options', function () {
const interaction = new PointerInteraction({
handleDownEvent: flagHandleDown,
handleDragEvent: flagHandleDrag,
handleMoveEvent: flagHandleMove,
handleUpEvent: flagHandleUp
handleUpEvent: flagHandleUp,
});
interaction.handleDownEvent();
@@ -117,7 +114,7 @@ describe('ol.interaction.Pointer', function() {
expect(handleUpCalled).to.be(true);
});
it('allows event handler overrides via class extension', function() {
it('allows event handler overrides via class extension', function () {
const interaction = new MockPointerInteraction({});
interaction.handleDownEvent();
@@ -132,7 +129,5 @@ describe('ol.interaction.Pointer', function() {
interaction.handleUpEvent();
expect(handleUpCalled).to.be(true);
});
});
});