Merge pull request #12102 from simonseyock/update-ol-eslint

Update eslint-config-openlayers
This commit is contained in:
Tim Schaub
2021-03-09 04:14:47 -07:00
committed by GitHub
11 changed files with 860 additions and 331 deletions
+628 -109
View File
File diff suppressed because it is too large Load Diff
+1 -8
View File
@@ -63,7 +63,7 @@
"copy-webpack-plugin": "^6.0.1", "copy-webpack-plugin": "^6.0.1",
"coveralls": "3.1.0", "coveralls": "3.1.0",
"eslint": "^7.2.0", "eslint": "^7.2.0",
"eslint-config-openlayers": "^14.0.0", "eslint-config-openlayers": "^15.0.0",
"expect.js": "0.3.1", "expect.js": "0.3.1",
"express": "^4.17.1", "express": "^4.17.1",
"front-matter": "^4.0.0", "front-matter": "^4.0.0",
@@ -116,13 +116,6 @@
"@openlayers" "@openlayers"
], ],
"rules": { "rules": {
"valid-jsdoc": "off",
"@openlayers/valid-tsdoc": [
"error",
{
"requireReturn": false
}
],
"@openlayers/no-exclusive-tests": [ "@openlayers/no-exclusive-tests": [
"error", "error",
{ {
+4 -4
View File
@@ -12,10 +12,10 @@ import {listen, unlistenByKey} from './events.js';
/** /**
* @typedef {Object} PointerEventData * @typedef {Object} PointerEventData
* @property {string} type * @property {string} type The type of the pointer event.
* @property {number} clientX * @property {number} clientX ClientX.
* @property {number} clientY * @property {number} clientY ClientY.
* @property {EventTarget} target * @property {EventTarget} target The target of the event.
*/ */
class MapBrowserEventHandler extends Target { class MapBrowserEventHandler extends Target {
+13 -12
View File
@@ -1473,19 +1473,20 @@ class Modify extends PointerInteraction {
* @private * @private
*/ */
updateSegmentIndices_(geometry, index, depth, delta) { updateSegmentIndices_(geometry, index, depth, delta) {
this.rBush_.forEachInExtent(geometry.getExtent(), function ( this.rBush_.forEachInExtent(
segmentDataMatch geometry.getExtent(),
) { function (segmentDataMatch) {
if ( if (
segmentDataMatch.geometry === geometry && segmentDataMatch.geometry === geometry &&
(depth === undefined || (depth === undefined ||
segmentDataMatch.depth === undefined || segmentDataMatch.depth === undefined ||
equals(segmentDataMatch.depth, depth)) && equals(segmentDataMatch.depth, depth)) &&
segmentDataMatch.index > index segmentDataMatch.index > index
) { ) {
segmentDataMatch.index += delta; segmentDataMatch.index += delta;
}
} }
}); );
} }
} }
+1 -1
View File
@@ -362,7 +362,7 @@ class TileGrid {
/** /**
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate. * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {number} z Integer zoom level. * @param {number} z Integer zoom level.
* @param {import("../TileRange.js").default=} opt_tileRange Temporary import("../TileRange.js").default object. * @param {import("../TileRange.js").default} [opt_tileRange] Temporary import("../TileRange.js").default object.
* @return {import("../TileRange.js").default} Tile range. * @return {import("../TileRange.js").default} Tile range.
*/ */
getTileRangeForTileCoordAndZ(tileCoord, z, opt_tileRange) { getTileRangeForTileCoordAndZ(tileCoord, z, opt_tileRange) {
+36 -35
View File
@@ -342,43 +342,44 @@ describe('ol.format.GeoJSON', function () {
}); });
it('parses countries.geojson', function (done) { it('parses countries.geojson', function (done) {
afterLoadText('spec/ol/format/geojson/countries.geojson', function ( afterLoadText(
text 'spec/ol/format/geojson/countries.geojson',
) { function (text) {
const result = format.readFeatures(text); const result = format.readFeatures(text);
expect(result.length).to.be(179); expect(result.length).to.be(179);
const first = result[0]; const first = result[0];
expect(first).to.be.a(Feature); expect(first).to.be.a(Feature);
expect(first.get('name')).to.be('Afghanistan'); expect(first.get('name')).to.be('Afghanistan');
expect(first.getId()).to.be('AFG'); expect(first.getId()).to.be('AFG');
const firstGeom = first.getGeometry(); const firstGeom = first.getGeometry();
expect(firstGeom).to.be.a(Polygon); expect(firstGeom).to.be.a(Polygon);
expect( expect(
equals(firstGeom.getExtent(), [ equals(firstGeom.getExtent(), [
60.52843, 60.52843,
29.318572, 29.318572,
75.158028, 75.158028,
38.486282, 38.486282,
]) ])
).to.be(true); ).to.be(true);
const last = result[178]; const last = result[178];
expect(last).to.be.a(Feature); expect(last).to.be.a(Feature);
expect(last.get('name')).to.be('Zimbabwe'); expect(last.get('name')).to.be('Zimbabwe');
expect(last.getId()).to.be('ZWE'); expect(last.getId()).to.be('ZWE');
const lastGeom = last.getGeometry(); const lastGeom = last.getGeometry();
expect(lastGeom).to.be.a(Polygon); expect(lastGeom).to.be.a(Polygon);
expect( expect(
equals(lastGeom.getExtent(), [ equals(lastGeom.getExtent(), [
25.264226, 25.264226,
-22.271612, -22.271612,
32.849861, 32.849861,
-15.507787, -15.507787,
]) ])
).to.be(true); ).to.be(true);
done(); done();
}); }
);
}); });
it('generates an array of features for Feature', function () { it('generates an array of features for Feature', function () {
+37 -34
View File
@@ -1663,19 +1663,20 @@ describe('ol.format.GML3', function () {
describe('when parsing multiple feature types', function () { describe('when parsing multiple feature types', function () {
let features; let features;
before(function (done) { before(function (done) {
afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function ( afterLoadText(
xml 'spec/ol/format/gml/multiple-typenames.xml',
) { function (xml) {
try { try {
features = new GML({ features = new GML({
featureNS: 'http://localhost:8080/official', featureNS: 'http://localhost:8080/official',
featureType: ['planet_osm_polygon', 'planet_osm_line'], featureType: ['planet_osm_polygon', 'planet_osm_line'],
}).readFeatures(xml); }).readFeatures(xml);
} catch (e) { } catch (e) {
done(e); done(e);
}
done();
} }
done(); );
});
}); });
it('reads all features', function () { it('reads all features', function () {
@@ -1686,16 +1687,17 @@ describe('ol.format.GML3', function () {
describe('when parsing multiple feature types', function () { describe('when parsing multiple feature types', function () {
let features; let features;
before(function (done) { before(function (done) {
afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function ( afterLoadText(
xml 'spec/ol/format/gml/multiple-typenames.xml',
) { function (xml) {
try { try {
features = new GML().readFeatures(xml); features = new GML().readFeatures(xml);
} catch (e) { } catch (e) {
done(e); done(e);
}
done();
} }
done(); );
});
}); });
it('reads all features with autoconfigure', function () { it('reads all features with autoconfigure', function () {
@@ -1750,20 +1752,21 @@ describe('ol.format.GML3', function () {
describe('when parsing srsDimension from WFS (Geoserver)', function () { describe('when parsing srsDimension from WFS (Geoserver)', function () {
let features, feature; let features, feature;
before(function (done) { before(function (done) {
afterLoadText('spec/ol/format/gml/geoserver3DFeatures.xml', function ( afterLoadText(
xml 'spec/ol/format/gml/geoserver3DFeatures.xml',
) { function (xml) {
try { try {
const config = { const config = {
'featureNS': 'http://www.opengeospatial.net/cite', 'featureNS': 'http://www.opengeospatial.net/cite',
'featureType': 'geoserver_layer', 'featureType': 'geoserver_layer',
}; };
features = new GML(config).readFeatures(xml); features = new GML(config).readFeatures(xml);
} catch (e) { } catch (e) {
done(e); done(e);
}
done();
} }
done(); );
});
}); });
it('creates 3 features', function () { it('creates 3 features', function () {
+71 -64
View File
@@ -152,12 +152,13 @@ describe('ol.format.WFS', function () {
describe('when parsing FeatureCollection', function () { describe('when parsing FeatureCollection', function () {
let xml; let xml;
before(function (done) { before(function (done) {
afterLoadText('spec/ol/format/wfs/EmptyFeatureCollection.xml', function ( afterLoadText(
_xml 'spec/ol/format/wfs/EmptyFeatureCollection.xml',
) { function (_xml) {
xml = _xml; xml = _xml;
done(); done();
}); }
);
}); });
it('returns an empty array of features when none exist', function () { it('returns an empty array of features when none exist', function () {
const result = new WFS().readFeatures(xml); const result = new WFS().readFeatures(xml);
@@ -215,16 +216,17 @@ describe('ol.format.WFS', function () {
describe('when parsing TransactionResponse', function () { describe('when parsing TransactionResponse', function () {
let response; let response;
before(function (done) { before(function (done) {
afterLoadText('spec/ol/format/wfs/TransactionResponse.xml', function ( afterLoadText(
xml 'spec/ol/format/wfs/TransactionResponse.xml',
) { function (xml) {
try { try {
response = new WFS().readTransactionResponse(xml); response = new WFS().readTransactionResponse(xml);
} catch (e) { } catch (e) {
done(e); done(e);
}
done();
} }
done(); );
});
}); });
it('returns the correct TransactionResponse object', function () { it('returns the correct TransactionResponse object', function () {
expect(response.transactionSummary.totalDeleted).to.equal(0); expect(response.transactionSummary.totalDeleted).to.equal(0);
@@ -1241,12 +1243,13 @@ describe('ol.format.WFS', function () {
describe('when writing out a Transaction request', function () { describe('when writing out a Transaction request', function () {
let text; let text;
before(function (done) { before(function (done) {
afterLoadText('spec/ol/format/wfs/TransactionMulti_3D.xml', function ( afterLoadText(
xml 'spec/ol/format/wfs/TransactionMulti_3D.xml',
) { function (xml) {
text = xml; text = xml;
done(); done();
}); }
);
}); });
it('handles 3D in WFS 1.1.0', function () { it('handles 3D in WFS 1.1.0', function () {
@@ -1283,12 +1286,13 @@ describe('ol.format.WFS', function () {
describe('when writing out a GetFeature request', function () { describe('when writing out a GetFeature request', function () {
let text; let text;
before(function (done) { before(function (done) {
afterLoadText('spec/ol/format/wfs/GetFeatureMultiple.xml', function ( afterLoadText(
xml 'spec/ol/format/wfs/GetFeatureMultiple.xml',
) { function (xml) {
text = xml; text = xml;
done(); done();
}); }
);
}); });
it('handles writing multiple Query elements', function () { it('handles writing multiple Query elements', function () {
@@ -1335,19 +1339,20 @@ describe('ol.format.WFS', function () {
describe('when parsing multiple feature types', function () { describe('when parsing multiple feature types', function () {
let features; let features;
before(function (done) { before(function (done) {
afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function ( afterLoadText(
xml 'spec/ol/format/gml/multiple-typenames.xml',
) { function (xml) {
try { try {
features = new WFS({ features = new WFS({
featureNS: 'http://localhost:8080/official', featureNS: 'http://localhost:8080/official',
featureType: ['planet_osm_polygon', 'planet_osm_line'], featureType: ['planet_osm_polygon', 'planet_osm_line'],
}).readFeatures(xml); }).readFeatures(xml);
} catch (e) { } catch (e) {
done(e); done(e);
}
done();
} }
done(); );
});
}); });
it('reads all features', function () { it('reads all features', function () {
@@ -1358,23 +1363,24 @@ describe('ol.format.WFS', function () {
describe('when parsing multiple feature types separately', function () { describe('when parsing multiple feature types separately', function () {
let lineFeatures, polygonFeatures; let lineFeatures, polygonFeatures;
before(function (done) { before(function (done) {
afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function ( afterLoadText(
xml 'spec/ol/format/gml/multiple-typenames.xml',
) { function (xml) {
try { try {
lineFeatures = new WFS({ lineFeatures = new WFS({
featureNS: 'http://localhost:8080/official', featureNS: 'http://localhost:8080/official',
featureType: ['planet_osm_line'], featureType: ['planet_osm_line'],
}).readFeatures(xml); }).readFeatures(xml);
polygonFeatures = new WFS({ polygonFeatures = new WFS({
featureNS: 'http://localhost:8080/official', featureNS: 'http://localhost:8080/official',
featureType: ['planet_osm_polygon'], featureType: ['planet_osm_polygon'],
}).readFeatures(xml); }).readFeatures(xml);
} catch (e) { } catch (e) {
done(e); done(e);
}
done();
} }
done(); );
});
}); });
it('reads all features', function () { it('reads all features', function () {
@@ -1386,16 +1392,17 @@ describe('ol.format.WFS', function () {
describe('when parsing multiple feature types', function () { describe('when parsing multiple feature types', function () {
let features; let features;
before(function (done) { before(function (done) {
afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function ( afterLoadText(
xml 'spec/ol/format/gml/multiple-typenames.xml',
) { function (xml) {
try { try {
features = new WFS().readFeatures(xml); features = new WFS().readFeatures(xml);
} catch (e) { } catch (e) {
done(e); done(e);
}
done();
} }
done(); );
});
}); });
it('reads all features with autoconfigure', function () { it('reads all features with autoconfigure', function () {
+24 -20
View File
@@ -885,11 +885,12 @@ describe('ol.interaction.Modify', function () {
let firstSegmentData; let firstSegmentData;
firstSegmentData = modify.rBush_.forEachInExtent([0, 0, 5, 5], function ( firstSegmentData = modify.rBush_.forEachInExtent(
node [0, 0, 5, 5],
) { function (node) {
return node; return node;
}); }
);
expect(firstSegmentData.segment[0]).to.eql([10, 10]); expect(firstSegmentData.segment[0]).to.eql([10, 10]);
expect(firstSegmentData.segment[1]).to.eql([10, 10]); expect(firstSegmentData.segment[1]).to.eql([10, 10]);
@@ -898,11 +899,12 @@ describe('ol.interaction.Modify', function () {
center[1] = 1; center[1] = 1;
feature.getGeometry().setCenter(center); feature.getGeometry().setCenter(center);
firstSegmentData = modify.rBush_.forEachInExtent([0, 0, 5, 5], function ( firstSegmentData = modify.rBush_.forEachInExtent(
node [0, 0, 5, 5],
) { function (node) {
return node; return node;
}); }
);
expect(firstSegmentData.segment[0]).to.eql([1, 1]); expect(firstSegmentData.segment[0]).to.eql([1, 1]);
expect(firstSegmentData.segment[1]).to.eql([1, 1]); expect(firstSegmentData.segment[1]).to.eql([1, 1]);
@@ -924,11 +926,12 @@ describe('ol.interaction.Modify', function () {
let firstSegmentData; let firstSegmentData;
firstSegmentData = modify.rBush_.forEachInExtent([0, 0, 5, 5], function ( firstSegmentData = modify.rBush_.forEachInExtent(
node [0, 0, 5, 5],
) { function (node) {
return node; return node;
}); }
);
expect(firstSegmentData.segment[0]).to.eql([0, 0]); expect(firstSegmentData.segment[0]).to.eql([0, 0]);
expect(firstSegmentData.segment[1]).to.eql([10, 20]); expect(firstSegmentData.segment[1]).to.eql([10, 20]);
@@ -938,11 +941,12 @@ describe('ol.interaction.Modify', function () {
firstVertex[1] = 1; firstVertex[1] = 1;
feature.getGeometry().setCoordinates(coordinates); feature.getGeometry().setCoordinates(coordinates);
firstSegmentData = modify.rBush_.forEachInExtent([0, 0, 5, 5], function ( firstSegmentData = modify.rBush_.forEachInExtent(
node [0, 0, 5, 5],
) { function (node) {
return node; return node;
}); }
);
expect(firstSegmentData.segment[0]).to.eql([1, 1]); expect(firstSegmentData.segment[0]).to.eql([1, 1]);
expect(firstSegmentData.segment[1]).to.eql([10, 20]); expect(firstSegmentData.segment[1]).to.eql([10, 20]);
+10 -9
View File
@@ -354,16 +354,17 @@ describe('ol.source.WMTS', function () {
const parser = new WMTSCapabilities(); const parser = new WMTSCapabilities();
let capabilities; let capabilities;
before(function (done) { before(function (done) {
afterLoadText('spec/ol/format/wmts/capabilities_wgs84.xml', function ( afterLoadText(
xml 'spec/ol/format/wmts/capabilities_wgs84.xml',
) { function (xml) {
try { try {
capabilities = parser.read(xml); capabilities = parser.read(xml);
} catch (e) { } catch (e) {
done(e); done(e);
}
done();
} }
done(); );
});
}); });
it('returns correct bounding box', function () { it('returns correct bounding box', function () {
+35 -35
View File
@@ -616,21 +616,21 @@ describe('ol.tilegrid.TileGrid', function () {
const tileCoord = [5, 11, 21]; const tileCoord = [5, 11, 21];
const zs = []; const zs = [];
const tileRanges = []; const tileRanges = [];
tileGrid.forEachTileCoordParentTileRange(tileCoord, function ( tileGrid.forEachTileCoordParentTileRange(
z, tileCoord,
tileRange function (z, tileRange) {
) { zs.push(z);
zs.push(z); tileRanges.push(
tileRanges.push( new TileRange(
new TileRange( tileRange.minX,
tileRange.minX, tileRange.maxX,
tileRange.maxX, tileRange.minY,
tileRange.minY, tileRange.maxY
tileRange.maxY )
) );
); return false;
return false; }
}); );
expect(zs.length).to.eql(5); expect(zs.length).to.eql(5);
expect(tileRanges.length).to.eql(5); expect(tileRanges.length).to.eql(5);
@@ -1061,14 +1061,14 @@ describe('ol.tilegrid.TileGrid', function () {
const zs = []; const zs = [];
const tileRanges = []; const tileRanges = [];
tileGrid.forEachTileCoordParentTileRange([3, 7, 3], function ( tileGrid.forEachTileCoordParentTileRange(
z, [3, 7, 3],
tileRange function (z, tileRange) {
) { zs.push(z);
zs.push(z); tileRanges.push(tileRange);
tileRanges.push(tileRange); return false;
return false; }
}); );
expect(zs.length).to.eql(3); expect(zs.length).to.eql(3);
expect(tileRanges.length).to.eql(3); expect(tileRanges.length).to.eql(3);
@@ -1219,17 +1219,17 @@ describe('ol.tilegrid.TileGrid', function () {
}); });
const tileCoord = [15, 6239, 11751]; const tileCoord = [15, 6239, 11751];
tileGrid.forEachTileCoordParentTileRange(tileCoord, function ( tileGrid.forEachTileCoordParentTileRange(
z, tileCoord,
tileRange function (z, tileRange) {
) { it(`works for level ${z}`, function () {
it(`works for level ${z}`, function () { const range = tileGrid.getTileRangeForTileCoordAndZ(tileCoord, z);
const range = tileGrid.getTileRangeForTileCoordAndZ(tileCoord, z); expect(range.minX).to.be(tileRange.minX);
expect(range.minX).to.be(tileRange.minX); expect(range.maxX).to.be(tileRange.maxX);
expect(range.maxX).to.be(tileRange.maxX); expect(range.minY).to.be(tileRange.minY);
expect(range.minY).to.be(tileRange.minY); expect(range.maxY).to.be(tileRange.maxY);
expect(range.maxY).to.be(tileRange.maxY); });
}); }
}); );
}); });
}); });