mirror of
https://github.com/MichMich/MagicMirror.git
synced 2026-07-06 22:32:31 -07:00
chore: upgrade ESLint to v10 and fix newly surfaced issues (#4057)
`eslint-plugin-import-x` was the last thing blocking the ESLint v10 upgrade - it just got v10 support. So here we go. The upgrade itself is tiny. The rest of the diff is cleanup from issues ESLint v10 now catches: a few `let` declarations with initial values that were immediately overwritten anyway (`no-useless-assignment`), and `Translator` listed in `/* global */` in `main.js` and `module.js`. Working through those `no-useless-assignment` warnings also surfaced a dead default in `openmeteo`: `maxEntries: 5` in the constructor, which was never actually doing anything - `openmeteo` never reads `this.config.maxEntries` anywhere. And `weather.js` already sets that default for all providers, so it was just a redundant duplicate. Removed that too. No runtime behavior changes.
This commit is contained in:
committed by
GitHub
parent
21d1e7472a
commit
3ea3f0a605
@@ -98,7 +98,6 @@ class OpenMeteoProvider {
|
||||
pastDays: 0,
|
||||
type: "current",
|
||||
maxNumberOfDays: 5,
|
||||
maxEntries: 5,
|
||||
updateInterval: 10 * 60 * 1000,
|
||||
...config
|
||||
};
|
||||
@@ -241,16 +240,14 @@ class OpenMeteoProvider {
|
||||
}
|
||||
|
||||
#getQueryParameters () {
|
||||
const maxEntriesLimit = ["daily", "forecast"].includes(this.config.type) ? 7 : this.config.type === "hourly" ? 48 : 0;
|
||||
let maxEntries = this.config.maxEntries;
|
||||
let maxNumberOfDays = this.config.maxNumberOfDays;
|
||||
|
||||
if (this.config.maxNumberOfDays !== undefined && !isNaN(parseFloat(this.config.maxNumberOfDays))) {
|
||||
const maxEntriesLimit = ["daily", "forecast"].includes(this.config.type) ? 7 : this.config.type === "hourly" ? 48 : 0;
|
||||
const daysFactor = ["daily", "forecast"].includes(this.config.type) ? 1 : this.config.type === "hourly" ? 24 : 0;
|
||||
maxEntries = Math.max(1, Math.min(Math.round(parseFloat(this.config.maxNumberOfDays)) * daysFactor, maxEntriesLimit));
|
||||
const maxEntries = Math.max(1, Math.min(Math.round(parseFloat(this.config.maxNumberOfDays)) * daysFactor, maxEntriesLimit));
|
||||
maxNumberOfDays = Math.ceil(maxEntries / Math.max(1, daysFactor));
|
||||
}
|
||||
maxEntries = Math.max(1, Math.min(maxEntries, maxEntriesLimit));
|
||||
|
||||
const params = {
|
||||
latitude: this.config.lat,
|
||||
@@ -429,7 +426,7 @@ class OpenMeteoProvider {
|
||||
|
||||
// Add hourly data if available
|
||||
if (parsedData.hourly) {
|
||||
let h = 0;
|
||||
let h;
|
||||
const currentTime = parsedData.current_weather.time;
|
||||
|
||||
// Handle both data shapes: object with arrays or array of objects (after transpose)
|
||||
@@ -522,8 +519,8 @@ class OpenMeteoProvider {
|
||||
const now = new Date();
|
||||
|
||||
parsedData.hourly.forEach((weather, i) => {
|
||||
// Skip past entries, collect only future hours up to maxEntries
|
||||
if (weather.time <= now || hours.length >= this.config.maxEntries) {
|
||||
// Skip past entries
|
||||
if (weather.time <= now) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ class OpenWeatherMapProvider {
|
||||
}
|
||||
|
||||
#generateWeatherObjectsFromOnecall (data) {
|
||||
let precip = false;
|
||||
let precip;
|
||||
|
||||
// Get current weather
|
||||
const current = {};
|
||||
|
||||
@@ -85,7 +85,7 @@ class PirateweatherProvider {
|
||||
return;
|
||||
}
|
||||
|
||||
let weatherData = null;
|
||||
let weatherData;
|
||||
|
||||
switch (this.config.type) {
|
||||
case "current":
|
||||
|
||||
@@ -116,7 +116,7 @@ class UkMetOfficeDataHubProvider {
|
||||
return;
|
||||
}
|
||||
|
||||
let weatherData = null;
|
||||
let weatherData;
|
||||
|
||||
switch (this.config.type) {
|
||||
case "current":
|
||||
|
||||
@@ -31,7 +31,7 @@ const WeatherUtils = {
|
||||
if (valueUnit === "%") return `${value.toFixed(0)} ${valueUnit}`;
|
||||
|
||||
let convertedValue = value;
|
||||
let conversionUnit = valueUnit;
|
||||
let conversionUnit;
|
||||
if (outputUnit === "imperial") {
|
||||
convertedValue = this.convertPrecipitationToInch(value, valueUnit);
|
||||
conversionUnit = "in";
|
||||
|
||||
+1
-1
@@ -191,7 +191,7 @@ class HTTPFetcher extends EventEmitter {
|
||||
#getDelayForResponse (response) {
|
||||
const { status } = response;
|
||||
let delay = this.reloadInterval;
|
||||
let message = "";
|
||||
let message;
|
||||
let errorType = "UNKNOWN_ERROR";
|
||||
|
||||
if (status === 401 || status === 403) {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* global Loader, defaults, Translator, addAnimateCSS, removeAnimateCSS, AnimateCSSIn, AnimateCSSOut, modulePositions, io */
|
||||
/* global Loader, defaults, addAnimateCSS, removeAnimateCSS, AnimateCSSIn, AnimateCSSOut, modulePositions, io */
|
||||
|
||||
const MM = (function () {
|
||||
let modules = [];
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* global Class, cloneObject, Loader, MMSocket, nunjucks, Translator */
|
||||
/* global Class, cloneObject, Loader, MMSocket, nunjucks */
|
||||
|
||||
/*
|
||||
* Module Blueprint.
|
||||
|
||||
Generated
+227
-359
File diff suppressed because it is too large
Load Diff
+6
-5
@@ -93,7 +93,7 @@
|
||||
"ajv": "^8.18.0",
|
||||
"animate.css": "^4.1.1",
|
||||
"croner": "^10.0.1",
|
||||
"eslint": "^9.39.4",
|
||||
"eslint": "^10.0.3",
|
||||
"express": "^5.2.1",
|
||||
"feedme": "^2.0.2",
|
||||
"helmet": "^8.1.0",
|
||||
@@ -112,14 +112,15 @@
|
||||
"weathericons": "^2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@stylistic/eslint-plugin": "^5.10.0",
|
||||
"@vitest/coverage-v8": "^4.0.18",
|
||||
"@vitest/eslint-plugin": "^1.6.9",
|
||||
"@vitest/eslint-plugin": "^1.6.10",
|
||||
"@vitest/ui": "^4.0.18",
|
||||
"cspell": "^9.7.0",
|
||||
"eslint-plugin-import-x": "^4.16.1",
|
||||
"eslint-plugin-jsdoc": "^62.7.1",
|
||||
"eslint-plugin-package-json": "^0.89.4",
|
||||
"eslint-plugin-import-x": "^4.16.2",
|
||||
"eslint-plugin-jsdoc": "^62.8.0",
|
||||
"eslint-plugin-package-json": "^0.90.1",
|
||||
"eslint-plugin-playwright": "^2.9.0",
|
||||
"express-basic-auth": "^1.2.1",
|
||||
"husky": "^9.1.7",
|
||||
|
||||
Reference in New Issue
Block a user