Chore: Remove unused variables

This commit is contained in:
Pieter Vander Vennet 2024-01-24 23:45:20 +01:00
parent 1a415f4815
commit e68b31e267
42 changed files with 48 additions and 106 deletions

View file

@ -225,6 +225,7 @@ function run(file, protojson) {
} }
// noinspection JSUnusedLocalSymbols
async function queryTagInfo(file, type, clean: ((s: string) => string)) { async function queryTagInfo(file, type, clean: ((s: string) => string)) {
for (const e of loadCsv(file)) { for (const e of loadCsv(file)) {
const value = await ScriptUtils.TagInfoHistogram(e.key + ":" + type) const value = await ScriptUtils.TagInfoHistogram(e.key + ":" + type)
@ -252,6 +253,7 @@ async function queryTagInfo(file, type, clean: ((s: string) => string)) {
} }
} }
// noinspection JSUnusedLocalSymbols
/** /**
* Adds the translations into the 'newConfig' object * Adds the translations into the 'newConfig' object
* @param origPath * @param origPath

View file

@ -39,7 +39,7 @@ export default class ScriptUtils {
public static DownloadFileTo(url, targetFilePath: string): Promise<void> { public static DownloadFileTo(url, targetFilePath: string): Promise<void> {
ScriptUtils.erasableLog("Downloading", url, "to", targetFilePath) ScriptUtils.erasableLog("Downloading", url, "to", targetFilePath)
return new Promise<void>((resolve, err) => { return new Promise<void>((resolve) => {
https.get(url, (res) => { https.get(url, (res) => {
const filePath = fs.createWriteStream(targetFilePath) const filePath = fs.createWriteStream(targetFilePath)
res.pipe(filePath) res.pipe(filePath)

View file

@ -112,7 +112,7 @@ export class Conflate extends Script {
const changedObjects: OsmObject[] = [] const changedObjects: OsmObject[] = []
for (const { match, replayed } of bestMatches) { for (const { match, replayed } of bestMatches) {
const { external_feature, d, osm_feature } = match const { d, osm_feature } = match
const { possibly_imported, certainly_imported, resting_properties } = replayed const { possibly_imported, certainly_imported, resting_properties } = replayed
const status = resting_properties["status"] const status = resting_properties["status"]
delete resting_properties["status"] delete resting_properties["status"]

View file

@ -30,17 +30,6 @@ t.OnEveryLanguage((txt, ln) => {
return txt return txt
}) })
const articles = {
/* de: "eine",
es: 'una',
fr: 'une',
it: 'una',
nb_NO: 'en',
nl: 'een',
pt: 'uma',
pt_BR : 'uma',//*/
}
function reorder(object: object, order: string[]) { function reorder(object: object, order: string[]) {
const allKeys = new Set<string>(Object.keys(object)) const allKeys = new Set<string>(Object.keys(object))
const copy = {} const copy = {}
@ -54,38 +43,6 @@ function reorder(object: object, order: string[]) {
return copy return copy
} }
function addArticleToPresets(layerConfig: { presets?: { title: any }[] }) {
/*
if(layerConfig.presets === undefined){
return
}
for (const preset of layerConfig.presets) {
preset.title = new Translation(preset.title, "autofix")
.OnEveryLanguage((txt, lang) => {
let article = articles[lang]
if(lang === "en"){
if(["a","e","u","o","i"].some(vowel => txt.toLowerCase().startsWith(vowel))) {
article = "an"
}else{
article = "a"
}
}
if(article === undefined){
return txt;
}
if(txt.startsWith(article+" ")){
return txt;
}
if(txt.startsWith("an ")){
return txt;
}
return article +" " + txt.toLowerCase();
})
.translations
}
//*/
}
const layerFiles = ScriptUtils.getLayerFiles() const layerFiles = ScriptUtils.getLayerFiles()
for (const layerFile of layerFiles) { for (const layerFile of layerFiles) {
try { try {
@ -95,7 +52,6 @@ for (const layerFile of layerFiles) {
ConversionContext.construct([layerFile.path.split("/").at(-1)], ["update legacy"]) ConversionContext.construct([layerFile.path.split("/").at(-1)], ["update legacy"])
) )
) )
addArticleToPresets(fixed)
const reordered = reorder(fixed, layerAttributesOrder) const reordered = reorder(fixed, layerAttributesOrder)
writeFileSync(layerFile.path, JSON.stringify(reordered, null, " ") + "\n") writeFileSync(layerFile.path, JSON.stringify(reordered, null, " ") + "\n")
} catch (e) { } catch (e) {
@ -110,11 +66,7 @@ for (const themeFile of themeFiles) {
themeFile.parsed, themeFile.parsed,
ConversionContext.construct([themeFile.path.split("/").at(-1)], ["update legacy layer"]) ConversionContext.construct([themeFile.path.split("/").at(-1)], ["update legacy layer"])
) )
for (const layer of fixed.layers) {
if (layer["presets"] !== undefined) {
addArticleToPresets(<any>layer)
}
}
// extractInlineLayer(fixed) // extractInlineLayer(fixed)
const endsWithNewline = themeFile.raw.at(-1) === "\n" const endsWithNewline = themeFile.raw.at(-1) === "\n"
const ordered = reorder(fixed, themeAttributesOrder) const ordered = reorder(fixed, themeAttributesOrder)

View file

@ -159,7 +159,6 @@ export default class FavouritesFeatureSource extends StaticFeatureSource {
public removeFavourite(feature: Feature, tags?: UIEventSource<Record<string, string>>) { public removeFavourite(feature: Feature, tags?: UIEventSource<Record<string, string>>) {
const id = feature.properties.id.replace("/", "-") const id = feature.properties.id.replace("/", "-")
const pref = this._osmConnection.GetPreference("favourite-" + id)
this._osmConnection.preferencesHandler.removeAllWithPrefix("mapcomplete-favourite-" + id) this._osmConnection.preferencesHandler.removeAllWithPrefix("mapcomplete-favourite-" + id)
if (tags) { if (tags) {
delete tags.data._favourite delete tags.data._favourite

View file

@ -46,7 +46,6 @@ export default class LayoutSource extends FeatureSourceMerger {
) )
const overpassSource = LayoutSource.setupOverpass( const overpassSource = LayoutSource.setupOverpass(
backend,
osmLayers, osmLayers,
bounds, bounds,
zoom, zoom,
@ -132,7 +131,6 @@ export default class LayoutSource extends FeatureSourceMerger {
} }
private static setupOverpass( private static setupOverpass(
backend: string,
osmLayers: LayerConfig[], osmLayers: LayerConfig[],
bounds: Store<BBox>, bounds: Store<BBox>,
zoom: Store<number>, zoom: Store<number>,

View file

@ -48,7 +48,7 @@ export default class NearbyFeatureSource implements FeatureSource {
flayer.layerDef.minzoom, flayer.layerDef.minzoom,
flayer.isDisplayed flayer.isDisplayed
) )
calcSource.addCallbackAndRunD((features) => { calcSource.addCallbackAndRunD(() => {
this.update() this.update()
}) })
this._allSources.push(calcSource) this._allSources.push(calcSource)

View file

@ -103,7 +103,7 @@ export default class OverpassFeatureSource implements FeatureSource {
if (!result) { if (!result) {
return return
} }
const [bounds, date, updatedLayers] = result const [bounds, _, _] = result
this._lastQueryBBox = bounds this._lastQueryBBox = bounds
} }

View file

@ -133,7 +133,7 @@ export class Mapillary extends ImageProvider {
return [this.PrepareUrlAsync(key, value)] return [this.PrepareUrlAsync(key, value)]
} }
public async DownloadAttribution(url: string): Promise<LicenseInfo> { public async DownloadAttribution(_: string): Promise<LicenseInfo> {
const license = new LicenseInfo() const license = new LicenseInfo()
license.artist = undefined license.artist = undefined
license.license = "CC BY-SA 4.0" license.license = "CC BY-SA 4.0"

View file

@ -416,7 +416,7 @@ export class OsmConnection {
): Promise<{ id: number }> { ): Promise<{ id: number }> {
if (this._dryRun.data) { if (this._dryRun.data) {
console.warn("Dryrun enabled - not actually uploading GPX ", gpx) console.warn("Dryrun enabled - not actually uploading GPX ", gpx)
return new Promise<{ id: number }>((ok, error) => { return new Promise<{ id: number }>((ok) => {
window.setTimeout( window.setTimeout(
() => ok({ id: Math.floor(Math.random() * 1000) }), () => ok({ id: Math.floor(Math.random() * 1000) }),
Math.random() * 5000 Math.random() * 5000

View file

@ -615,7 +615,7 @@ export default class SimpleMetaTaggers {
isLazy: true, isLazy: true,
includesDates: true, includesDates: true,
}, },
(feature, layer, tagsStore) => { (feature) => {
Utils.AddLazyProperty(feature.properties, "_last_edit:passed_time", () => { Utils.AddLazyProperty(feature.properties, "_last_edit:passed_time", () => {
const lastEditTimestamp = new Date( const lastEditTimestamp = new Date(
feature.properties["_last_edit:timestamp"] feature.properties["_last_edit:timestamp"]

View file

@ -20,11 +20,11 @@ export default class ComparingTag implements TagsFilter {
this._boundary = boundary this._boundary = boundary
} }
asChange(properties: Record<string, string>): { k: string; v: string }[] { asChange(_: Record<string, string>): { k: string; v: string }[] {
throw "A comparable tag can not be used to be uploaded to OSM" throw "A comparable tag can not be used to be uploaded to OSM"
} }
asHumanString(linkToWiki: boolean, shorten: boolean, properties: Record<string, string>) { asHumanString() {
return this._key + this._representation + this._boundary return this._key + this._representation + this._boundary
} }

View file

@ -122,7 +122,7 @@ export default class ThemeViewStateHashActor {
private loadStateFromHash(hash: string) { private loadStateFromHash(hash: string) {
const state = this._state const state = this._state
const parts = hash.split(":") const parts = hash.split(":")
outer: for (const { toggle, name, showOverOthers, submenu } of state.guistate.allToggles) { outer: for (const { toggle, name, submenu } of state.guistate.allToggles) {
for (const part of parts) { for (const part of parts) {
if (part === name) { if (part === name) {
toggle.setData(true) toggle.setData(true)

View file

@ -173,7 +173,7 @@ export class Pass<T> extends Conversion<T, T> {
super(message ?? "Does nothing, often to swap out steps in testing", [], "Pass") super(message ?? "Does nothing, often to swap out steps in testing", [], "Pass")
} }
convert(json: T, context: ConversionContext): T { convert(json: T, _: ConversionContext): T {
return json return json
} }
} }
@ -304,7 +304,7 @@ export class SetDefault<T> extends DesugaringStep<T> {
this._overrideEmptyString = overrideEmptyString this._overrideEmptyString = overrideEmptyString
} }
convert(json: T, context: ConversionContext): T { convert(json: T, _: ConversionContext): T {
if (json === undefined) { if (json === undefined) {
return undefined return undefined
} }

View file

@ -24,7 +24,7 @@ export default class CreateNoteImportLayer extends Conversion<LayerConfigJson, L
this._includeClosedNotesDays = includeClosedNotesDays this._includeClosedNotesDays = includeClosedNotesDays
} }
convert(layerJson: LayerConfigJson, context: ConversionContext): LayerConfigJson { convert(layerJson: LayerConfigJson, _: ConversionContext): LayerConfigJson {
const t = Translations.t.importLayer const t = Translations.t.importLayer
/** /**

View file

@ -589,7 +589,7 @@ export class AddEditingElements extends DesugaringStep<LayerConfigJson> {
this._desugaring = desugaring this._desugaring = desugaring
} }
convert(json: LayerConfigJson, context: ConversionContext): LayerConfigJson { convert(json: LayerConfigJson, _: ConversionContext): LayerConfigJson {
if (this._desugaring.tagRenderings === null) { if (this._desugaring.tagRenderings === null) {
return json return json
} }
@ -1088,7 +1088,7 @@ class AddFavouriteBadges extends DesugaringStep<LayerConfigJson> {
) )
} }
convert(json: LayerConfigJson, context: ConversionContext): LayerConfigJson { convert(json: LayerConfigJson, _: ConversionContext): LayerConfigJson {
if (json.source === "special" || json.source === "special:library") { if (json.source === "special" || json.source === "special:library") {
return json return json
} }
@ -1113,7 +1113,7 @@ export class AddRatingBadge extends DesugaringStep<LayerConfigJson> {
) )
} }
convert(json: LayerConfigJson, context: ConversionContext): LayerConfigJson { convert(json: LayerConfigJson, _: ConversionContext): LayerConfigJson {
if (!json.tagRenderings) { if (!json.tagRenderings) {
return json return json
} }

View file

@ -301,7 +301,7 @@ class ApplyOverrideAll extends DesugaringStep<LayoutConfigJson> {
) )
} }
convert(json: LayoutConfigJson, context: ConversionContext): LayoutConfigJson { convert(json: LayoutConfigJson, _: ConversionContext): LayoutConfigJson {
const overrideAll = json.overrideAll const overrideAll = json.overrideAll
if (overrideAll === undefined) { if (overrideAll === undefined) {
return json return json

View file

@ -27,7 +27,7 @@
mapExtent: state.mapProperties.bounds.data, mapExtent: state.mapProperties.bounds.data,
width: maindiv.offsetWidth, width: maindiv.offsetWidth,
height: maindiv.offsetHeight, height: maindiv.offsetHeight,
noSelfIntersectingLines: true, noSelfIntersectingLines,
}) })
} }
</script> </script>

View file

@ -26,7 +26,7 @@
on:click={() => { on:click={() => {
previewedImage?.setData(image) previewedImage?.setData(image)
}} }}
on:error={(event) => { on:error={() => {
if (fallbackImage) { if (fallbackImage) {
imgEl.src = fallbackImage imgEl.src = fallbackImage
} }

View file

@ -21,8 +21,7 @@ export class ImageCarousel extends Toggle {
changes?: Changes changes?: Changes
layout: LayoutConfig layout: LayoutConfig
previewedImage?: UIEventSource<ProvidedImage> previewedImage?: UIEventSource<ProvidedImage>
}, }
feature: Feature
) { ) {
const uiElements = images.map( const uiElements = images.map(
(imageURLS: { key: string; url: string; provider: ImageProvider; id: string }[]) => { (imageURLS: { key: string; url: string; provider: ImageProvider; id: string }[]) => {

View file

@ -98,7 +98,7 @@ class SelfHidingToggle extends UIElement implements InputElement<boolean> {
return this._selected return this._selected
} }
IsValid(t: boolean): boolean { IsValid(_: boolean): boolean {
return true return true
} }
@ -298,7 +298,7 @@ export class SearchablePillsSelector<T> extends Combine implements InputElement<
return this.selectedElements return this.selectedElements
} }
IsValid(t: T[]): boolean { IsValid(_: T[]): boolean {
return true return true
} }
} }

View file

@ -23,7 +23,7 @@
function update() { function update() {
const v = currentVal.data const v = currentVal.data
const l = currentLang.data const l = currentLang.data
if (translations.data === "" || translations.data === undefined) { if (<any> translations.data === "" || translations.data === undefined) {
translations.data = {} translations.data = {}
} }
if (translations.data[l] === v) { if (translations.data[l] === v) {
@ -44,7 +44,7 @@
) )
onDestroy( onDestroy(
currentVal.addCallbackAndRunD((v) => { currentVal.addCallbackAndRunD(() => {
update() update()
}) })
) )

View file

@ -71,7 +71,7 @@ export abstract class Validator {
return Translations.t.validation[this.name].description return Translations.t.validation[this.name].description
} }
public isValid(key: string, getCountry?: () => string): boolean { public isValid(_: string): boolean {
return true return true
} }

View file

@ -6,7 +6,7 @@ export default class TranslationValidator extends Validator {
super("translation", "Makes sure the the string is of format `Record<string, string>` ") super("translation", "Makes sure the the string is of format `Record<string, string>` ")
} }
isValid(value: string, getCountry?: () => string): boolean { isValid(value: string): boolean {
try { try {
JSON.parse(value) JSON.parse(value)
return true return true

View file

@ -136,7 +136,7 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap {
map.on("dblclick", (e) => { map.on("dblclick", (e) => {
handleClick(e) handleClick(e)
}) })
map.on("rotateend", (e) => { map.on("rotateend", (_) => {
this.updateStores() this.updateStores()
}) })
map.getContainer().addEventListener("keydown", (event) => { map.getContainer().addEventListener("keydown", (event) => {

View file

@ -145,7 +145,7 @@ export default class OpeningHoursInput extends InputElement<string> {
return this._value return this._value
} }
IsValid(t: string): boolean { IsValid(_: string): boolean {
return true return true
} }

View file

@ -23,7 +23,7 @@ export default class OpeningHoursPicker extends InputElement<OpeningHour[]> {
return this._ohs return this._ohs
} }
IsValid(t: OpeningHour[]): boolean { IsValid(_: OpeningHour[]): boolean {
return true return true
} }

View file

@ -37,7 +37,7 @@ export default class OpeningHoursPickerTable extends InputElement<OpeningHour[]>
this.SetClass("w-full block") this.SetClass("w-full block")
} }
IsValid(t: OpeningHour[]): boolean { IsValid(_: OpeningHour[]): boolean {
return true return true
} }

View file

@ -21,7 +21,7 @@ export default class PublicHolidayInput extends InputElement<string> {
return this._value return this._value
} }
IsValid(t: string): boolean { IsValid(_: string): boolean {
return true return true
} }

View file

@ -86,8 +86,7 @@ export default class ConflateImportButtonViz implements SpecialVisualization, Au
state: SpecialVisualizationState, state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>, tagSource: UIEventSource<Record<string, string>>,
argument: string[], argument: string[],
feature: Feature, feature: Feature
layer: LayerConfig
): BaseUIElement { ): BaseUIElement {
const canBeImported = const canBeImported =
feature.geometry.type === "LineString" || feature.geometry.type === "LineString" ||

View file

@ -51,8 +51,7 @@ export class PointImportButtonViz implements SpecialVisualization {
state: SpecialVisualizationState, state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>, tagSource: UIEventSource<Record<string, string>>,
argument: string[], argument: string[],
feature: Feature, feature: Feature
layer: LayerConfig
): BaseUIElement { ): BaseUIElement {
if (feature.geometry.type !== "Point") { if (feature.geometry.type !== "Point") {
return Translations.t.general.add.import.wrongType.SetClass("alert") return Translations.t.general.add.import.wrongType.SetClass("alert")

View file

@ -17,7 +17,7 @@ import { EditButton, SaveButton } from "./SaveButton"
import Translations from "../i18n/Translations" import Translations from "../i18n/Translations"
import Toggle from "../Input/Toggle" import Toggle from "../Input/Toggle"
import { Feature } from "geojson" import { Feature } from "geojson"
class xyz {}
export class LanguageElement implements SpecialVisualization { export class LanguageElement implements SpecialVisualization {
funcName: string = "language_chooser" funcName: string = "language_chooser"
needsUrls = [] needsUrls = []

View file

@ -18,8 +18,7 @@ export class AddNoteCommentViz implements SpecialVisualization {
public constr( public constr(
state: SpecialVisualizationState, state: SpecialVisualizationState,
tags: UIEventSource<Record<string, string>>, tags: UIEventSource<Record<string, string>>
args: string[]
) { ) {
return new SvelteUIElement(AddNoteComment, { state, tags }) return new SvelteUIElement(AddNoteComment, { state, tags })
} }

View file

@ -171,7 +171,7 @@
} }
} }
function onSave(e = undefined, deleteFreeform = false) { function onSave(_ = undefined) {
if (selectedTags === undefined) { if (selectedTags === undefined) {
return return
} }
@ -395,7 +395,7 @@
<slot name="cancel" /> <slot name="cancel" />
<slot name="save-button" {selectedTags}> <slot name="save-button" {selectedTags}>
{#if allowDeleteOfFreeform && mappings?.length === 0 && $freeformInput === undefined && $freeformInputUnvalidated === ""} {#if allowDeleteOfFreeform && mappings?.length === 0 && $freeformInput === undefined && $freeformInputUnvalidated === ""}
<button class="primary flex" on:click|stopPropagation|preventDefault={_ => onSave(_, true)}> <button class="primary flex" on:click|stopPropagation|preventDefault={onSave}>
<TrashIcon class="w-6 h-6 text-red-500" /> <TrashIcon class="w-6 h-6 text-red-500" />
<Tr t={Translations.t.general.eraseValue}/> <Tr t={Translations.t.general.eraseValue}/>
</button> </button>

View file

@ -77,7 +77,7 @@
on:hover={(e) => { on:hover={(e) => {
score = e.detail.score score = e.detail.score
}} }}
on:mouseout={(e) => { on:mouseout={() => {
score = null score = null
}} }}
score={score ?? confirmedScore ?? 0} score={score ?? confirmedScore ?? 0}

View file

@ -681,8 +681,7 @@ export default class SpecialVisualizations {
return new ImageCarousel( return new ImageCarousel(
AllImageProviders.LoadImagesFor(tags, imagePrefixes), AllImageProviders.LoadImagesFor(tags, imagePrefixes),
tags, tags,
state, state
feature
) )
}, },
}, },

View file

@ -119,7 +119,7 @@ export abstract class EditJsonState<T> {
this.setValueAt(path, v) this.setValueAt(path, v)
}) })
this._stores.set(key, store) this._stores.set(key, store)
this.configuration.addCallbackD((config) => { this.configuration.addCallbackD(() => {
store.setData(this.getCurrentValueFor(path)) store.setData(this.getCurrentValueFor(path))
}) })
return store return store

View file

@ -6,13 +6,11 @@
export let state: EditLayerState export let state: EditLayerState
export let path: (string | number)[] = [] export let path: (string | number)[] = []
export let schema: ConfigMeta let value = new UIEventSource<Record<string,string>>({})
let value = new UIEventSource<string>({})
console.log("Registering translation to path", path) console.log("Registering translation to path", path)
state.register( state.register(
path, path,
value.mapD((v) => JSON.parse(value.data)) value.mapD(() => JSON.parse(value.data))
) )
</script> </script>

View file

@ -20,7 +20,6 @@ export default class StudioServer {
category: "layers" | "themes" category: "layers" | "themes"
}[] }[]
> { > {
const uid = this._userId.data
const { allFiles } = <{ allFiles: string[] }>( const { allFiles } = <{ allFiles: string[] }>(
await Utils.downloadJson(this.url + "/overview") await Utils.downloadJson(this.url + "/overview")
) )

View file

@ -698,7 +698,7 @@ class SvgToPdfPage {
} }
for (const mapSpec of mapSpecs) { for (const mapSpec of mapSpecs) {
await this.prepareMap(mapSpec, !this.options?.disableDataLoading) await this.prepareMap(mapSpec)
} }
} }
@ -840,7 +840,7 @@ class SvgToPdfPage {
/** /**
* Replaces a mapSpec with the appropriate map * Replaces a mapSpec with the appropriate map
*/ */
private async prepareMap(mapSpec: SVGTSpanElement, loadData: boolean): Promise<void> { private async prepareMap(mapSpec: SVGTSpanElement): Promise<void> {
if (this.options.disableMaps) { if (this.options.disableMaps) {
return return
} }

View file

@ -884,7 +884,6 @@ describe("ReplaceGeometryAction", () => {
) )
it("should move nodes accordingly", async () => { it("should move nodes accordingly", async () => {
const layout = new LayoutConfig(<any>grbStripped)
const bbox = new BBox([ const bbox = new BBox([
[3.2166673243045807, 51.21467321525788], [3.2166673243045807, 51.21467321525788],

View file

@ -6,7 +6,7 @@ import { Changes } from "../../../src/Logic/Osm/Changes"
import { describe, expect, it } from "vitest" import { describe, expect, it } from "vitest"
function elstorage() { function elstorage() {
return { addAlias: (a, b) => {} } return { addAlias: (_, __) => {} }
} }
describe("ChangesetHanlder", () => { describe("ChangesetHanlder", () => {