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,14 +1,11 @@
import WMTSCapabilities from '../../../../src/ol/format/WMTSCapabilities.js';
describe('ol.format.WMTSCapabilities', function() {
describe('when parsing ogcsample.xml', function() {
describe('ol.format.WMTSCapabilities', function () {
describe('when parsing ogcsample.xml', function () {
const parser = new WMTSCapabilities();
let capabilities;
before(function(done) {
afterLoadText('spec/ol/format/wmts/ogcsample.xml', function(xml) {
before(function (done) {
afterLoadText('spec/ol/format/wmts/ogcsample.xml', function (xml) {
try {
capabilities = parser.read(xml);
} catch (e) {
@@ -18,15 +15,14 @@ describe('ol.format.WMTSCapabilities', function() {
});
});
it('can read Capability.Contents.Layer', function() {
it('can read Capability.Contents.Layer', function () {
expect(capabilities.Contents.Layer).to.be.an('array');
expect(capabilities.Contents.Layer).to.have.length(1);
const layer = capabilities.Contents.Layer[0];
expect(layer.Abstract).to.be
.eql('Blue Marble Next Generation NASA Product');
expect(layer.Abstract).to.be.eql(
'Blue Marble Next Generation NASA Product'
);
expect(layer.Identifier).to.be.eql('BlueMarbleNextGeneration');
expect(layer.Title).to.be.eql('Blue Marble Next Generation');
@@ -48,19 +44,20 @@ describe('ol.format.WMTSCapabilities', function() {
expect(layer.Style[0].Identifier).to.be.eql('DarkBlue');
expect(layer.Style[0].isDefault).to.be(true);
expect(layer.Style[0].Title).to.be.eql('Dark Blue');
expect(layer.Style[0].LegendURL[0].href).to.be
.eql('http://www.miramon.uab.es/wmts/Coastlines/' +
'coastlines_darkBlue.png');
expect(layer.Style[0].LegendURL[0].href).to.be.eql(
'http://www.miramon.uab.es/wmts/Coastlines/' + 'coastlines_darkBlue.png'
);
expect(layer.Style[0].LegendURL[0].format).to.be.eql('image/png');
expect(layer.TileMatrixSetLink).to.be.an('array');
expect(layer.TileMatrixSetLink).to.have.length(3);
expect(layer.TileMatrixSetLink[0].TileMatrixSet).to.be
.eql('BigWorldPixel');
expect(layer.TileMatrixSetLink[1].TileMatrixSet).to.be
.eql('google3857');
expect(layer.TileMatrixSetLink[2].TileMatrixSet).to.be
.eql('google3857subset');
expect(layer.TileMatrixSetLink[0].TileMatrixSet).to.be.eql(
'BigWorldPixel'
);
expect(layer.TileMatrixSetLink[1].TileMatrixSet).to.be.eql('google3857');
expect(layer.TileMatrixSetLink[2].TileMatrixSet).to.be.eql(
'google3857subset'
);
const wgs84Bbox = layer.WGS84BoundingBox;
expect(wgs84Bbox).to.be.an('array');
@@ -72,13 +69,13 @@ describe('ol.format.WMTSCapabilities', function() {
expect(layer.ResourceURL).to.be.an('array');
expect(layer.ResourceURL).to.have.length(2);
expect(layer.ResourceURL[0].format).to.be.eql('image/png');
expect(layer.ResourceURL[0].template).to.be
.eql('http://www.example.com/wmts/coastlines/{TileMatrix}' +
'/{TileRow}/{TileCol}.png');
expect(layer.ResourceURL[0].template).to.be.eql(
'http://www.example.com/wmts/coastlines/{TileMatrix}' +
'/{TileRow}/{TileCol}.png'
);
});
it('Can read Capabilities.Content.TileMatrixSet', function() {
it('Can read Capabilities.Content.TileMatrixSet', function () {
expect(capabilities.Contents.TileMatrixSet).to.be.ok();
const bigWorld = capabilities.Contents.TileMatrixSet[2];
@@ -104,24 +101,19 @@ describe('ol.format.WMTSCapabilities', function() {
expect(bigWorld.TileMatrix[1].TopLeftCorner).to.be.a('array');
expect(bigWorld.TileMatrix[1].TopLeftCorner[0]).to.be.eql(-180);
expect(bigWorld.TileMatrix[1].TopLeftCorner[1]).to.be.eql(84);
});
it('Can read OWS tags', function() {
it('Can read OWS tags', function () {
expect(capabilities.ServiceIdentification).to.be.ok();
expect(capabilities.OperationsMetadata).to.be.ok();
});
});
describe('when parsing ign.xml', function() {
describe('when parsing ign.xml', function () {
const parser = new WMTSCapabilities();
let capabilities;
before(function(done) {
afterLoadText('spec/ol/format/wmts/ign.xml', function(xml) {
before(function (done) {
afterLoadText('spec/ol/format/wmts/ign.xml', function (xml) {
try {
capabilities = parser.read(xml);
} catch (e) {
@@ -131,35 +123,53 @@ describe('ol.format.WMTSCapabilities', function() {
});
});
it('can read Capability.Contents.Layer', function() {
it('can read Capability.Contents.Layer', function () {
expect(capabilities.Contents.Layer).to.be.an('array');
expect(capabilities.Contents.Layer).to.have.length(1);
const layer = capabilities.Contents.Layer[0];
expect(layer.TileMatrixSetLink).to.be.an('array');
expect(layer.TileMatrixSetLink).to.have.length(2);
expect(layer.TileMatrixSetLink[0].TileMatrixSet).to.be.eql('PM');
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits).to.be.an('array');
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits).to.have.length(20);
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].TileMatrix).to.be.eql('0');
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MinTileRow).to.be.eql(0);
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MaxTileRow).to.be.eql(1);
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MinTileCol).to.be.eql(0);
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MaxTileCol).to.be.eql(1);
expect(
layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].TileMatrix
).to.be.eql('0');
expect(
layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MinTileRow
).to.be.eql(0);
expect(
layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MaxTileRow
).to.be.eql(1);
expect(
layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MinTileCol
).to.be.eql(0);
expect(
layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MaxTileCol
).to.be.eql(1);
expect(layer.TileMatrixSetLink[1].TileMatrixSet).to.be.eql('Prefixed');
expect(layer.TileMatrixSetLink[1].TileMatrixSetLimits).to.be.an('array');
expect(layer.TileMatrixSetLink[1].TileMatrixSetLimits).to.have.length(2);
expect(layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].TileMatrix).to.be.eql('Prefixed:0');
expect(layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].MinTileRow).to.be.eql(0);
expect(layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].MaxTileRow).to.be.eql(1);
expect(layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].MinTileCol).to.be.eql(0);
expect(layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].MaxTileCol).to.be.eql(1);
expect(
layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].TileMatrix
).to.be.eql('Prefixed:0');
expect(
layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].MinTileRow
).to.be.eql(0);
expect(
layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].MaxTileRow
).to.be.eql(1);
expect(
layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].MinTileCol
).to.be.eql(0);
expect(
layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].MaxTileCol
).to.be.eql(1);
});
it('Can read Capabilities.Content.TileMatrixSet', function() {
it('Can read Capabilities.Content.TileMatrixSet', function () {
expect(capabilities.Contents.TileMatrixSet).to.be.ok();
const pm = capabilities.Contents.TileMatrixSet[0];
@@ -170,8 +180,9 @@ describe('ol.format.WMTSCapabilities', function() {
expect(pm.TileMatrix[0].Identifier).to.be.eql('0');
expect(pm.TileMatrix[0].MatrixHeight).to.be.eql(1);
expect(pm.TileMatrix[0].MatrixWidth).to.be.eql(1);
expect(pm.TileMatrix[0].ScaleDenominator)
.to.be.eql(559082264.0287178958533332);
expect(pm.TileMatrix[0].ScaleDenominator).to.be.eql(
559082264.0287178958533332
);
expect(pm.TileMatrix[0].TileWidth).to.be.eql(256);
expect(pm.TileMatrix[0].TileHeight).to.be.eql(256);
expect(pm.TileMatrix[0].TopLeftCorner).to.be.a('array');
@@ -180,16 +191,14 @@ describe('ol.format.WMTSCapabilities', function() {
expect(pm.TileMatrix[1].Identifier).to.be.eql('1');
expect(pm.TileMatrix[1].MatrixHeight).to.be.eql(2);
expect(pm.TileMatrix[1].MatrixWidth).to.be.eql(2);
expect(pm.TileMatrix[1].ScaleDenominator)
.to.be.eql(279541132.0143588959472254);
expect(pm.TileMatrix[1].ScaleDenominator).to.be.eql(
279541132.0143588959472254
);
expect(pm.TileMatrix[1].TileWidth).to.be.eql(256);
expect(pm.TileMatrix[1].TileHeight).to.be.eql(256);
expect(pm.TileMatrix[1].TopLeftCorner).to.be.a('array');
expect(pm.TileMatrix[1].TopLeftCorner[0]).to.be.eql(-20037508);
expect(pm.TileMatrix[1].TopLeftCorner[1]).to.be.eql(20037508);
});
});
});