Skip to content

Commit

Permalink
Add eslint-rule no-param-reassign (evcc-io#15849)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maschga authored Sep 4, 2024
1 parent 536712d commit 9ca0bd4
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
};
3 changes: 1 addition & 2 deletions assets/js/components/Energyflow/Energyflow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
9 changes: 5 additions & 4 deletions assets/js/components/Energyflow/EnergyflowEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions assets/js/components/Savings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions assets/js/components/VehicleStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
},
};
Expand Down
14 changes: 8 additions & 6 deletions assets/js/mixins/formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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") {
Expand Down

0 comments on commit 9ca0bd4

Please sign in to comment.