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,53 +1,72 @@
import ImageWrapper from '../../../../src/ol/Image.js';
import {listen} from '../../../../src/ol/events.js';
import {get as getProjection} from '../../../../src/ol/proj.js';
import ReprojImage from '../../../../src/ol/reproj/Image.js';
import {get as getProjection} from '../../../../src/ol/proj.js';
import {listen} from '../../../../src/ol/events.js';
describe('ol.reproj.Image', function() {
describe('ol.reproj.Image', function () {
function createImage(pixelRatio) {
return new ReprojImage(
getProjection('EPSG:3857'), getProjection('EPSG:4326'),
[-180, -85, 180, 85], 10, pixelRatio,
function(extent, resolution, pixelRatio) {
return new ImageWrapper(extent, resolution, pixelRatio,
getProjection('EPSG:3857'),
getProjection('EPSG:4326'),
[-180, -85, 180, 85],
10,
pixelRatio,
function (extent, resolution, pixelRatio) {
return new ImageWrapper(
extent,
resolution,
pixelRatio,
'data:image/gif;base64,' +
'R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=', null,
function(image, src) {
'R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=',
null,
function (image, src) {
image.getImage().src = src;
});
});
}
);
}
);
}
function createTranslucentImage(pixelRatio) {
return new ReprojImage(
getProjection('EPSG:3857'), getProjection('EPSG:4326'),
[-180, -85, 180, 85], 10, pixelRatio,
function(extent, resolution, pixelRatio) {
return new ImageWrapper(extent, resolution, pixelRatio,
getProjection('EPSG:3857'),
getProjection('EPSG:4326'),
[-180, -85, 180, 85],
10,
pixelRatio,
function (extent, resolution, pixelRatio) {
return new ImageWrapper(
extent,
resolution,
pixelRatio,
'data:image/png;base64,' +
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8depePQAIiwMjFXlnJQAAAABJRU5ErkJggg==', null,
function(image, src) {
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8depePQAIiwMjFXlnJQAAAABJRU5ErkJggg==',
null,
function (image, src) {
image.getImage().src = src;
});
});
}
);
}
);
}
it('changes state as expected', function(done) {
it('changes state as expected', function (done) {
const image = createImage(1);
expect(image.getState()).to.be(0); // IDLE
listen(image, 'change', function() {
if (image.getState() == 2) { // LOADED
listen(image, 'change', function () {
if (image.getState() == 2) {
// LOADED
done();
}
});
image.load();
});
it('returns correct canvas size', function(done) {
it('returns correct canvas size', function (done) {
const image = createImage(1);
listen(image, 'change', function() {
if (image.getState() == 2) { // LOADED
listen(image, 'change', function () {
if (image.getState() == 2) {
// LOADED
const canvas = image.getImage();
expect(canvas.width).to.be(36);
expect(canvas.height).to.be(17);
@@ -57,10 +76,11 @@ describe('ol.reproj.Image', function() {
image.load();
});
it('respects pixelRatio', function(done) {
it('respects pixelRatio', function (done) {
const image = createImage(2);
listen(image, 'change', function() {
if (image.getState() == 2) { // LOADED
listen(image, 'change', function () {
if (image.getState() == 2) {
// LOADED
const canvas = image.getImage();
expect(canvas.width).to.be(72);
expect(canvas.height).to.be(34);
@@ -70,14 +90,17 @@ describe('ol.reproj.Image', function() {
image.load();
});
it('has uniform color', function(done) {
it('has uniform color', function (done) {
const image = createTranslucentImage(1);
listen(image, 'change', function() {
if (image.getState() == 2) { // LOADED
listen(image, 'change', function () {
if (image.getState() == 2) {
// LOADED
const canvas = image.getImage();
expect(canvas.width).to.be(36);
expect(canvas.height).to.be(17);
const pixels = canvas.getContext('2d').getImageData(0, 0, canvas.width, canvas.height).data;
const pixels = canvas
.getContext('2d')
.getImageData(0, 0, canvas.width, canvas.height).data;
for (let i = 0; i < canvas.width * canvas.height * 4; i += 4) {
expect(pixels[i + 0]).to.be.within(pixels[0] - 2, pixels[0] + 2);
@@ -90,5 +113,4 @@ describe('ol.reproj.Image', function() {
});
image.load();
});
});