Add eslint-rule no-param-reassign (#15849)

This commit is contained in:
Maschga 2024-09-04 20:12:45 +02:00 • committed by GitHub
parent 536712dab3
commit 9ca0bd4858
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 21 additions and 18 deletions

View file

@ -18,5 +18,6 @@ module.exports = {
"vue/attribute-hyphenation": "off",
"vue/multi-word-component-names": "off",
"vue/no-reserved-component-names": "off",
"no-param-reassign": "error",
},
};

View file

@ -285,8 +285,7 @@ export default {
},
loadpointsPower: function () {
return this.loadpointsCompact.reduce((sum, lp) => {
sum += lp.power || 0;
return sum;
return sum + (lp.power || 0);
}, 0);
},
pvExport: function () {

View file

@ -124,12 +124,13 @@ export default {
}
return;
}
if (!instance) {
instance = new Tooltip(ref, { html: true, title: " " });
let newInstance = instance;
if (!newInstance) {
newInstance = new Tooltip(ref, { html: true, title: " " });
}
const html = `<div class="text-end">${content.join("<br/>")}</div>`;
instance.setContent({ ".tooltip-inner": html });
return instance;
newInstance.setContent({ ".tooltip-inner": html });
return newInstance;
},
powerClicked: function ($event) {
if (this.powerTooltip) {

View file

@ -327,8 +327,7 @@ export default {
const { rates } = res.data.result;
this.referenceGrid =
rates.reduce((acc, slot) => {
acc += slot.price;
return acc;
return acc + slot.price;
}, 0) / rates.length;
} catch (e) {
this.referenceGrid = undefined;

View file

@ -626,12 +626,13 @@ export default {
}
return;
}
if (!instance) {
let newInstance = instance;
if (!newInstance) {
const trigger = hoverOnly ? "hover" : "hover focus";
instance = new Tooltip(ref, { title: " ", trigger });
newInstance = new Tooltip(ref, { title: " ", trigger });
}
instance.setContent({ ".tooltip-inner": content });
return instance;
newInstance.setContent({ ".tooltip-inner": content });
return newInstance;
},
},
};

View file

@ -38,8 +38,10 @@ export default {
if (val === undefined || val === null) {
return 0;
}
val = Math.abs(val);
return val >= this.fmtLimit ? this.round(val / 1e3, this.fmtDigits) : this.round(val, 0);
let absVal = Math.abs(val);
return absVal >= this.fmtLimit
? this.round(absVal / 1e3, this.fmtDigits)
: this.round(absVal, 0);
},
fmtW: function (watt = 0, format = POWER_UNIT.KW, withUnit = true, digits) {
let unit = format;
@ -106,10 +108,10 @@ export default {
if (duration <= 0) {
return "—";
}
duration = Math.round(duration);
var seconds = duration % 60;
var minutes = Math.floor(duration / 60) % 60;
var hours = Math.floor(duration / 3600);
let roundedDuration = Math.round(duration);
var seconds = roundedDuration % 60;
var minutes = Math.floor(roundedDuration / 60) % 60;
var hours = Math.floor(roundedDuration / 3600);
var result = "";
let unit = "";
if (hours >= 1 || minUnit === "h") {