Skip to content

Commit

Permalink
chore: apply Biome safe changes
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbgk committed Jun 25, 2024
1 parent e32deed commit ef33a26
Show file tree
Hide file tree
Showing 33 changed files with 263 additions and 363 deletions.
2 changes: 1 addition & 1 deletion umap/static/umap/js/components/alerts/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions umap/static/umap/js/modules/autocomplete.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions umap/static/umap/js/modules/browser.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion umap/static/umap/js/modules/caption.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion umap/static/umap/js/modules/dompurify.js
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
10 changes: 5 additions & 5 deletions umap/static/umap/js/modules/facets.js
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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
}
Expand All @@ -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':
Expand All @@ -84,7 +84,7 @@ export default class Facets {
handler = 'FacetSearchDateTime'
break
}
let label = defined[name]['label']
const label = defined[name]['label']
return [
`selected.${name}`,
{
Expand Down Expand Up @@ -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':
Expand Down
32 changes: 16 additions & 16 deletions umap/static/umap/js/modules/global.js
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion umap/static/umap/js/modules/help.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
6 changes: 3 additions & 3 deletions umap/static/umap/js/modules/importer.js
Original file line number Diff line number Diff line change
@@ -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 = `
Expand Down
6 changes: 3 additions & 3 deletions umap/static/umap/js/modules/importers/geodatamine.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions umap/static/umap/js/modules/importers/overpass.js
Original file line number Diff line number Diff line change
@@ -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 = `
<h3>Overpass</h3>
Expand Down Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion umap/static/umap/js/modules/request.js
Original file line number Diff line number Diff line change
@@ -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 {}

Expand Down
8 changes: 3 additions & 5 deletions umap/static/umap/js/modules/rules.js
Original file line number Diff line number Diff line change
@@ -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
}
Expand All @@ -13,7 +12,6 @@ class Rule {
this.parse()
}


get isDirty() {
return this._isDirty
}
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions umap/static/umap/js/modules/sync/engine.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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}`)
Expand Down
8 changes: 4 additions & 4 deletions umap/static/umap/js/modules/sync/updaters.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BaseUpdater {
}

applyMessage(payload) {
let { verb } = payload
const { verb } = payload
return this[verb](payload)
}
}
Expand Down Expand Up @@ -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)

Expand All @@ -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}.`)
}
Expand All @@ -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)
}
}
2 changes: 1 addition & 1 deletion umap/static/umap/js/modules/sync/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion umap/static/umap/js/modules/ui/dialog.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion umap/static/umap/js/modules/ui/panel.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions umap/static/umap/js/modules/ui/tooltip.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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)
}
}
Expand Down
6 changes: 3 additions & 3 deletions umap/static/umap/js/modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -120,7 +120,7 @@ export function toHTML(r, options) {
r = r.replace(/^\*\* (.*)/gm, '<ul><ul><li>$1</li></ul></ul>')
r = r.replace(/^\* (.*)/gm, '<ul><li>$1</li></ul>')
for (let ii = 0; ii < 3; ii++) {
r = r.replace(new RegExp(`</ul>(\r\n|\r|\n)<ul>`, 'g'), '')
r = r.replace(/<\/ul>(\r\n|\r|\n)<ul>/g, '')
}

// headings and hr
Expand Down Expand Up @@ -352,7 +352,7 @@ export function normalize(s) {
var templateRe = /\{ *([\w_ -]+) *\}/g

export function template(str, data) {
return str.replace(templateRe, function (str, key) {
return str.replace(templateRe, (str, key) => {
var value = data[key]

if (value === undefined) {
Expand Down
14 changes: 6 additions & 8 deletions umap/static/umap/js/umap.controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ U.BaseFeatureAction = L.ToolbarAction.extend({
this.postInit()
},

postInit: function () {},
postInit: () => {},

hideToolbar: function () {
this.map.removeLayer(this.toolbar)
Expand Down Expand Up @@ -356,7 +356,7 @@ U.DropControl = L.Class.extend({
this.dropzone.classList.add('umap-dragover')
},

dragover: function (e) {
dragover: (e) => {
L.DomEvent.stop(e)
},

Expand Down Expand Up @@ -393,7 +393,7 @@ U.EditControl = L.Control.extend({
L.DomEvent.on(
enableEditing,
'mouseover',
function () {
() => {
map.tooltip.open({
content: map.help.displayLabel('TOGGLE_EDIT'),
anchor: enableEditing,
Expand Down Expand Up @@ -503,7 +503,7 @@ L.Control.Button = L.Control.extend({
return container
},

afterAdd: function (container) {},
afterAdd: (container) => {},
})

U.DataLayersControl = L.Control.Button.extend({
Expand Down Expand Up @@ -1205,9 +1205,7 @@ L.Control.MiniMap.include({
this._miniMap.addLayer(this._layer)
},

_cloneLayer: function (layer) {
return new L.TileLayer(layer._url, L.Util.extend({}, layer.options))
},
_cloneLayer: (layer) => new L.TileLayer(layer._url, L.Util.extend({}, layer.options)),
})

L.Control.Loading.include({
Expand Down Expand Up @@ -1364,7 +1362,7 @@ U.Editable = L.Editable.extend({
this.map.ui.closeTooltip()
},

onVertexRawClick: function (e) {
onVertexRawClick: (e) => {
e.layer.onVertexRawClick(e)
L.DomEvent.stop(e)
e.cancel()
Expand Down
Loading

0 comments on commit ef33a26

Please sign in to comment.