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/
src/assets/generated
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: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:eslint": "eslint ./src",
"lint:prettier": "prettier --check '**/*.ts' '**/*.svelte'",
"lint:eslint": "eslint ./src --fix",
"lint:prettier": "prettier --check 'src/**/*.ts' 'test/**/*.ts' 'src/**/*.svelte'",
"lint:themes": "vite-node scripts/lint.ts",
"format": "prettier --write '**/*.ts' '**/*.svelte'",
"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]
}
let allFeatures: Feature[][] = []
const allFeatures: Feature[][] = []
for (const spec of features) {
if (typeof spec === "string") {
const name = spec
@ -284,7 +284,7 @@ class ClosestNObjectFunc implements ExtraFunction {
}
const selfCenter = GeoOperations.centerpointCoordinates(feature)
let closestFeatures: { feat: any; distance: number }[] = []
const closestFeatures: { feat: any; distance: number }[] = []
for (const feats of allFeatures ?? []) {
for (const otherFeature of feats) {

View file

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

View file

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

View file

@ -297,7 +297,7 @@ export class ImageUploadManager {
let absoluteUrl: string
try {
;({ key, value, absoluteUrl } = await this._uploader.uploadImage(
({ key, value, absoluteUrl } = await this._uploader.uploadImage(
blob,
location,
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
// Let's figure out which member is neighbouring our way
let commonStartPoint: number = await this.targetNodeAt(members.indexOf(selfMember), true)
let commonEndPoint: number = await this.targetNodeAt(members.indexOf(selfMember), false)
const commonStartPoint: number = await this.targetNodeAt(members.indexOf(selfMember), true)
const commonEndPoint: number = await this.targetNodeAt(members.indexOf(selfMember), false)
// 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
const idToKeep: { id: number } = this._input.allWaysNodesInOrder

View file

@ -120,7 +120,7 @@ export default class SplitAction extends OsmChangeAction {
const allWaysNodesInOrder: number[][] = []
// Lets create OsmWays based on them
for (const wayPart of wayParts) {
let isOriginal = wayPart === longest
const isOriginal = wayPart === longest
if (isOriginal) {
// We change the existing way
const nodeIds = wayPart.map((p) => p.originalIndex)
@ -140,7 +140,7 @@ export default class SplitAction extends OsmChangeAction {
allWayIdsInOrder.push(originalElement.id)
allWaysNodesInOrder.push(nodeIds)
} else {
let id = changes.getNewID()
const id = changes.getNewID()
// Copy the tags from the original object onto the new
const kv = []
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,
// - `dist`: distance between pt 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
return {
coordinates: c,
@ -232,8 +232,8 @@ export default class SplitAction extends OsmChangeAction {
// 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
for (let i = 0; i < originalPoints.length; i++) {
let originalPoint = originalPoints[i]
let projected = GeoOperations.nearestPoint(wayGeoJson, originalPoint)
const originalPoint = originalPoints[i]
const projected = GeoOperations.nearestPoint(wayGeoJson, originalPoint)
allPoints.push({
coordinates: originalPoint,
isSplitPoint: false,

View file

@ -24,7 +24,7 @@ export default class AspectedRouting {
let functionName /*: string*/ = undefined
let functionArguments /*: any */ = undefined
let otherValues = {}
const otherValues = {}
// @ts-ignore
Object.entries(program).forEach((tag) => {
const [key, value] = tag
@ -135,9 +135,9 @@ export default class AspectedRouting {
private static getFirstMatchScore(tags, order: any) {
/*Order should be a list of arguments after evaluation*/
order = <string[]>AspectedRouting.interpret(order, tags)
for (let key of order) {
for (const key of order) {
// @ts-ignore
for (let entry of Object.entries(JSON.parse(tags))) {
for (const entry of Object.entries(JSON.parse(tags))) {
const [tagKey, value] = entry
if (key === tagKey) {
// 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)
}
let htmlContent = await Utils.download(url)
const htmlContent = await Utils.download(url)
const div = document.createElement("div")
div.innerHTML = htmlContent
const script = Array.from(div.getElementsByTagName("script")).find(

View file

@ -234,7 +234,7 @@ export default class Wikidata {
}[]
> {
const maxCount = options?.maxCount ?? 20
let pageCount = Math.min(maxCount, 50)
const pageCount = Math.min(maxCount, 50)
const start = page * pageCount - pageCount
const lang = options?.lang ?? "en"
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))
if (funcs.has("list_reviews")) {
;(<(string | TagRenderingConfigJson)[]>json.titleIcons).push("icons.rating")
(<(string | TagRenderingConfigJson)[]>json.titleIcons).push("icons.rating")
}
return json
}

View file

@ -18,7 +18,7 @@ export default class ExtraLinkConfig {
this.newTab = configJson.newTab
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))) {
throw (
"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
* */
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 (deflt === undefined) {
return undefined

View file

@ -86,7 +86,7 @@ export class Tiles {
static asGeojson(zIndex: number, x?: number, y?: number): Feature<Polygon> {
let z = zIndex
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)
return new BBox(bounds).asGeoJson()

View file

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

View file

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

View file

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

View file

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

View file

@ -33,7 +33,7 @@ export class ShareLinkViz implements SpecialVisualizationSvelte {
const generateShareData = () => {
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 =
matchingLayer?.title?.GetRenderValue(tagSource.data)?.Subs(tagSource.data)?.txt ??
tagSource.data?.name ??

View file

@ -80,7 +80,7 @@ export default class TagApplyButton implements AutoAction, SpecialVisualization
const newTags: Tag[] = []
for (const [key, value] of tgsSpec) {
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
let actualValue = parts[0]
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
const matchWithFuncName = stackItem.match(regex)
if (matchWithFuncName) {
;[_, functionName, path, line, column] = matchWithFuncName
[_, functionName, path, line, column] = matchWithFuncName
} else {
const regexNoFuncName: RegExp = new RegExp("at ([a-zA-Z0-9-/.]+):([0-9]+):([0-9]+)")
;[_, path, line, column] = stackItem.match(regexNoFuncName)

View file

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

View file

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

View file

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