Add no-param-reassign from eslint (#3089)

While waiting for the easterbunny I cleaned up some bad coding practice
:-)

Very open for comments especially regarding the places I commented
myself...

---------

Co-authored-by: veeck <michael@veeck.de>
This commit is contained in:
Veeck
2023-04-16 17:38:39 +02:00
committed by GitHub
parent 979f4ec664
commit 7e58b38ddf
18 changed files with 245 additions and 237 deletions

View File

@@ -218,29 +218,30 @@ Module.register("weather", {
this.nunjucksEnvironment().addFilter(
"unit",
function (value, type, valueUnit) {
let formattedValue;
if (type === "temperature") {
value = `${this.roundValue(WeatherUtils.convertTemp(value, this.config.tempUnits))}°`;
formattedValue = `${this.roundValue(WeatherUtils.convertTemp(value, this.config.tempUnits))}°`;
if (this.config.degreeLabel) {
if (this.config.tempUnits === "metric") {
value += "C";
formattedValue += "C";
} else if (this.config.tempUnits === "imperial") {
value += "F";
formattedValue += "F";
} else {
value += "K";
formattedValue += "K";
}
}
} else if (type === "precip") {
if (value === null || isNaN(value) || value === 0 || value.toFixed(2) === "0.00") {
value = "";
formattedValue = "";
} else {
value = WeatherUtils.convertPrecipitationUnit(value, valueUnit, this.config.units);
formattedValue = WeatherUtils.convertPrecipitationUnit(value, valueUnit, this.config.units);
}
} else if (type === "humidity") {
value += "%";
formattedValue = `${value}%`;
} else if (type === "wind") {
value = WeatherUtils.convertWind(value, this.config.windUnits);
formattedValue = WeatherUtils.convertWind(value, this.config.windUnits);
}
return value;
return formattedValue;
}.bind(this)
);