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:
@@ -1,16 +1,14 @@
|
||||
import {
|
||||
getKey,
|
||||
fromKey,
|
||||
hash,
|
||||
withinExtentAndZ
|
||||
} from '../../../src/ol/tilecoord.js';
|
||||
import TileGrid from '../../../src/ol/tilegrid/TileGrid.js';
|
||||
import {
|
||||
fromKey,
|
||||
getKey,
|
||||
hash,
|
||||
withinExtentAndZ,
|
||||
} from '../../../src/ol/tilecoord.js';
|
||||
|
||||
|
||||
describe('ol.TileCoord', function() {
|
||||
|
||||
describe('create', function() {
|
||||
it('sets x y z properties as expected', function() {
|
||||
describe('ol.TileCoord', function () {
|
||||
describe('create', function () {
|
||||
it('sets x y z properties as expected', function () {
|
||||
const tileCoord = [1, 2, 3];
|
||||
expect(tileCoord[0]).to.eql(1);
|
||||
expect(tileCoord[1]).to.eql(2);
|
||||
@@ -18,15 +16,15 @@ describe('ol.TileCoord', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('getKey()', function() {
|
||||
it('returns a key for a tile coord', function() {
|
||||
describe('getKey()', function () {
|
||||
it('returns a key for a tile coord', function () {
|
||||
const key = getKey([1, 2, 3]);
|
||||
expect(key).to.eql('1/2/3');
|
||||
});
|
||||
});
|
||||
|
||||
describe('fromKey()', function() {
|
||||
it('returns a tile coord given a key', function() {
|
||||
describe('fromKey()', function () {
|
||||
it('returns a tile coord given a key', function () {
|
||||
const tileCoord = [1, 2, 3];
|
||||
const key = getKey(tileCoord);
|
||||
|
||||
@@ -35,47 +33,45 @@ describe('ol.TileCoord', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('hash', function() {
|
||||
it('produces different hashes for different tile coords', function() {
|
||||
describe('hash', function () {
|
||||
it('produces different hashes for different tile coords', function () {
|
||||
const tileCoord1 = [3, 2, 1];
|
||||
const tileCoord2 = [3, 1, 1];
|
||||
expect(hash(tileCoord1)).not.to.eql(
|
||||
hash(tileCoord2));
|
||||
expect(hash(tileCoord1)).not.to.eql(hash(tileCoord2));
|
||||
});
|
||||
});
|
||||
|
||||
describe('withinExtentAndZ', function() {
|
||||
|
||||
it('restricts by z', function() {
|
||||
describe('withinExtentAndZ', function () {
|
||||
it('restricts by z', function () {
|
||||
const tileGrid = new TileGrid({
|
||||
extent: [10, 20, 30, 40],
|
||||
tileSize: 10,
|
||||
resolutions: [2, 1],
|
||||
minZoom: 1
|
||||
minZoom: 1,
|
||||
});
|
||||
expect(withinExtentAndZ([0, 0, 0], tileGrid)).to.be(false);
|
||||
expect(withinExtentAndZ([1, 0, 0], tileGrid)).to.be(true);
|
||||
expect(withinExtentAndZ([2, 0, 0], tileGrid)).to.be(false);
|
||||
});
|
||||
|
||||
it('restricts by extent when extent defines tile ranges', function() {
|
||||
it('restricts by extent when extent defines tile ranges', function () {
|
||||
const tileGrid = new TileGrid({
|
||||
extent: [10, 20, 30, 40],
|
||||
sizes: [[3, -3]],
|
||||
tileSize: 10,
|
||||
resolutions: [1]
|
||||
resolutions: [1],
|
||||
});
|
||||
expect(withinExtentAndZ([0, 1, 1], tileGrid)).to.be(true);
|
||||
expect(withinExtentAndZ([0, 2, 0], tileGrid)).to.be(false);
|
||||
expect(withinExtentAndZ([0, 0, 2], tileGrid)).to.be(false);
|
||||
});
|
||||
|
||||
it('restricts by extent when sizes define tile ranges', function() {
|
||||
it('restricts by extent when sizes define tile ranges', function () {
|
||||
const tileGrid = new TileGrid({
|
||||
origin: [10, 20],
|
||||
sizes: [[3, 3]],
|
||||
tileSize: 10,
|
||||
resolutions: [1]
|
||||
resolutions: [1],
|
||||
});
|
||||
expect(withinExtentAndZ([0, 0, 0], tileGrid)).to.be(true);
|
||||
expect(withinExtentAndZ([0, 1, 0], tileGrid)).to.be(true);
|
||||
@@ -101,12 +97,12 @@ describe('ol.TileCoord', function() {
|
||||
expect(withinExtentAndZ([0, 2, 3], tileGrid)).to.be(false);
|
||||
});
|
||||
|
||||
it('restricts by extent when sizes (neg y) define tile ranges', function() {
|
||||
it('restricts by extent when sizes (neg y) define tile ranges', function () {
|
||||
const tileGrid = new TileGrid({
|
||||
origin: [10, 40],
|
||||
sizes: [[3, -3]],
|
||||
tileSize: 10,
|
||||
resolutions: [1]
|
||||
resolutions: [1],
|
||||
});
|
||||
expect(withinExtentAndZ([0, 0, -1], tileGrid)).to.be(true);
|
||||
expect(withinExtentAndZ([0, 1, -1], tileGrid)).to.be(true);
|
||||
@@ -132,11 +128,11 @@ describe('ol.TileCoord', function() {
|
||||
expect(withinExtentAndZ([0, 2, -4], tileGrid)).to.be(false);
|
||||
});
|
||||
|
||||
it('does not restrict by extent with no extent or sizes', function() {
|
||||
it('does not restrict by extent with no extent or sizes', function () {
|
||||
const tileGrid = new TileGrid({
|
||||
origin: [10, 20],
|
||||
tileSize: 10,
|
||||
resolutions: [1]
|
||||
resolutions: [1],
|
||||
});
|
||||
expect(withinExtentAndZ([0, Infinity, -1], tileGrid)).to.be(true);
|
||||
expect(withinExtentAndZ([0, 0, Infinity], tileGrid)).to.be(true);
|
||||
@@ -144,5 +140,4 @@ describe('ol.TileCoord', function() {
|
||||
expect(withinExtentAndZ([0, 0, Infinity], tileGrid)).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user