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:
@@ -2,7 +2,6 @@
|
||||
* @module ol/obj
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Polyfill for Object.assign(). Assigns enumerable and own properties from
|
||||
* one or more source objects to a target object.
|
||||
@@ -12,25 +11,27 @@
|
||||
* @param {...Object} var_sources The source object(s).
|
||||
* @return {!Object} The modified target object.
|
||||
*/
|
||||
export const assign = (typeof Object.assign === 'function') ? Object.assign : function(target, var_sources) {
|
||||
if (target === undefined || target === null) {
|
||||
throw new TypeError('Cannot convert undefined or null to object');
|
||||
}
|
||||
|
||||
const output = Object(target);
|
||||
for (let i = 1, ii = arguments.length; i < ii; ++i) {
|
||||
const source = arguments[i];
|
||||
if (source !== undefined && source !== null) {
|
||||
for (const key in source) {
|
||||
if (source.hasOwnProperty(key)) {
|
||||
output[key] = source[key];
|
||||
export const assign =
|
||||
typeof Object.assign === 'function'
|
||||
? Object.assign
|
||||
: function (target, var_sources) {
|
||||
if (target === undefined || target === null) {
|
||||
throw new TypeError('Cannot convert undefined or null to object');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
const output = Object(target);
|
||||
for (let i = 1, ii = arguments.length; i < ii; ++i) {
|
||||
const source = arguments[i];
|
||||
if (source !== undefined && source !== null) {
|
||||
for (const key in source) {
|
||||
if (source.hasOwnProperty(key)) {
|
||||
output[key] = source[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes all properties from an object.
|
||||
@@ -42,7 +43,6 @@ export function clear(object) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Polyfill for Object.values(). Get an array of property values from an object.
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values
|
||||
@@ -51,14 +51,16 @@ export function clear(object) {
|
||||
* @return {!Array<V>} The property values.
|
||||
* @template K,V
|
||||
*/
|
||||
export const getValues = (typeof Object.values === 'function') ? Object.values : function(object) {
|
||||
const values = [];
|
||||
for (const property in object) {
|
||||
values.push(object[property]);
|
||||
}
|
||||
return values;
|
||||
};
|
||||
|
||||
export const getValues =
|
||||
typeof Object.values === 'function'
|
||||
? Object.values
|
||||
: function (object) {
|
||||
const values = [];
|
||||
for (const property in object) {
|
||||
values.push(object[property]);
|
||||
}
|
||||
return values;
|
||||
};
|
||||
|
||||
/**
|
||||
* Determine if an object has any properties.
|
||||
|
||||
Reference in New Issue
Block a user