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)) {
for (const e of loadCsv(file)) {
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
* @param origPath

View file

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

View file

@ -112,7 +112,7 @@ export class Conflate extends Script {
const changedObjects: OsmObject[] = []
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 status = resting_properties["status"]
delete resting_properties["status"]

View file

@ -30,17 +30,6 @@ t.OnEveryLanguage((txt, ln) => {
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[]) {
const allKeys = new Set<string>(Object.keys(object))
const copy = {}
@ -54,38 +43,6 @@ function reorder(object: object, order: string[]) {
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()
for (const layerFile of layerFiles) {
try {
@ -95,7 +52,6 @@ for (const layerFile of layerFiles) {
ConversionContext.construct([layerFile.path.split("/").at(-1)], ["update legacy"])
)
)
addArticleToPresets(fixed)
const reordered = reorder(fixed, layerAttributesOrder)
writeFileSync(layerFile.path, JSON.stringify(reordered, null, " ") + "\n")
} catch (e) {
@ -110,11 +66,7 @@ for (const themeFile of themeFiles) {
themeFile.parsed,
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)
const endsWithNewline = themeFile.raw.at(-1) === "\n"
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>>) {
const id = feature.properties.id.replace("/", "-")
const pref = this._osmConnection.GetPreference("favourite-" + id)
this._osmConnection.preferencesHandler.removeAllWithPrefix("mapcomplete-favourite-" + id)
if (tags) {
delete tags.data._favourite

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -20,11 +20,11 @@ export default class ComparingTag implements TagsFilter {
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"
}
asHumanString(linkToWiki: boolean, shorten: boolean, properties: Record<string, string>) {
asHumanString() {
return this._key + this._representation + this._boundary
}

View file

@ -122,7 +122,7 @@ export default class ThemeViewStateHashActor {
private loadStateFromHash(hash: string) {
const state = this._state
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) {
if (part === name) {
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")
}
convert(json: T, context: ConversionContext): T {
convert(json: T, _: ConversionContext): T {
return json
}
}
@ -304,7 +304,7 @@ export class SetDefault<T> extends DesugaringStep<T> {
this._overrideEmptyString = overrideEmptyString
}
convert(json: T, context: ConversionContext): T {
convert(json: T, _: ConversionContext): T {
if (json === undefined) {
return undefined
}

View file

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

View file

@ -589,7 +589,7 @@ export class AddEditingElements extends DesugaringStep<LayerConfigJson> {
this._desugaring = desugaring
}
convert(json: LayerConfigJson, context: ConversionContext): LayerConfigJson {
convert(json: LayerConfigJson, _: ConversionContext): LayerConfigJson {
if (this._desugaring.tagRenderings === null) {
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") {
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) {
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
if (overrideAll === undefined) {
return json

View file

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

View file

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

View file

@ -21,8 +21,7 @@ export class ImageCarousel extends Toggle {
changes?: Changes
layout: LayoutConfig
previewedImage?: UIEventSource<ProvidedImage>
},
feature: Feature
}
) {
const uiElements = images.map(
(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
}
IsValid(t: boolean): boolean {
IsValid(_: boolean): boolean {
return true
}
@ -298,7 +298,7 @@ export class SearchablePillsSelector<T> extends Combine implements InputElement<
return this.selectedElements
}
IsValid(t: T[]): boolean {
IsValid(_: T[]): boolean {
return true
}
}

View file

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

View file

@ -71,7 +71,7 @@ export abstract class Validator {
return Translations.t.validation[this.name].description
}
public isValid(key: string, getCountry?: () => string): boolean {
public isValid(_: string): boolean {
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>` ")
}
isValid(value: string, getCountry?: () => string): boolean {
isValid(value: string): boolean {
try {
JSON.parse(value)
return true

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -51,8 +51,7 @@ export class PointImportButtonViz implements SpecialVisualization {
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>,
argument: string[],
feature: Feature,
layer: LayerConfig
feature: Feature
): BaseUIElement {
if (feature.geometry.type !== "Point") {
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 Toggle from "../Input/Toggle"
import { Feature } from "geojson"
class xyz {}
export class LanguageElement implements SpecialVisualization {
funcName: string = "language_chooser"
needsUrls = []

View file

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

View file

@ -171,7 +171,7 @@
}
}
function onSave(e = undefined, deleteFreeform = false) {
function onSave(_ = undefined) {
if (selectedTags === undefined) {
return
}
@ -395,7 +395,7 @@
<slot name="cancel" />
<slot name="save-button" {selectedTags}>
{#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" />
<Tr t={Translations.t.general.eraseValue}/>
</button>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -698,7 +698,7 @@ class SvgToPdfPage {
}
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
*/
private async prepareMap(mapSpec: SVGTSpanElement, loadData: boolean): Promise<void> {
private async prepareMap(mapSpec: SVGTSpanElement): Promise<void> {
if (this.options.disableMaps) {
return
}

View file

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

View file

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