diff --git a/biome.json b/biome.json index dabb2cce..fe1b09d4 100644 --- a/biome.json +++ b/biome.json @@ -15,6 +15,9 @@ "style": { "useBlockStatements": "off", "noShoutyConstants": "warn" + }, + "performance": { + "noDelete": "off" } } }, diff --git a/umap/static/umap/js/umap.features.js b/umap/static/umap/js/umap.features.js index 061030f6..c2764884 100644 --- a/umap/static/umap/js/umap.features.js +++ b/umap/static/umap/js/umap.features.js @@ -312,7 +312,7 @@ U.FeatureMixin = { // Retrocompat if (this.properties._umap_options.clickable === false) { this.properties._umap_options.interactive = false - this.properties._umap_options.clickable = undefined + delete this.properties._umap_options.clickable } }, @@ -377,7 +377,7 @@ U.FeatureMixin = { const properties = L.extend({}, this.properties) properties._umap_options = L.extend({}, properties._umap_options) if (Object.keys && Object.keys(properties._umap_options).length === 0) { - properties._umap_options = undefined // It can make a difference on big data sets + delete properties._umap_options // It can make a difference on big data sets } return properties }, @@ -396,7 +396,6 @@ U.FeatureMixin = { const geojson = this.parentClass.prototype.toGeoJSON.call(this) geojson.properties = this.cloneProperties() geojson.id = this.id - // biome-ignore lint/performance/noDelete: we do not want the key at all. delete geojson.properties._storage_options return geojson }, @@ -579,8 +578,8 @@ U.FeatureMixin = { clone: function () { const geoJSON = this.toGeoJSON() - geoJSON.id = undefined - geoJSON.properties.id = undefined + delete geoJSON.id + delete geoJSON.properties.id const layer = this.datalayer.geojsonToFeatures(geoJSON) layer.isDirty = true layer.edit() @@ -1100,7 +1099,7 @@ U.Polyline = L.Polyline.extend({ U.Utils.flattenCoordinates(geojson.geometry.coordinates), ] - geojson.id = undefined // delete the copied id, a new one will be generated. + delete geojson.id // delete the copied id, a new one will be generated. const polygon = this.datalayer.geojsonToFeatures(geojson) polygon.edit() @@ -1235,8 +1234,8 @@ U.Polygon = L.Polygon.extend({ toPolyline: function () { const geojson = this.toGeoJSON() - geojson.id = undefined - geojson.properties.id = undefined + delete geojson.id + delete geojson.properties.id geojson.geometry.type = 'LineString' geojson.geometry.coordinates = U.Utils.flattenCoordinates( geojson.geometry.coordinates diff --git a/umap/static/umap/js/umap.forms.js b/umap/static/umap/js/umap.forms.js index 1243b466..0d698624 100644 --- a/umap/static/umap/js/umap.forms.js +++ b/umap/static/umap/js/umap.forms.js @@ -1133,7 +1133,7 @@ U.FormBuilder = L.FormBuilder.extend({ } } // FormBuilder use this key for the input type itself - schema.type = undefined + delete schema.type this.defaultOptions[key] = schema } }, diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index b3ca3b5c..79348124 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -104,7 +104,7 @@ U.Map = L.Map.extend({ } if (this.options.advancedFilterKey) { this.options.facetKey = this.options.advancedFilterKey - this.options.advancedFilterKey = undefined + delete this.options.advancedFilterKey } // Global storage for retrieving datalayers and features @@ -130,14 +130,14 @@ U.Map = L.Map.extend({ if (!this.options.onLoadPanel) { this.options.onLoadPanel = 'caption' } - this.options.displayCaptionOnLoad = undefined + delete this.options.displayCaptionOnLoad } if (this.options.displayDataBrowserOnLoad) { // Retrocompat if (!this.options.onLoadPanel) { this.options.onLoadPanel = 'databrowser' } - this.options.displayDataBrowserOnLoad = undefined + delete this.options.displayDataBrowserOnLoad } if (this.options.datalayersControl === 'expanded') { this.options.onLoadPanel = 'datalayers' @@ -901,7 +901,7 @@ U.Map = L.Map.extend({ importedData.layers.forEach((geojson) => { if (!geojson._umap_options && geojson._storage) { geojson._umap_options = geojson._storage - geojson._storage = undefined + delete geojson._storage } delete geojson._umap_options?.id // Never trust an id at this stage const dataLayer = this.createDataLayer(geojson._umap_options) diff --git a/umap/static/umap/js/umap.layer.js b/umap/static/umap/js/umap.layer.js index e1e9432f..2d4d0133 100644 --- a/umap/static/umap/js/umap.layer.js +++ b/umap/static/umap/js/umap.layer.js @@ -568,11 +568,11 @@ U.DataLayer = L.Evented.extend({ // Retrocompat if (this.options.remoteData?.from) { this.options.fromZoom = this.options.remoteData.from - this.options.remoteData.from = undefined + delete this.options.remoteData.from } if (this.options.remoteData?.to) { this.options.toZoom = this.options.remoteData.to - this.options.remoteData.to = undefined + delete this.options.remoteData.to } this.backupOptions() this.connectToMap() @@ -834,7 +834,7 @@ U.DataLayer = L.Evented.extend({ }, setOptions: function (options) { - options.geojson = undefined + delete options.geojson this.options = U.Utils.CopyJSON(U.DataLayer.prototype.options) // Start from fresh. this.updateOptions(options) }, @@ -1202,7 +1202,7 @@ U.DataLayer = L.Evented.extend({ clone: function () { const options = U.Utils.CopyJSON(this.options) options.name = L._('Clone of {name}', { name: this.options.name }) - options.id = undefined + delete options.id const geojson = U.Utils.CopyJSON(this._geojson) const datalayer = this.map.createDataLayer(options) datalayer.fromGeoJSON(geojson) @@ -1222,8 +1222,8 @@ U.DataLayer = L.Evented.extend({ this.map.off('zoomend', this.onZoomEnd, this) this.off() this.clear() - this._loaded = undefined - this._dataloaded = undefined + delete this._loaded + delete this._dataloaded }, reset: function () { @@ -1701,7 +1701,7 @@ U.DataLayer = L.Evented.extend({ if (data.geojson) { this.clear() this.fromGeoJSON(data.geojson) - data.geojson = undefined + delete data.geojson } this._reference_version = response.headers.get('X-Datalayer-Version') this.sync.update('_reference_version', this._reference_version) diff --git a/umap/static/umap/js/umap.share.js b/umap/static/umap/js/umap.share.js index 567b8fd0..a2ab6106 100644 --- a/umap/static/umap/js/umap.share.js +++ b/umap/static/umap/js/umap.share.js @@ -21,7 +21,6 @@ U.Share = L.Class.extend({ map.eachFeature((feature) => { const row = feature.toGeoJSON().properties const center = feature.getCenter() - // biome-ignore lint/performance/noDelete: we do not want the key at all. delete row._umap_options row.Latitude = center.lat row.Longitude = center.lng @@ -225,7 +224,7 @@ U.IframeExporter = L.Evented.extend({ if (this.options.viewCurrentFeature && this.map.currentFeature) { this.queryString.feature = this.map.currentFeature.getSlug() } else { - this.queryString.feature = undefined + delete this.queryString.feature } if (this.options.keepCurrentDatalayers) { this.map.eachDataLayer((datalayer) => { @@ -235,7 +234,7 @@ U.IframeExporter = L.Evented.extend({ }) this.queryString.datalayers = datalayers.join(',') } else { - this.queryString.datalayers = undefined + delete this.queryString.datalayers } const currentView = this.options.currentView ? window.location.hash : '' const queryString = L.extend({}, this.queryString, options) diff --git a/umap/static/umap/test/DataLayer.js b/umap/static/umap/test/DataLayer.js index 26ba7d61..201f8a7f 100644 --- a/umap/static/umap/test/DataLayer.js +++ b/umap/static/umap/test/DataLayer.js @@ -316,7 +316,7 @@ describe('U.DataLayer', () => { let icon = qs('div.umap-div-icon .icon_container') poly.properties.mycolor = 'DarkGoldenRod' marker.properties.mycolor = 'DarkRed' - marker.properties._umap_options.color = undefined + delete marker.properties._umap_options.color assert.notOk(qs('path[fill="DarkGoldenRod"]')) assert.equal(icon.style.backgroundColor, 'olivedrab') datalayer.options.color = '{mycolor}'