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
+51 -17
View File
@@ -3,7 +3,6 @@
*/
import {coordinates as reverseCoordinates} from './reverse.js';
/**
* @param {Array<number>} flatCoordinates Flat coordinates.
* @param {number} offset Offset.
@@ -27,7 +26,6 @@ export function linearRingIsClockwise(flatCoordinates, offset, end, stride) {
return edge > 0;
}
/**
* Determines if linear rings are oriented. By default, left-hand orientation
* is tested (first ring must be clockwise, remaining rings counter-clockwise).
@@ -41,12 +39,22 @@ export function linearRingIsClockwise(flatCoordinates, offset, end, stride) {
* (counter-clockwise exterior ring and clockwise interior rings).
* @return {boolean} Rings are correctly oriented.
*/
export function linearRingsAreOriented(flatCoordinates, offset, ends, stride, opt_right) {
export function linearRingsAreOriented(
flatCoordinates,
offset,
ends,
stride,
opt_right
) {
const right = opt_right !== undefined ? opt_right : false;
for (let i = 0, ii = ends.length; i < ii; ++i) {
const end = ends[i];
const isClockwise = linearRingIsClockwise(
flatCoordinates, offset, end, stride);
flatCoordinates,
offset,
end,
stride
);
if (i === 0) {
if ((right && isClockwise) || (!right && !isClockwise)) {
return false;
@@ -61,7 +69,6 @@ export function linearRingsAreOriented(flatCoordinates, offset, ends, stride, op
return true;
}
/**
* Determines if linear rings are oriented. By default, left-hand orientation
* is tested (first ring must be clockwise, remaining rings counter-clockwise).
@@ -75,11 +82,18 @@ export function linearRingsAreOriented(flatCoordinates, offset, ends, stride, op
* (counter-clockwise exterior ring and clockwise interior rings).
* @return {boolean} Rings are correctly oriented.
*/
export function linearRingssAreOriented(flatCoordinates, offset, endss, stride, opt_right) {
export function linearRingssAreOriented(
flatCoordinates,
offset,
endss,
stride,
opt_right
) {
for (let i = 0, ii = endss.length; i < ii; ++i) {
const ends = endss[i];
if (!linearRingsAreOriented(
flatCoordinates, offset, ends, stride, opt_right)) {
if (
!linearRingsAreOriented(flatCoordinates, offset, ends, stride, opt_right)
) {
return false;
}
if (ends.length) {
@@ -89,7 +103,6 @@ export function linearRingssAreOriented(flatCoordinates, offset, endss, stride,
return true;
}
/**
* Orient coordinates in a flat array of linear rings. By default, rings
* are oriented following the left-hand rule (clockwise for exterior and
@@ -103,15 +116,26 @@ export function linearRingssAreOriented(flatCoordinates, offset, endss, stride,
* @param {boolean=} opt_right Follow the right-hand rule for orientation.
* @return {number} End.
*/
export function orientLinearRings(flatCoordinates, offset, ends, stride, opt_right) {
export function orientLinearRings(
flatCoordinates,
offset,
ends,
stride,
opt_right
) {
const right = opt_right !== undefined ? opt_right : false;
for (let i = 0, ii = ends.length; i < ii; ++i) {
const end = ends[i];
const isClockwise = linearRingIsClockwise(
flatCoordinates, offset, end, stride);
const reverse = i === 0 ?
(right && isClockwise) || (!right && !isClockwise) :
(right && !isClockwise) || (!right && isClockwise);
flatCoordinates,
offset,
end,
stride
);
const reverse =
i === 0
? (right && isClockwise) || (!right && !isClockwise)
: (right && !isClockwise) || (!right && isClockwise);
if (reverse) {
reverseCoordinates(flatCoordinates, offset, end, stride);
}
@@ -120,7 +144,6 @@ export function orientLinearRings(flatCoordinates, offset, ends, stride, opt_rig
return offset;
}
/**
* Orient coordinates in a flat array of linear rings. By default, rings
* are oriented following the left-hand rule (clockwise for exterior and
@@ -134,10 +157,21 @@ export function orientLinearRings(flatCoordinates, offset, ends, stride, opt_rig
* @param {boolean=} opt_right Follow the right-hand rule for orientation.
* @return {number} End.
*/
export function orientLinearRingsArray(flatCoordinates, offset, endss, stride, opt_right) {
export function orientLinearRingsArray(
flatCoordinates,
offset,
endss,
stride,
opt_right
) {
for (let i = 0, ii = endss.length; i < ii; ++i) {
offset = orientLinearRings(
flatCoordinates, offset, endss[i], stride, opt_right);
flatCoordinates,
offset,
endss[i],
stride,
opt_right
);
}
return offset;
}