chore: remove the noDelete rule completely

This commit is contained in:
David Larlet 2024-06-25 21:31:37 -04:00
parent b819c554ee
commit c61ca9c506
No known key found for this signature in database
GPG key ID: 3E2953A359E7E7BD
7 changed files with 25 additions and 24 deletions

View file

@ -15,6 +15,9 @@
"style": { "style": {
"useBlockStatements": "off", "useBlockStatements": "off",
"noShoutyConstants": "warn" "noShoutyConstants": "warn"
},
"performance": {
"noDelete": "off"
} }
} }
}, },

View file

@ -312,7 +312,7 @@ U.FeatureMixin = {
// Retrocompat // Retrocompat
if (this.properties._umap_options.clickable === false) { if (this.properties._umap_options.clickable === false) {
this.properties._umap_options.interactive = 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) const properties = L.extend({}, this.properties)
properties._umap_options = L.extend({}, properties._umap_options) properties._umap_options = L.extend({}, properties._umap_options)
if (Object.keys && Object.keys(properties._umap_options).length === 0) { 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 return properties
}, },
@ -396,7 +396,6 @@ U.FeatureMixin = {
const geojson = this.parentClass.prototype.toGeoJSON.call(this) const geojson = this.parentClass.prototype.toGeoJSON.call(this)
geojson.properties = this.cloneProperties() geojson.properties = this.cloneProperties()
geojson.id = this.id geojson.id = this.id
// biome-ignore lint/performance/noDelete: we do not want the key at all.
delete geojson.properties._storage_options delete geojson.properties._storage_options
return geojson return geojson
}, },
@ -579,8 +578,8 @@ U.FeatureMixin = {
clone: function () { clone: function () {
const geoJSON = this.toGeoJSON() const geoJSON = this.toGeoJSON()
geoJSON.id = undefined delete geoJSON.id
geoJSON.properties.id = undefined delete geoJSON.properties.id
const layer = this.datalayer.geojsonToFeatures(geoJSON) const layer = this.datalayer.geojsonToFeatures(geoJSON)
layer.isDirty = true layer.isDirty = true
layer.edit() layer.edit()
@ -1100,7 +1099,7 @@ U.Polyline = L.Polyline.extend({
U.Utils.flattenCoordinates(geojson.geometry.coordinates), 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) const polygon = this.datalayer.geojsonToFeatures(geojson)
polygon.edit() polygon.edit()
@ -1235,8 +1234,8 @@ U.Polygon = L.Polygon.extend({
toPolyline: function () { toPolyline: function () {
const geojson = this.toGeoJSON() const geojson = this.toGeoJSON()
geojson.id = undefined delete geojson.id
geojson.properties.id = undefined delete geojson.properties.id
geojson.geometry.type = 'LineString' geojson.geometry.type = 'LineString'
geojson.geometry.coordinates = U.Utils.flattenCoordinates( geojson.geometry.coordinates = U.Utils.flattenCoordinates(
geojson.geometry.coordinates geojson.geometry.coordinates

View file

@ -1133,7 +1133,7 @@ U.FormBuilder = L.FormBuilder.extend({
} }
} }
// FormBuilder use this key for the input type itself // FormBuilder use this key for the input type itself
schema.type = undefined delete schema.type
this.defaultOptions[key] = schema this.defaultOptions[key] = schema
} }
}, },

View file

@ -104,7 +104,7 @@ U.Map = L.Map.extend({
} }
if (this.options.advancedFilterKey) { if (this.options.advancedFilterKey) {
this.options.facetKey = this.options.advancedFilterKey this.options.facetKey = this.options.advancedFilterKey
this.options.advancedFilterKey = undefined delete this.options.advancedFilterKey
} }
// Global storage for retrieving datalayers and features // Global storage for retrieving datalayers and features
@ -130,14 +130,14 @@ U.Map = L.Map.extend({
if (!this.options.onLoadPanel) { if (!this.options.onLoadPanel) {
this.options.onLoadPanel = 'caption' this.options.onLoadPanel = 'caption'
} }
this.options.displayCaptionOnLoad = undefined delete this.options.displayCaptionOnLoad
} }
if (this.options.displayDataBrowserOnLoad) { if (this.options.displayDataBrowserOnLoad) {
// Retrocompat // Retrocompat
if (!this.options.onLoadPanel) { if (!this.options.onLoadPanel) {
this.options.onLoadPanel = 'databrowser' this.options.onLoadPanel = 'databrowser'
} }
this.options.displayDataBrowserOnLoad = undefined delete this.options.displayDataBrowserOnLoad
} }
if (this.options.datalayersControl === 'expanded') { if (this.options.datalayersControl === 'expanded') {
this.options.onLoadPanel = 'datalayers' this.options.onLoadPanel = 'datalayers'
@ -901,7 +901,7 @@ U.Map = L.Map.extend({
importedData.layers.forEach((geojson) => { importedData.layers.forEach((geojson) => {
if (!geojson._umap_options && geojson._storage) { if (!geojson._umap_options && geojson._storage) {
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 delete geojson._umap_options?.id // Never trust an id at this stage
const dataLayer = this.createDataLayer(geojson._umap_options) const dataLayer = this.createDataLayer(geojson._umap_options)

View file

@ -568,11 +568,11 @@ U.DataLayer = L.Evented.extend({
// Retrocompat // Retrocompat
if (this.options.remoteData?.from) { if (this.options.remoteData?.from) {
this.options.fromZoom = 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) { if (this.options.remoteData?.to) {
this.options.toZoom = this.options.remoteData.to this.options.toZoom = this.options.remoteData.to
this.options.remoteData.to = undefined delete this.options.remoteData.to
} }
this.backupOptions() this.backupOptions()
this.connectToMap() this.connectToMap()
@ -834,7 +834,7 @@ U.DataLayer = L.Evented.extend({
}, },
setOptions: function (options) { setOptions: function (options) {
options.geojson = undefined delete options.geojson
this.options = U.Utils.CopyJSON(U.DataLayer.prototype.options) // Start from fresh. this.options = U.Utils.CopyJSON(U.DataLayer.prototype.options) // Start from fresh.
this.updateOptions(options) this.updateOptions(options)
}, },
@ -1202,7 +1202,7 @@ U.DataLayer = L.Evented.extend({
clone: function () { clone: function () {
const options = U.Utils.CopyJSON(this.options) const options = U.Utils.CopyJSON(this.options)
options.name = L._('Clone of {name}', { name: this.options.name }) options.name = L._('Clone of {name}', { name: this.options.name })
options.id = undefined delete options.id
const geojson = U.Utils.CopyJSON(this._geojson) const geojson = U.Utils.CopyJSON(this._geojson)
const datalayer = this.map.createDataLayer(options) const datalayer = this.map.createDataLayer(options)
datalayer.fromGeoJSON(geojson) datalayer.fromGeoJSON(geojson)
@ -1222,8 +1222,8 @@ U.DataLayer = L.Evented.extend({
this.map.off('zoomend', this.onZoomEnd, this) this.map.off('zoomend', this.onZoomEnd, this)
this.off() this.off()
this.clear() this.clear()
this._loaded = undefined delete this._loaded
this._dataloaded = undefined delete this._dataloaded
}, },
reset: function () { reset: function () {
@ -1701,7 +1701,7 @@ U.DataLayer = L.Evented.extend({
if (data.geojson) { if (data.geojson) {
this.clear() this.clear()
this.fromGeoJSON(data.geojson) this.fromGeoJSON(data.geojson)
data.geojson = undefined delete data.geojson
} }
this._reference_version = response.headers.get('X-Datalayer-Version') this._reference_version = response.headers.get('X-Datalayer-Version')
this.sync.update('_reference_version', this._reference_version) this.sync.update('_reference_version', this._reference_version)

View file

@ -21,7 +21,6 @@ U.Share = L.Class.extend({
map.eachFeature((feature) => { map.eachFeature((feature) => {
const row = feature.toGeoJSON().properties const row = feature.toGeoJSON().properties
const center = feature.getCenter() const center = feature.getCenter()
// biome-ignore lint/performance/noDelete: we do not want the key at all.
delete row._umap_options delete row._umap_options
row.Latitude = center.lat row.Latitude = center.lat
row.Longitude = center.lng row.Longitude = center.lng
@ -225,7 +224,7 @@ U.IframeExporter = L.Evented.extend({
if (this.options.viewCurrentFeature && this.map.currentFeature) { if (this.options.viewCurrentFeature && this.map.currentFeature) {
this.queryString.feature = this.map.currentFeature.getSlug() this.queryString.feature = this.map.currentFeature.getSlug()
} else { } else {
this.queryString.feature = undefined delete this.queryString.feature
} }
if (this.options.keepCurrentDatalayers) { if (this.options.keepCurrentDatalayers) {
this.map.eachDataLayer((datalayer) => { this.map.eachDataLayer((datalayer) => {
@ -235,7 +234,7 @@ U.IframeExporter = L.Evented.extend({
}) })
this.queryString.datalayers = datalayers.join(',') this.queryString.datalayers = datalayers.join(',')
} else { } else {
this.queryString.datalayers = undefined delete this.queryString.datalayers
} }
const currentView = this.options.currentView ? window.location.hash : '' const currentView = this.options.currentView ? window.location.hash : ''
const queryString = L.extend({}, this.queryString, options) const queryString = L.extend({}, this.queryString, options)

View file

@ -316,7 +316,7 @@ describe('U.DataLayer', () => {
let icon = qs('div.umap-div-icon .icon_container') let icon = qs('div.umap-div-icon .icon_container')
poly.properties.mycolor = 'DarkGoldenRod' poly.properties.mycolor = 'DarkGoldenRod'
marker.properties.mycolor = 'DarkRed' marker.properties.mycolor = 'DarkRed'
marker.properties._umap_options.color = undefined delete marker.properties._umap_options.color
assert.notOk(qs('path[fill="DarkGoldenRod"]')) assert.notOk(qs('path[fill="DarkGoldenRod"]'))
assert.equal(icon.style.backgroundColor, 'olivedrab') assert.equal(icon.style.backgroundColor, 'olivedrab')
datalayer.options.color = '{mycolor}' datalayer.options.color = '{mycolor}'