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

@@ -32,17 +32,19 @@ const WeatherUtils = {
* @returns {string} - A string with tha value and a unit postfix.
*/
convertPrecipitationUnit(value, valueUnit, outputUnit) {
let convertedValue = value;
let conversionUnit = valueUnit;
if (outputUnit === "imperial") {
if (valueUnit && valueUnit.toLowerCase() === "cm") value = value * 0.3937007874;
else value = value * 0.03937007874;
valueUnit = "in";
if (valueUnit && valueUnit.toLowerCase() === "cm") convertedValue = convertedValue * 0.3937007874;
else convertedValue = convertedValue * 0.03937007874;
conversionUnit = "in";
} else {
valueUnit = valueUnit ? valueUnit : "mm";
conversionUnit = valueUnit ? valueUnit : "mm";
}
if (valueUnit === "%") return `${value.toFixed(0)} ${valueUnit}`;
if (valueUnit === "%") return `${convertedValue.toFixed(0)} ${conversionUnit}`;
return `${value.toFixed(2)} ${valueUnit}`;
return `${convertedValue.toFixed(2)} ${conversionUnit}`;
},
/**