chore: automatic fix some linting errors, update lint config

This commit is contained in:
Pieter Vander Vennet 2025-06-18 21:52:03 +02:00
parent 04c8ccb0d2
commit 804280511b
26 changed files with 47 additions and 45 deletions

View file

@ -1 +1,2 @@
src/test.ts src/test.ts
android/*

View file

@ -13,3 +13,4 @@ Docs/Schemas/
Docs/TagInfo/ Docs/TagInfo/
src/assets/generated src/assets/generated
src/assets/svg src/assets/svg
android/

View file

@ -130,8 +130,8 @@
"weblate:add-upstream": "npm run weblate:add-upstream-core; npm run weblate:add-upstream-layers; npm run weblate:add-upstream-themes", "weblate:add-upstream": "npm run weblate:add-upstream-core; npm run weblate:add-upstream-layers; npm run weblate:add-upstream-themes",
"weblate:fix": "npm run weblate:add-upstream && git merge weblate-core/master weblate-layers/master weblate-themes/master && git rebase source/master && git push", "weblate:fix": "npm run weblate:add-upstream && git merge weblate-core/master weblate-layers/master weblate-themes/master && git rebase source/master && git push",
"lint": "npm run lint:prettier && npm run lint:eslint && npm run lint:themes", "lint": "npm run lint:prettier && npm run lint:eslint && npm run lint:themes",
"lint:eslint": "eslint ./src", "lint:eslint": "eslint ./src --fix",
"lint:prettier": "prettier --check '**/*.ts' '**/*.svelte'", "lint:prettier": "prettier --check 'src/**/*.ts' 'test/**/*.ts' 'src/**/*.svelte'",
"lint:themes": "vite-node scripts/lint.ts", "lint:themes": "vite-node scripts/lint.ts",
"format": "prettier --write '**/*.ts' '**/*.svelte'", "format": "prettier --write '**/*.ts' '**/*.svelte'",
"optimize-images-png": "cd assets/generated/ && find -name '*.png' -exec optipng '{}' \\; && echo 'PNGs are optimized'", "optimize-images-png": "cd assets/generated/ && find -name '*.png' -exec optipng '{}' \\; && echo 'PNGs are optimized'",

View file

