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
+20 -27
View File
@@ -1,24 +1,21 @@
import {assign, clear, isEmpty, getValues} from '../../../src/ol/obj.js';
import {assign, clear, getValues, isEmpty} from '../../../src/ol/obj.js';
describe('ol.obj.assign()', function() {
it('is an alias for Object.assign() where available', function() {
describe('ol.obj.assign()', function () {
it('is an alias for Object.assign() where available', function () {
if (typeof Object.assign === 'function') {
expect(assign).to.be(Object.assign);
}
});
it('assigns properties from a source object to a target object', function() {
it('assigns properties from a source object to a target object', function () {
const source = {
sourceProp1: 'sourceValue1',
sourceProp2: 'sourceValue2'
sourceProp2: 'sourceValue2',
};
const target = {
sourceProp1: 'overridden',
targetProp1: 'targetValue1'
targetProp1: 'targetValue1',
};
const assigned = assign(target, source);
@@ -26,46 +23,42 @@ describe('ol.obj.assign()', function() {
expect(assigned.sourceProp1).to.be('sourceValue1');
expect(assigned.sourceProp2).to.be('sourceValue2');
expect(assigned.targetProp1).to.be('targetValue1');
});
it('throws a TypeError with `undefined` as target', function() {
expect(() => assign()).to.throwException(/Cannot convert undefined or null to object/);
it('throws a TypeError with `undefined` as target', function () {
expect(() => assign()).to.throwException(
/Cannot convert undefined or null to object/
);
});
it('throws a TypeError with `null` as target', function() {
expect(() => assign(null)).to.throwException(/Cannot convert undefined or null to object/);
it('throws a TypeError with `null` as target', function () {
expect(() => assign(null)).to.throwException(
/Cannot convert undefined or null to object/
);
});
});
describe('ol.obj.clear()', function() {
it('removes all properties from an object', function() {
describe('ol.obj.clear()', function () {
it('removes all properties from an object', function () {
expect(isEmpty(clear({foo: 'bar'}))).to.be(true);
expect(isEmpty(clear({foo: 'bar', num: 42}))).to.be(true);
expect(isEmpty(clear({}))).to.be(true);
expect(isEmpty(clear(null))).to.be(true);
});
});
describe('ol.obj.getValues()', function() {
it('gets a list of property values from an object', function() {
describe('ol.obj.getValues()', function () {
it('gets a list of property values from an object', function () {
expect(getValues({foo: 'bar', num: 42}).sort()).to.eql([42, 'bar']);
expect(getValues([])).to.eql([]);
});
});
describe('ol.obj.isEmpty()', function() {
it('checks if an object has any properties', function() {
describe('ol.obj.isEmpty()', function () {
it('checks if an object has any properties', function () {
expect(isEmpty({})).to.be(true);
expect(isEmpty(null)).to.be(true);
expect(isEmpty({foo: 'bar'})).to.be(false);
expect(isEmpty({foo: false})).to.be(false);
});
});