Skip to content

Commit 3ea3f0a

Browse files
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.
1 parent 21d1e74 commit 3ea3f0a

File tree

10 files changed

+245
-379
lines changed

10 files changed

+245
-379
lines changed

defaultmodules/weather/providers/openmeteo.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ class OpenMeteoProvider {
9898
pastDays: 0,
9999
type: "current",
100100
maxNumberOfDays: 5,
101-
maxEntries: 5,
102101
updateInterval: 10 * 60 * 1000,
103102
...config
104103
};
@@ -241,16 +240,14 @@ class OpenMeteoProvider {
241240
}
242241

243242
#getQueryParameters () {
244-
const maxEntriesLimit = ["daily", "forecast"].includes(this.config.type) ? 7 : this.config.type === "hourly" ? 48 : 0;
245-
let maxEntries = this.config.maxEntries;
246243
let maxNumberOfDays = this.config.maxNumberOfDays;
247244

248245
if (this.config.maxNumberOfDays !== undefined && !isNaN(parseFloat(this.config.maxNumberOfDays))) {
246+
const maxEntriesLimit = ["daily", "forecast"].includes(this.config.type) ? 7 : this.config.type === "hourly" ? 48 : 0;
249247
const daysFactor = ["daily", "forecast"].includes(this.config.type) ? 1 : this.config.type === "hourly" ? 24 : 0;
250-
maxEntries = Math.max(1, Math.min(Math.round(parseFloat(this.config.maxNumberOfDays)) * daysFactor, maxEntriesLimit));
248+
const maxEntries = Math.max(1, Math.min(Math.round(parseFloat(this.config.maxNumberOfDays)) * daysFactor, maxEntriesLimit));
251249
maxNumberOfDays = Math.ceil(maxEntries / Math.max(1, daysFactor));
252250
}
253-
maxEntries = Math.max(1, Math.min(maxEntries, maxEntriesLimit));
254251

255252
const params = {
256253
latitude: this.config.lat,
@@ -429,7 +426,7 @@ class OpenMeteoProvider {
429426

430427
// Add hourly data if available
431428
if (parsedData.hourly) {
432-
let h = 0;
429+
let h;
433430
const currentTime = parsedData.current_weather.time;
434431

435432
// Handle both data shapes: object with arrays or array of objects (after transpose)
@@ -522,8 +519,8 @@ class OpenMeteoProvider {
522519
const now = new Date();
523520

524521
parsedData.hourly.forEach((weather, i) => {
525-
// Skip past entries, collect only future hours up to maxEntries
526-
if (weather.time <= now || hours.length >= this.config.maxEntries) {
522+
// Skip past entries
523+
if (weather.time <= now) {
527524
return;
528525
}
529526

defaultmodules/weather/providers/openweathermap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class OpenWeatherMapProvider {
135135
}
136136

137137
#generateWeatherObjectsFromOnecall (data) {
138-
let precip = false;
138+
let precip;
139139

140140
// Get current weather
141141
const current = {};

defaultmodules/weather/providers/pirateweather.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class PirateweatherProvider {
8585
return;
8686
}
8787

88-
let weatherData = null;
88+
let weatherData;
8989

9090
switch (this.config.type) {
9191
case "current":

defaultmodules/weather/providers/ukmetofficedatahub.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class UkMetOfficeDataHubProvider {
116116
return;
117117
}
118118

119-
let weatherData = null;
119+
let weatherData;
120120

121121
switch (this.config.type) {
122122
case "current":

defaultmodules/weather/weatherutils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const WeatherUtils = {
3131
if (valueUnit === "%") return `${value.toFixed(0)} ${valueUnit}`;
3232

3333
let convertedValue = value;
34-
let conversionUnit = valueUnit;
34+
let conversionUnit;
3535
if (outputUnit === "imperial") {
3636
convertedValue = this.convertPrecipitationToInch(value, valueUnit);
3737
conversionUnit = "in";

js/http_fetcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class HTTPFetcher extends EventEmitter {
191191
#getDelayForResponse (response) {
192192
const { status } = response;
193193
let delay = this.reloadInterval;
194-
let message = "";
194+
let message;
195195
let errorType = "UNKNOWN_ERROR";
196196

197197
if (status === 401 || status === 403) {

js/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global Loader, defaults, Translator, addAnimateCSS, removeAnimateCSS, AnimateCSSIn, AnimateCSSOut, modulePositions, io */
1+
/* global Loader, defaults, addAnimateCSS, removeAnimateCSS, AnimateCSSIn, AnimateCSSOut, modulePositions, io */
22

33
const MM = (function () {
44
let modules = [];

js/module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global Class, cloneObject, Loader, MMSocket, nunjucks, Translator */
1+
/* global Class, cloneObject, Loader, MMSocket, nunjucks */
22

33
/*
44
* Module Blueprint.

0 commit comments

Comments
 (0)