diff --git a/.eslintignore b/.eslintignore index 472150eeb..944effc72 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1,2 @@ -src/test.ts \ No newline at end of file +src/test.ts +android/* diff --git a/.prettierignore b/.prettierignore index ae756d365..a78f7a20b 100644 --- a/.prettierignore +++ b/.prettierignore @@ -13,3 +13,4 @@ Docs/Schemas/ Docs/TagInfo/ src/assets/generated src/assets/svg +android/ diff --git a/package.json b/package.json index a868aef6b..7ae1bec02 100644 --- a/package.json +++ b/package.json @@ -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'", diff --git a/src/Logic/ExtraFunctions.ts b/src/Logic/ExtraFunctions.ts index 32bd2d7f7..b28dcbc50 100644 --- a/src/Logic/ExtraFunctions.ts +++ b/src/Logic/ExtraFunctions.ts @@ -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) { diff --git a/src/Logic/FeatureSource/Sources/FeatureSourceMerger.ts b/src/Logic/FeatureSource/Sources/FeatureSourceMerger.ts index 296588984..1e2ab4513 100644 --- a/src/Logic/FeatureSource/Sources/FeatureSourceMerger.ts +++ b/src/Logic/FeatureSource/Sources/FeatureSourceMerger.ts @@ -25,7 +25,7 @@ export default class FeatureSourceMerger { self.addDataFromSources(sources) }) diff --git a/src/Logic/FeatureSource/TiledFeatureSource/PolygonSourceMerger.ts b/src/Logic/FeatureSource/TiledFeatureSource/PolygonSourceMerger.ts index 716db8e27..a1e6be2b8 100644 --- a/src/Logic/FeatureSource/TiledFeatureSource/PolygonSourceMerger.ts +++ b/src/Logic/FeatureSource/TiledFeatureSource/PolygonSourceMerger.ts @@ -34,7 +34,7 @@ export class PolygonSourceMerger extends UpdatableDynamicTileSource< const zooms: Map = 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")) { diff --git a/src/Logic/ImageProviders/ImageUploadManager.ts b/src/Logic/ImageProviders/ImageUploadManager.ts index 4e3345e31..d9f0ac0e2 100644 --- a/src/Logic/ImageProviders/ImageUploadManager.ts +++ b/src/Logic/ImageProviders/ImageUploadManager.ts @@ -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, diff --git a/src/Logic/Osm/Actions/RelationSplitHandler.ts b/src/Logic/Osm/Actions/RelationSplitHandler.ts index 3cdc6cc43..755cf0080 100644 --- a/src/Logic/Osm/Actions/RelationSplitHandler.ts +++ b/src/Logic/Osm/Actions/RelationSplitHandler.ts @@ -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 diff --git a/src/Logic/Osm/Actions/SplitAction.ts b/src/Logic/Osm/Actions/SplitAction.ts index 7062bec6f..efbb21f8f 100644 --- a/src/Logic/Osm/Actions/SplitAction.ts +++ b/src/Logic/Osm/Actions/SplitAction.ts @@ -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, diff --git a/src/Logic/Osm/aspectedRouting.ts b/src/Logic/Osm/aspectedRouting.ts index bd2fa9f7f..a83477db7 100644 --- a/src/Logic/Osm/aspectedRouting.ts +++ b/src/Logic/Osm/aspectedRouting.ts @@ -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 = 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 diff --git a/src/Logic/Web/LinkedDataLoader.ts b/src/Logic/Web/LinkedDataLoader.ts index 07dd83098..8c477677e 100644 --- a/src/Logic/Web/LinkedDataLoader.ts +++ b/src/Logic/Web/LinkedDataLoader.ts @@ -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( diff --git a/src/Logic/Web/Wikidata.ts b/src/Logic/Web/Wikidata.ts index 50573f2dd..6a23371a6 100644 --- a/src/Logic/Web/Wikidata.ts +++ b/src/Logic/Web/Wikidata.ts @@ -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 = diff --git a/src/Models/ThemeConfig/Conversion/PrepareLayer.ts b/src/Models/ThemeConfig/Conversion/PrepareLayer.ts index 3f9c37b09..23aa239ad 100644 --- a/src/Models/ThemeConfig/Conversion/PrepareLayer.ts +++ b/src/Models/ThemeConfig/Conversion/PrepareLayer.ts @@ -930,7 +930,7 @@ export class AddRatingBadge extends DesugaringStep { const funcs = new Set(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 } diff --git a/src/Models/ThemeConfig/ExtraLinkConfig.ts b/src/Models/ThemeConfig/ExtraLinkConfig.ts index 333d74d2d..ec13da2c3 100644 --- a/src/Models/ThemeConfig/ExtraLinkConfig.ts +++ b/src/Models/ThemeConfig/ExtraLinkConfig.ts @@ -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(("no-" + requirement))) { throw ( "Conflicting requirements found for " + diff --git a/src/Models/ThemeConfig/WithContextLoader.ts b/src/Models/ThemeConfig/WithContextLoader.ts index 46d16e281..b46a9e20e 100644 --- a/src/Models/ThemeConfig/WithContextLoader.ts +++ b/src/Models/ThemeConfig/WithContextLoader.ts @@ -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 diff --git a/src/Models/TileRange.ts b/src/Models/TileRange.ts index d4494da6d..0e8353033 100644 --- a/src/Models/TileRange.ts +++ b/src/Models/TileRange.ts @@ -86,7 +86,7 @@ export class Tiles { static asGeojson(zIndex: number, x?: number, y?: number): Feature { 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() diff --git a/src/UI/Base/Hotkeys.ts b/src/UI/Base/Hotkeys.ts index fb714230f..f2f601d57 100644 --- a/src/UI/Base/Hotkeys.ts +++ b/src/UI/Base/Hotkeys.ts @@ -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)] diff --git a/src/UI/Base/LoginButton.svelte b/src/UI/Base/LoginButton.svelte index 011732003..f70865b8f 100644 --- a/src/UI/Base/LoginButton.svelte +++ b/src/UI/Base/LoginButton.svelte @@ -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") } diff --git a/src/UI/BaseUIElement.ts b/src/UI/BaseUIElement.ts index 05cfa1ab2..d21f29224 100644 --- a/src/UI/BaseUIElement.ts +++ b/src/UI/BaseUIElement.ts @@ -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) diff --git a/src/UI/Comparison/ComparisonState.ts b/src/UI/Comparison/ComparisonState.ts index ee4b19c2a..736e68faa 100644 --- a/src/UI/Comparison/ComparisonState.ts +++ b/src/UI/Comparison/ComparisonState.ts @@ -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("_")) { diff --git a/src/UI/Popup/ShareLinkViz.ts b/src/UI/Popup/ShareLinkViz.ts index 487573664..fe6a92138 100644 --- a/src/UI/Popup/ShareLinkViz.ts +++ b/src/UI/Popup/ShareLinkViz.ts @@ -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 ?? diff --git a/src/UI/Popup/TagApplyButton.ts b/src/UI/Popup/TagApplyButton.ts index 2b8fc1164..03c0672d8 100644 --- a/src/UI/Popup/TagApplyButton.ts +++ b/src/UI/Popup/TagApplyButton.ts @@ -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() diff --git a/src/Utils.ts b/src/Utils.ts index d65a7e6fd..448827c3a 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -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) diff --git a/src/Utils/dragDetection.ts b/src/Utils/dragDetection.ts index bf9459fd1..f8ee3d015 100644 --- a/src/Utils/dragDetection.ts +++ b/src/Utils/dragDetection.ts @@ -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) => { diff --git a/src/service-worker.ts b/src/service-worker.ts index 73dc590b8..7cba05b54 100644 --- a/src/service-worker.ts +++ b/src/service-worker.ts @@ -24,8 +24,8 @@ async function activate() { } async function fetchAndCache(event: ServiceWorkerFetchEvent): Promise { - 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 diff --git a/tslint.json b/tslint.json index 0cd44d383..08ee41fce 100644 --- a/tslint.json +++ b/tslint.json @@ -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",