diff --git a/umap/static/umap/js/components/alerts/alert.js b/umap/static/umap/js/components/alerts/alert.js index fb37ed6d5..517b79921 100644 --- a/umap/static/umap/js/components/alerts/alert.js +++ b/umap/static/umap/js/components/alerts/alert.js @@ -140,7 +140,7 @@ class uMapAlertConflict extends uMapAlert { // biome-ignore lint/style/useNumberNamespace: Number.Infinity returns undefined by default const { level = 'info', - duration = Infinity, + duration = Number.POSITIVE_INFINITY, message = '', forceCallback = undefined, } = event.detail diff --git a/umap/static/umap/js/modules/autocomplete.js b/umap/static/umap/js/modules/autocomplete.js index 48c0cdaa9..0c6972e7b 100644 --- a/umap/static/umap/js/modules/autocomplete.js +++ b/umap/static/umap/js/modules/autocomplete.js @@ -1,8 +1,8 @@ import { - DomUtil, DomEvent, - setOptions, + DomUtil, Util, + setOptions, } from '../../vendors/leaflet/leaflet-src.esm.js' import { translate } from './i18n.js' import { Request, ServerRequest } from './request.js' diff --git a/umap/static/umap/js/modules/browser.js b/umap/static/umap/js/modules/browser.js index 64c7cad9b..9a277a7f8 100644 --- a/umap/static/umap/js/modules/browser.js +++ b/umap/static/umap/js/modules/browser.js @@ -1,4 +1,4 @@ -import { DomUtil, DomEvent, stamp } from '../../vendors/leaflet/leaflet-src.esm.js' +import { DomEvent, DomUtil, stamp } from '../../vendors/leaflet/leaflet-src.esm.js' import { translate } from './i18n.js' export default class Browser { @@ -90,7 +90,7 @@ export default class Browser { container.innerHTML = '' datalayer.eachFeature((feature) => this.addFeature(feature, container)) - let total = datalayer.count(), + const total = datalayer.count(), current = container.querySelectorAll('li').length, count = total == current ? total : `${current}/${total}` const counter = DomUtil.create('span', 'datalayer-counter', headline) diff --git a/umap/static/umap/js/modules/caption.js b/umap/static/umap/js/modules/caption.js index a5557c5d4..a17a57e90 100644 --- a/umap/static/umap/js/modules/caption.js +++ b/umap/static/umap/js/modules/caption.js @@ -18,7 +18,7 @@ export default class Caption { open() { const container = DomUtil.create('div', 'umap-caption') - const hgroup = DomUtil.element({tagName: 'hgroup', parent: container}) + const hgroup = DomUtil.element({ tagName: 'hgroup', parent: container }) DomUtil.createTitle(hgroup, this.map.options.name, 'icon-caption icon-block') this.map.permissions.addOwnerLink('h4', hgroup) if (this.map.options.description) { diff --git a/umap/static/umap/js/modules/dompurify.js b/umap/static/umap/js/modules/dompurify.js index e82197416..74d75ed72 100644 --- a/umap/static/umap/js/modules/dompurify.js +++ b/umap/static/umap/js/modules/dompurify.js @@ -1,5 +1,5 @@ -import { default as DOMPurifyInitializer } from '../../vendors/dompurify/purify.es.js' import { JSDOM } from 'jsdom' +import { default as DOMPurifyInitializer } from '../../vendors/dompurify/purify.es.js' console.log(DOMPurifyInitializer) diff --git a/umap/static/umap/js/modules/facets.js b/umap/static/umap/js/modules/facets.js index 461a8ec31..47e266fe0 100644 --- a/umap/static/umap/js/modules/facets.js +++ b/umap/static/umap/js/modules/facets.js @@ -1,4 +1,4 @@ -import { DomUtil, DomEvent, stamp } from '../../vendors/leaflet/leaflet-src.esm.js' +import { DomEvent, DomUtil, stamp } from '../../vendors/leaflet/leaflet-src.esm.js' import { translate } from './i18n.js' import * as Utils from './utils.js' @@ -57,7 +57,7 @@ export default class Facets { } isActive() { - for (let { type, min, max, choices } of Object.values(this.selected)) { + for (const { type, min, max, choices } of Object.values(this.selected)) { if (min !== undefined || max != undefined || choices?.length) { return true } @@ -71,7 +71,7 @@ export default class Facets { const facetProperties = this.compute(names, defined) const fields = names.map((name) => { - let criteria = facetProperties[name] + const criteria = facetProperties[name] let handler = 'FacetSearchChoices' switch (criteria['type']) { case 'number': @@ -84,7 +84,7 @@ export default class Facets { handler = 'FacetSearchDateTime' break } - let label = defined[name]['label'] + const label = defined[name]['label'] return [ `selected.${name}`, { @@ -112,7 +112,7 @@ export default class Facets { getParser(type) { switch (type) { case 'number': - return parseFloat + return Number.parseFloat case 'datetime': return (v) => new Date(v) case 'date': diff --git a/umap/static/umap/js/modules/global.js b/umap/static/umap/js/modules/global.js index 49f2822b7..c4eebe03e 100644 --- a/umap/static/umap/js/modules/global.js +++ b/umap/static/umap/js/modules/global.js @@ -1,24 +1,24 @@ -import URLs from './urls.js' +import { + uMapAlert as Alert, + uMapAlertConflict as AlertConflict, + uMapAlertCreation as AlertCreation, +} from '../components/alerts/alert.js' +import { AjaxAutocomplete, AjaxAutocompleteMultiple } from './autocomplete.js' import Browser from './browser.js' -import Facets from './facets.js' import Caption from './caption.js' -import { Panel, EditPanel, FullPanel } from './ui/panel.js' -import Dialog from './ui/dialog.js' -import Tooltip from './ui/tooltip.js' +import Facets from './facets.js' +import Help from './help.js' +import Importer from './importer.js' +import Orderable from './orderable.js' +import { HTTPError, NOKError, Request, RequestError, ServerRequest } from './request.js' import Rules from './rules.js' -import * as Utils from './utils.js' import { SCHEMA } from './schema.js' -import { Request, ServerRequest, RequestError, HTTPError, NOKError } from './request.js' -import { AjaxAutocomplete, AjaxAutocompleteMultiple } from './autocomplete.js' -import Orderable from './orderable.js' -import Importer from './importer.js' -import Help from './help.js' import { SyncEngine } from './sync/engine.js' -import { - uMapAlert as Alert, - uMapAlertCreation as AlertCreation, - uMapAlertConflict as AlertConflict, -} from '../components/alerts/alert.js' +import Dialog from './ui/dialog.js' +import { EditPanel, FullPanel, Panel } from './ui/panel.js' +import Tooltip from './ui/tooltip.js' +import URLs from './urls.js' +import * as Utils from './utils.js' // Import modules and export them to the global scope. // For the not yet module-compatible JS out there. diff --git a/umap/static/umap/js/modules/help.js b/umap/static/umap/js/modules/help.js index 74c2b9f2c..580d97cd6 100644 --- a/umap/static/umap/js/modules/help.js +++ b/umap/static/umap/js/modules/help.js @@ -1,4 +1,4 @@ -import { DomUtil, DomEvent } from '../../vendors/leaflet/leaflet-src.esm.js' +import { DomEvent, DomUtil } from '../../vendors/leaflet/leaflet-src.esm.js' import { translate } from './i18n.js' const SHORTCUTS = { diff --git a/umap/static/umap/js/modules/importer.js b/umap/static/umap/js/modules/importer.js index 8ced13bf4..cca118068 100644 --- a/umap/static/umap/js/modules/importer.js +++ b/umap/static/umap/js/modules/importer.js @@ -1,8 +1,8 @@ -import { DomUtil, DomEvent } from '../../vendors/leaflet/leaflet-src.esm.js' -import { translate } from './i18n.js' +import { DomEvent, DomUtil } from '../../vendors/leaflet/leaflet-src.esm.js' import { uMapAlert as Alert } from '../components/alerts/alert.js' -import Dialog from './ui/dialog.js' +import { translate } from './i18n.js' import { SCHEMA } from './schema.js' +import Dialog from './ui/dialog.js' import * as Utils from './utils.js' const TEMPLATE = ` diff --git a/umap/static/umap/js/modules/importers/geodatamine.js b/umap/static/umap/js/modules/importers/geodatamine.js index 5c73be009..74c2819b4 100644 --- a/umap/static/umap/js/modules/importers/geodatamine.js +++ b/umap/static/umap/js/modules/importers/geodatamine.js @@ -1,8 +1,8 @@ -import { DomUtil, DomEvent } from '../../../vendors/leaflet/leaflet-src.esm.js' +import { DomEvent, DomUtil } from '../../../vendors/leaflet/leaflet-src.esm.js' +import { uMapAlert as Alert } from '../../components/alerts/alert.js' import { BaseAjax, SingleMixin } from '../autocomplete.js' import { translate } from '../i18n.js' import * as Utils from '../utils.js' -import { uMapAlert as Alert } from '../../components/alerts/alert.js' const BOUNDARY_TYPES = { admin_6: 'département', @@ -54,7 +54,7 @@ export class Importer { const select = container.querySelector('select') if (response && response.ok) { const { themes } = await response.json() - themes.sort((a, b) => Utils.naturalSort(a['name:fr'], b ['name:fr'])) + themes.sort((a, b) => Utils.naturalSort(a['name:fr'], b['name:fr'])) for (const theme of themes) { DomUtil.element({ tagName: 'option', diff --git a/umap/static/umap/js/modules/importers/overpass.js b/umap/static/umap/js/modules/importers/overpass.js index 8d7d5ac8c..8bd7f058d 100644 --- a/umap/static/umap/js/modules/importers/overpass.js +++ b/umap/static/umap/js/modules/importers/overpass.js @@ -1,7 +1,7 @@ import { DomUtil } from '../../../vendors/leaflet/leaflet-src.esm.js' +import { uMapAlert as Alert } from '../../components/alerts/alert.js' import { BaseAjax, SingleMixin } from '../autocomplete.js' import { translate } from '../i18n.js' -import { uMapAlert as Alert } from '../../components/alerts/alert.js' const TEMPLATE = `

Overpass

@@ -68,7 +68,7 @@ export class Importer { if (!tags.startsWith('[')) tags = `[${tags}]` let area = '{south},{west},{north},{east}' if (boundary) area = `area:${boundary}` - let query = `[out:json];nwr${tags}(${area});out ${outMode};` + const query = `[out:json];nwr${tags}(${area});out ${outMode};` importer.url = `${this.baseUrl}?data=${query}` if (boundary) importer.layerName = boundaryName importer.format = 'osm' diff --git a/umap/static/umap/js/modules/request.js b/umap/static/umap/js/modules/request.js index 3edc6ba8f..c8525363b 100644 --- a/umap/static/umap/js/modules/request.js +++ b/umap/static/umap/js/modules/request.js @@ -1,5 +1,5 @@ -import { translate } from './i18n.js' import { uMapAlert as Alert } from '../components/alerts/alert.js' +import { translate } from './i18n.js' export class RequestError extends Error {} diff --git a/umap/static/umap/js/modules/rules.js b/umap/static/umap/js/modules/rules.js index e89d6a8f8..b3e06dd9e 100644 --- a/umap/static/umap/js/modules/rules.js +++ b/umap/static/umap/js/modules/rules.js @@ -1,9 +1,8 @@ -import { DomUtil, DomEvent, stamp } from '../../vendors/leaflet/leaflet-src.esm.js' -import * as Utils from './utils.js' +import { DomEvent, DomUtil, stamp } from '../../vendors/leaflet/leaflet-src.esm.js' import { translate } from './i18n.js' +import * as Utils from './utils.js' class Rule { - get condition() { return this._condition } @@ -13,7 +12,6 @@ class Rule { this.parse() } - get isDirty() { return this._isDirty } @@ -76,7 +74,7 @@ class Rule { if (vars.length != 2) return this.key = vars[0] this.expected = vars[1] - if (!isNaN(this.expected)) this.cast = parseFloat + if (!isNaN(this.expected)) this.cast = Number.parseFloat else if (['true', 'false'].includes(this.expected)) this.cast = (v) => !!v this.expected = this.cast(this.expected) } diff --git a/umap/static/umap/js/modules/sync/engine.js b/umap/static/umap/js/modules/sync/engine.js index 2af5dfb68..6b672aa75 100644 --- a/umap/static/umap/js/modules/sync/engine.js +++ b/umap/static/umap/js/modules/sync/engine.js @@ -1,5 +1,5 @@ +import { DataLayerUpdater, FeatureUpdater, MapUpdater } from './updaters.js' import { WebSocketTransport } from './websocket.js' -import { MapUpdater, DataLayerUpdater, FeatureUpdater } from './updaters.js' export class SyncEngine { constructor(map) { @@ -37,7 +37,7 @@ export class SyncEngine { // This method is called by the transport layer on new messages receive({ kind, ...payload }) { if (kind == 'operation') { - let updater = this._getUpdater(payload.subject, payload.metadata) + const updater = this._getUpdater(payload.subject, payload.metadata) updater.applyMessage(payload) } else { throw new Error(`Unknown dispatch kind: ${kind}`) diff --git a/umap/static/umap/js/modules/sync/updaters.js b/umap/static/umap/js/modules/sync/updaters.js index a64e351dd..faaf79203 100644 --- a/umap/static/umap/js/modules/sync/updaters.js +++ b/umap/static/umap/js/modules/sync/updaters.js @@ -35,7 +35,7 @@ class BaseUpdater { } applyMessage(payload) { - let { verb } = payload + const { verb } = payload return this[verb](payload) } } @@ -69,7 +69,7 @@ export class FeatureUpdater extends BaseUpdater { // Create or update an object at a specific position upsert({ metadata, value }) { - let { id, layerId } = metadata + const { id, layerId } = metadata const datalayer = this.getDataLayerFromID(layerId) let feature = this.getFeatureFromMetadata(metadata, value) @@ -84,7 +84,7 @@ export class FeatureUpdater extends BaseUpdater { // Update a property of an object update({ key, metadata, value }) { - let feature = this.getFeatureFromMetadata(metadata) + const feature = this.getFeatureFromMetadata(metadata) if (feature === undefined) { console.error(`Unable to find feature with id = ${metadata.id}.`) } @@ -103,7 +103,7 @@ export class FeatureUpdater extends BaseUpdater { delete({ metadata }) { // XXX Distinguish between properties getting deleted // and the wole feature getting deleted - let feature = this.getFeatureFromMetadata(metadata) + const feature = this.getFeatureFromMetadata(metadata) if (feature) feature.del(false) } } diff --git a/umap/static/umap/js/modules/sync/websocket.js b/umap/static/umap/js/modules/sync/websocket.js index 45854dc11..529c0b190 100644 --- a/umap/static/umap/js/modules/sync/websocket.js +++ b/umap/static/umap/js/modules/sync/websocket.js @@ -15,7 +15,7 @@ export class WebSocketTransport { send(kind, payload) { const message = { ...payload } message.kind = kind - let encoded = JSON.stringify(message) + const encoded = JSON.stringify(message) this.websocket.send(encoded) } diff --git a/umap/static/umap/js/modules/ui/dialog.js b/umap/static/umap/js/modules/ui/dialog.js index f85b7d544..9cfea1b19 100644 --- a/umap/static/umap/js/modules/ui/dialog.js +++ b/umap/static/umap/js/modules/ui/dialog.js @@ -1,4 +1,4 @@ -import { DomUtil, DomEvent } from '../../../vendors/leaflet/leaflet-src.esm.js' +import { DomEvent, DomUtil } from '../../../vendors/leaflet/leaflet-src.esm.js' import { translate } from '../i18n.js' export default class Dialog { diff --git a/umap/static/umap/js/modules/ui/panel.js b/umap/static/umap/js/modules/ui/panel.js index e236e82ab..f84a92b30 100644 --- a/umap/static/umap/js/modules/ui/panel.js +++ b/umap/static/umap/js/modules/ui/panel.js @@ -1,4 +1,4 @@ -import { DomUtil, DomEvent } from '../../../vendors/leaflet/leaflet-src.esm.js' +import { DomEvent, DomUtil } from '../../../vendors/leaflet/leaflet-src.esm.js' import { translate } from '../i18n.js' export class Panel { diff --git a/umap/static/umap/js/modules/ui/tooltip.js b/umap/static/umap/js/modules/ui/tooltip.js index 6573421d3..eb95b8094 100644 --- a/umap/static/umap/js/modules/ui/tooltip.js +++ b/umap/static/umap/js/modules/ui/tooltip.js @@ -1,4 +1,4 @@ -import { DomUtil, DomEvent } from '../../../vendors/leaflet/leaflet-src.esm.js' +import { DomEvent, DomUtil } from '../../../vendors/leaflet/leaflet-src.esm.js' import { translate } from '../i18n.js' export default class Tooltip { @@ -34,7 +34,7 @@ export default class Tooltip { if (opts.anchor) { L.DomEvent.once(opts.anchor, 'mouseout', closeIt) } - if (opts.duration !== Infinity) { + if (opts.duration !== Number.POSITIVE_INFINITY) { window.setTimeout(closeIt, opts.duration || 3000) } } diff --git a/umap/static/umap/js/modules/utils.js b/umap/static/umap/js/modules/utils.js index 0ebb885a5..c132f1a51 100644 --- a/umap/static/umap/js/modules/utils.js +++ b/umap/static/umap/js/modules/utils.js @@ -36,7 +36,7 @@ export function checkId(string) { */ export function getImpactsFromSchema(fields, schema) { schema = schema || U.SCHEMA - let impacted = fields + const impacted = fields .map((field) => { // remove the option prefix for fields // And only keep the first part in case of a subfield @@ -120,7 +120,7 @@ export function toHTML(r, options) { r = r.replace(/^\*\* (.*)/gm, '') r = r.replace(/^\* (.*)/gm, '') for (let ii = 0; ii < 3; ii++) { - r = r.replace(new RegExp(`(\r\n|\r|\n)