@ -265,7 +265,7 @@ class ClosestNObjectFunc implements ExtraFunction {
features = [features] features = [features]
} }
let allFeatures: Feature[][] = [] const allFeatures: Feature[][] = []
for (const spec of features) { for (const spec of features) {
if (typeof spec === "string") { if (typeof spec === "string") {
const name = spec const name = spec
@ -284,7 +284,7 @@ class ClosestNObjectFunc implements ExtraFunction {
} }
const selfCenter = GeoOperations.centerpointCoordinates(feature) const selfCenter = GeoOperations.centerpointCoordinates(feature)
let closestFeatures: { feat: any; distance: number }[] = [] const closestFeatures: { feat: any; distance: number }[] = []
for (const feats of allFeatures ?? []) { for (const feats of allFeatures ?? []) {
for (const otherFeature of feats) { for (const otherFeature of feats) {

View file

@ -25,7 +25,7 @@ export default class FeatureSourceMerger<Src extends FeatureSource = FeatureSour
this.featuresById = this._featuresById this.featuresById = this._featuresById
const self = this const self = this
sources = Utils.NoNull(sources) sources = Utils.NoNull(sources)
for (let source of sources) { for (const source of sources) {
source.features.addCallback(() => { source.features.addCallback(() => {
self.addDataFromSources(sources) self.addDataFromSources(sources)
}) })

View file

@ -34,7 +34,7 @@ export class PolygonSourceMerger extends UpdatableDynamicTileSource<
const zooms: Map<string, number> = new Map() const zooms: Map<string, number> = new Map()
for (const source of sources) { for (const source of sources) {
let z = source.z const z = source.z
for (const f of source.features.data) { for (const f of source.features.data) {
const id = f.properties.id const id = f.properties.id
if (id.endsWith("146616907")) { if (id.endsWith("146616907")) {

View file

@ -297,7 +297,7 @@ export class ImageUploadManager {
let absoluteUrl: string let absoluteUrl: string
try { try {
;({ key, value, absoluteUrl } = await this._uploader.uploadImage( ({ key, value, absoluteUrl } = await this._uploader.uploadImage(
blob, blob,
location, location,
author, author,

View file

@ -110,11 +110,11 @@ export class TurnRestrictionRSH extends AbstractRelationSplitHandler {
// We have to keep only the way with a common point with the rest of the relation // We have to keep only the way with a common point with the rest of the relation
// Let's figure out which member is neighbouring our way // Let's figure out which member is neighbouring our way
let commonStartPoint: number = await this.targetNodeAt(members.indexOf(selfMember), true) const commonStartPoint: number = await this.targetNodeAt(members.indexOf(selfMember), true)
let commonEndPoint: number = await this.targetNodeAt(members.indexOf(selfMember), false) const commonEndPoint: number = await this.targetNodeAt(members.indexOf(selfMember), false)
// In normal circumstances, only one of those should be defined // In normal circumstances, only one of those should be defined
let commonPoint = commonStartPoint ?? commonEndPoint const commonPoint = commonStartPoint ?? commonEndPoint
// Let's select the way to keep // Let's select the way to keep
const idToKeep: { id: number } = this._input.allWaysNodesInOrder const idToKeep: { id: number } = this._input.allWaysNodesInOrder

View file

@ -120,7 +120,7 @@ export default class SplitAction extends OsmChangeAction {
const allWaysNodesInOrder: number[][] = [] const allWaysNodesInOrder: number[][] = []
// Lets create OsmWays based on them // Lets create OsmWays based on them
for (const wayPart of wayParts) { for (const wayPart of wayParts) {
let isOriginal = wayPart === longest const isOriginal = wayPart === longest
if (isOriginal) { if (isOriginal) {
// We change the existing way // We change the existing way
const nodeIds = wayPart.map((p) => p.originalIndex) const nodeIds = wayPart.map((p) => p.originalIndex)
@ -140,7 +140,7 @@ export default class SplitAction extends OsmChangeAction {
allWayIdsInOrder.push(originalElement.id) allWayIdsInOrder.push(originalElement.id)
allWaysNodesInOrder.push(nodeIds) allWaysNodesInOrder.push(nodeIds)
} else { } else {
let id = changes.getNewID() const id = changes.getNewID()
// Copy the tags from the original object onto the new // Copy the tags from the original object onto the new
const kv = [] const kv = []
for (const k in originalElement.tags) { for (const k in originalElement.tags) {
@ -219,7 +219,7 @@ export default class SplitAction extends OsmChangeAction {
// - `index`: closest point was found on nth line part, // - `index`: closest point was found on nth line part,
// - `dist`: distance between pt and the closest point, // - `dist`: distance between pt and the closest point,
// `location`: distance along the line between start and the closest point. // `location`: distance along the line between start and the closest point.
let projected = GeoOperations.nearestPoint(wayGeoJson, c) const projected = GeoOperations.nearestPoint(wayGeoJson, c)
// c is lon lat // c is lon lat
return { return {
coordinates: c, coordinates: c,
@ -232,8 +232,8 @@ export default class SplitAction extends OsmChangeAction {
// We have a bunch of coordinates here: [ [lon, lon], [lat, lon], ...] ... // We have a bunch of coordinates here: [ [lon, lon], [lat, lon], ...] ...
// We project them onto the line (which should yield pretty much the same point and add them to allPoints // We project them onto the line (which should yield pretty much the same point and add them to allPoints
for (let i = 0; i < originalPoints.length; i++) { for (let i = 0; i < originalPoints.length; i++) {
let originalPoint = originalPoints[i] const originalPoint = originalPoints[i]
let projected = GeoOperations.nearestPoint(wayGeoJson, originalPoint) const projected = GeoOperations.nearestPoint(wayGeoJson, originalPoint)
allPoints.push({ allPoints.push({
coordinates: originalPoint, coordinates: originalPoint,
isSplitPoint: false, isSplitPoint: false,

View file

@ -24,7 +24,7 @@ export default class AspectedRouting {
let functionName /*: string*/ = undefined let functionName /*: string*/ = undefined
let functionArguments /*: any */ = undefined let functionArguments /*: any */ = undefined
let otherValues = {} const otherValues = {}
// @ts-ignore // @ts-ignore
Object.entries(program).forEach((tag) => { Object.entries(program).forEach((tag) => {
const [key, value] = tag const [key, value] = tag
@ -135,9 +135,9 @@ export default class AspectedRouting {
private static getFirstMatchScore(tags, order: any) { private static getFirstMatchScore(tags, order: any) {
/*Order should be a list of arguments after evaluation*/ /*Order should be a list of arguments after evaluation*/
order = <string[]>AspectedRouting.interpret(order, tags) order = <string[]>AspectedRouting.interpret(order, tags)
for (let key of order) { for (const key of order) {
// @ts-ignore // @ts-ignore
for (let entry of Object.entries(JSON.parse(tags))) { for (const entry of Object.entries(JSON.parse(tags))) {
const [tagKey, value] = entry const [tagKey, value] = entry
if (key === tagKey) { if (key === tagKey) {
// We have a match... let's evaluate the subprogram // We have a match... let's evaluate the subprogram

View file

@ -247,7 +247,7 @@ export default class LinkedDataLoader {
return await LinkedDataLoader.compact(data, options) return await LinkedDataLoader.compact(data, options)
} }
let htmlContent = await Utils.download(url) const htmlContent = await Utils.download(url)
const div = document.createElement("div") const div = document.createElement("div")
div.innerHTML = htmlContent div.innerHTML = htmlContent
const script = Array.from(div.getElementsByTagName("script")).find( const script = Array.from(div.getElementsByTagName("script")).find(

View file

@ -234,7 +234,7 @@ export default class Wikidata {
}[] }[]
> { > {
const maxCount = options?.maxCount ?? 20 const maxCount = options?.maxCount ?? 20
let pageCount = Math.min(maxCount, 50) const pageCount = Math.min(maxCount, 50)
const start = page * pageCount - pageCount const start = page * pageCount - pageCount
const lang = options?.lang ?? "en" const lang = options?.lang ?? "en"
const url = const url =

View file

@ -930,7 +930,7 @@ export class AddRatingBadge extends DesugaringStep<LayerConfigJson> {
const funcs = new Set<string>(specialVis.map((rs) => rs.func.funcName)) const funcs = new Set<string>(specialVis.map((rs) => rs.func.funcName))
if (funcs.has("list_reviews")) { if (funcs.has("list_reviews")) {
;(<(string | TagRenderingConfigJson)[]>json.titleIcons).push("icons.rating") (<(string | TagRenderingConfigJson)[]>json.titleIcons).push("icons.rating")
} }
return json return json
} }

View file

@ -18,7 +18,7 @@ export default class ExtraLinkConfig {
this.newTab = configJson.newTab this.newTab = configJson.newTab
this.requirements = new Set(configJson.requirements) this.requirements = new Set(configJson.requirements)
for (let requirement of configJson.requirements) { for (const requirement of configJson.requirements) {
if (this.requirements.has(<any>("no-" + requirement))) { if (this.requirements.has(<any>("no-" + requirement))) {
throw ( throw (
"Conflicting requirements found for " + "Conflicting requirements found for " +

View file

@ -17,7 +17,7 @@ export default class WithContextLoader {
* The found value is interpreted as a tagrendering and fetched/parsed * The found value is interpreted as a tagrendering and fetched/parsed
* */ * */
public tr(key: string, deflt?: string, translationContext?: string) { public tr(key: string, deflt?: string, translationContext?: string) {
let v: Translatable | TagRenderingConfigJson = this._json[key] const v: Translatable | TagRenderingConfigJson = this._json[key]
if (v === undefined || v === null) { if (v === undefined || v === null) {
if (deflt === undefined) { if (deflt === undefined) {
return undefined return undefined

View file

@ -86,7 +86,7 @@ export class Tiles {
static asGeojson(zIndex: number, x?: number, y?: number): Feature<Polygon> { static asGeojson(zIndex: number, x?: number, y?: number): Feature<Polygon> {
let z = zIndex let z = zIndex
if (x === undefined) { if (x === undefined) {
;[z, x, y] = Tiles.tile_from_index(zIndex) [z, x, y] = Tiles.tile_from_index(zIndex)
} }
const bounds = Tiles.tile_bounds_lon_lat(z, x, y) const bounds = Tiles.tile_bounds_lon_lat(z, x, y)
return new BBox(bounds).asGeoJson() return new BBox(bounds).asGeoJson()

View file

@ -156,7 +156,7 @@ export default class Hotkeys {
} }
const contents: string[][] = this.prepareDocumentation(docs).map( const contents: string[][] = this.prepareDocumentation(docs).map(
([key, doc, alsoTriggeredBy]) => { ([key, doc, alsoTriggeredBy]) => {
let keyEl: string = [key, ...(alsoTriggeredBy ?? [])] const keyEl: string = [key, ...(alsoTriggeredBy ?? [])]
.map((k) => "`" + t(k) + "`") .map((k) => "`" + t(k) + "`")
.join(" ") .join(" ")
return [keyEl, t(doc)] return [keyEl, t(doc)]

View file

@ -10,7 +10,7 @@
* Show the button, even though we are logged in * Show the button, even though we are logged in
*/ */
export let forceShow: boolean = false export let forceShow: boolean = false
export let msg: String = undefined export let msg: string = undefined
if (osmConnection === undefined) { if (osmConnection === undefined) {
console.error("No osmConnection passed into loginButton") console.error("No osmConnection passed into loginButton")
} }

View file

@ -24,7 +24,7 @@ export default abstract class BaseUIElement {
} }
AttachTo(divId: string) { AttachTo(divId: string) {
let element = document.getElementById(divId) const element = document.getElementById(divId)
if (element === null) { if (element === null) {
if (Utils.runningFromConsole) { if (Utils.runningFromConsole) {
this.ConstructElement() this.ConstructElement()
@ -78,7 +78,7 @@ export default abstract class BaseUIElement {
public RemoveClass(classes: string): BaseUIElement { public RemoveClass(classes: string): BaseUIElement {
const all = classes.split(" ").map((clsName) => clsName.trim()) const all = classes.split(" ").map((clsName) => clsName.trim())
for (let clss of all) { for (const clss of all) {
if (this.clss.has(clss)) { if (this.clss.has(clss)) {
this.clss.delete(clss) this.clss.delete(clss)
this._constructedHtmlElement?.classList.remove(clss) this._constructedHtmlElement?.classList.remove(clss)

View file

@ -14,7 +14,7 @@ export class ComparisonState {
externalProperties = { ...externalProperties } externalProperties = { ...externalProperties }
delete externalProperties["@context"] delete externalProperties["@context"]
let externalKeys: string[] = Object.keys(externalProperties).sort() const externalKeys: string[] = Object.keys(externalProperties).sort()
const imageKeyRegex = /image|image:[0-9]+/ const imageKeyRegex = /image|image:[0-9]+/
@ -35,7 +35,7 @@ export class ComparisonState {
) )
this.propertyKeysExternal = externalKeys.filter((k) => k.match(imageKeyRegex) === null) this.propertyKeysExternal = externalKeys.filter((k) => k.match(imageKeyRegex) === null)
let propertyKeysExternal = this.propertyKeysExternal const propertyKeysExternal = this.propertyKeysExternal
this.missing = tags.map((osmProperties) => this.missing = tags.map((osmProperties) =>
propertyKeysExternal.filter((k) => { propertyKeysExternal.filter((k) => {
if (k.startsWith("_")) { if (k.startsWith("_")) {

View file

@ -33,7 +33,7 @@ export class ShareLinkViz implements SpecialVisualizationSvelte {
const generateShareData = () => { const generateShareData = () => {
const title = state?.theme?.title?.txt ?? "MapComplete" const title = state?.theme?.title?.txt ?? "MapComplete"
let matchingLayer: LayerConfig = state?.theme?.getMatchingLayer(tagSource?.data) const matchingLayer: LayerConfig = state?.theme?.getMatchingLayer(tagSource?.data)
let name = let name =
matchingLayer?.title?.GetRenderValue(tagSource.data)?.Subs(tagSource.data)?.txt ?? matchingLayer?.title?.GetRenderValue(tagSource.data)?.Subs(tagSource.data)?.txt ??
tagSource.data?.name ?? tagSource.data?.name ??

View file

@ -80,7 +80,7 @@ export default class TagApplyButton implements AutoAction, SpecialVisualization
const newTags: Tag[] = [] const newTags: Tag[] = []
for (const [key, value] of tgsSpec) { for (const [key, value] of tgsSpec) {
if (value.indexOf("$") >= 0) { if (value.indexOf("$") >= 0) {
let parts = value.split("$") const parts = value.split("$")
// The first item of the split won't start with a '$', so no substitution needed // The first item of the split won't start with a '$', so no substitution needed
let actualValue = parts[0] let actualValue = parts[0]
parts.shift() parts.shift()

View file

@ -1596,7 +1596,7 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
let _: string let _: string
const matchWithFuncName = stackItem.match(regex) const matchWithFuncName = stackItem.match(regex)
if (matchWithFuncName) { if (matchWithFuncName) {
;[_, functionName, path, line, column] = matchWithFuncName [_, functionName, path, line, column] = matchWithFuncName
} else { } else {
const regexNoFuncName: RegExp = new RegExp("at ([a-zA-Z0-9-/.]+):([0-9]+):([0-9]+)") const regexNoFuncName: RegExp = new RegExp("at ([a-zA-Z0-9-/.]+):([0-9]+):([0-9]+)")
;[_, path, line, column] = stackItem.match(regexNoFuncName) ;[_, path, line, column] = stackItem.match(regexNoFuncName)

View file

@ -1,6 +1,6 @@
export function dragDetection(htmlElement: HTMLElement, callback: () => {}) { export function dragDetection(htmlElement: HTMLElement, callback: () => {}) {
let isDown = false let isDown = false
let threshold = 5 const threshold = 5
let start = null let start = null
htmlElement.addEventListener("pointerdown", (e) => { htmlElement.addEventListener("pointerdown", (e) => {

View file

@ -24,8 +24,8 @@ async function activate() {
} }
async function fetchAndCache(event: ServiceWorkerFetchEvent): Promise<Response> { async function fetchAndCache(event: ServiceWorkerFetchEvent): Promise<Response> {
let networkResponse = await fetch(event.request) const networkResponse = await fetch(event.request)
let cache = await caches.open(version) const cache = await caches.open(version)
await cache.put(event.request, networkResponse.clone()) await cache.put(event.request, networkResponse.clone())
console.log("Cached", event.request) console.log("Cached", event.request)
return networkResponse return networkResponse

View file

@ -1,11 +1,11 @@
{ {
"rules": { "rules": {
"class-name": false, "class-name": true,
"comment-format": [ "comment-format": [
true true
], ],
"curly": false, "curly": true,
"eofline": false, "eofline": true,
"forin": false, "forin": false,
"indent": [ "indent": [
true, true,
@ -13,14 +13,14 @@
], ],
"label-position": true, "label-position": true,
"max-line-length": false, "max-line-length": false,
"member-access": false, "member-access": true,
"member-ordering": [ "member-ordering": [
true, true,
"static-after-instance", "static-after-instance",
"variables-before-functions" "variables-before-functions"
], ],
"no-arg": true, "no-arg": true,
"no-bitwise": false, "no-bitwise": true,
"no-console": false, "no-console": false,
"no-construct": true, "no-construct": true,
"no-debugger": true, "no-debugger": true,
@ -33,7 +33,7 @@
"no-switch-case-fall-through": true, "no-switch-case-fall-through": true,
"no-trailing-whitespace": true, "no-trailing-whitespace": true,
"no-unused-expression": true, "no-unused-expression": true,
"no-use-before-declare": false, "no-use-before-declare": true,
"no-var-keyword": true, "no-var-keyword": true,
"object-literal-sort-keys": false, "object-literal-sort-keys": false,
"one-line": [ "one-line": [
@ -46,7 +46,7 @@
"quotemark": false, "quotemark": false,
"radix": true, "radix": true,
"semicolon": [ "semicolon": [
"always" "never"
], ],
"triple-equals": [], "triple-equals": [],
"typedef-whitespace": [ "typedef-whitespace": [
@ -59,7 +59,7 @@
"variable-declaration": "nospace" "variable-declaration": "nospace"
} }
], ],
"variable-name": false, "variable-name": true,
"whitespace": [ "whitespace": [
true, true,
"check-branch", "check-branch",