Skip to content

Commit 5e6d49f

Browse files
refactor(eslint): enforce prefer-arrow-callback rule
1 parent 234bc50 commit 5e6d49f

15 files changed

Lines changed: 48 additions & 47 deletions

File tree

‎clientonly/index.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ function getServerConfig (url) {
5050
let configData = "";
5151

5252
// Gather incoming data
53-
response.on("data", function (chunk) {
53+
response.on("data", (chunk) => {
5454
configData += chunk;
5555
});
5656
// Resolve promise at the end of the HTTP/HTTPS stream
57-
response.on("end", function () {
57+
response.on("end", () => {
5858
try {
5959
resolve(JSON.parse(configData));
6060
} catch (parseError) {
@@ -63,7 +63,7 @@ function getServerConfig (url) {
6363
});
6464
});
6565

66-
request.on("error", function (error) {
66+
request.on("error", (error) => {
6767
reject(new Error(`Unable to read config from server (${url}) (${error.message})`));
6868
});
6969
});
@@ -122,16 +122,16 @@ async function startClient (config, prefix) {
122122
const child = require("node:child_process").spawn(electron, elecParams, options);
123123

124124
// Pipe all child process output to current stdout
125-
child.stdout.on("data", function (buf) {
125+
child.stdout.on("data", (buf) => {
126126
process.stdout.write(`Client: ${buf}`);
127127
});
128128

129129
// Pipe all child process errors to current stderr
130-
child.stderr.on("data", function (buf) {
130+
child.stderr.on("data", (buf) => {
131131
process.stderr.write(`Client: ${buf}`);
132132
});
133133

134-
child.on("error", function (err) {
134+
child.on("error", (err) => {
135135
process.stderr.write(`Client: ${err}`);
136136
});
137137

‎defaultmodules/alert/alert.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Module.register("alert", {
124124

125125
renderMessage (type, data) {
126126
return new Promise((resolve) => {
127-
this.nunjucksEnvironment().render(this.getTemplate(type), data, function (err, res) {
127+
this.nunjucksEnvironment().render(this.getTemplate(type), data, (err, res) => {
128128
if (err) {
129129
Log.error("[alert] Failed to render alert", err);
130130
}

‎defaultmodules/calendar/calendar.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ Module.register("calendar", {
559559
}
560560
if (limitNumberOfEntries) {
561561
// sort entries before clipping
562-
by_url_calevents.sort(function (a, b) {
562+
by_url_calevents.sort((a, b) => {
563563
return a.startDate - b.startDate;
564564
});
565565
Log.debug(`[calendar] pushing ${by_url_calevents.length} events to total with room for ${remainingEntries}`);
@@ -570,7 +570,7 @@ Module.register("calendar", {
570570
}
571571
}
572572
Log.info(`[calendar] sorting events count=${events.length}`);
573-
events.sort(function (a, b) {
573+
events.sort((a, b) => {
574574
return a.startDate - b.startDate;
575575
});
576576

@@ -674,7 +674,7 @@ Module.register("calendar", {
674674

675675
mergeUnique (arr1, arr2) {
676676
return arr1.concat(
677-
arr2.filter(function (item) {
677+
arr2.filter((item) => {
678678
return arr1.indexOf(item) === -1;
679679
})
680680
);

‎defaultmodules/calendar/calendarfetcherutils.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ const CalendarFetcherUtils = {
150150
}
151151
});
152152

153-
newEvents.sort(function (a, b) {
153+
newEvents.sort((a, b) => {
154154
return a.startDate - b.startDate;
155155
});
156156

‎defaultmodules/calendar/debug.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ Log.log("Create fetcher ...");
2525

2626
const fetcher = new CalendarFetcher(url, fetchInterval, [], maximumEntries, maximumNumberOfDays, auth);
2727

28-
fetcher.onReceive(function (fetcher) {
28+
fetcher.onReceive((fetcher) => {
2929
Log.log(fetcher.events);
3030
process.exit(0);
3131
});
3232

33-
fetcher.onError(function (fetcher, error) {
33+
fetcher.onError((fetcher, error) => {
3434
Log.log("Fetcher error:", error);
3535
process.exit(1);
3636
});

‎defaultmodules/newsfeed/newsfeed.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ Module.register("newsfeed", {
182182
const item = this.newsItems[this.activeItem];
183183
this.activeItemHash = item.hash;
184184

185-
const items = this.newsItems.map(function (item) {
185+
const items = this.newsItems.map((item) => {
186186
item.publishDate = moment(new Date(item.pubdate)).fromNow();
187187
return item;
188188
});
@@ -250,7 +250,7 @@ Module.register("newsfeed", {
250250
}
251251
}
252252
}
253-
newsItems.sort(function (a, b) {
253+
newsItems.sort((a, b) => {
254254
const dateA = new Date(a.pubdate);
255255
const dateB = new Date(b.pubdate);
256256
return dateB - dateA;

‎defaultmodules/weather/weather.js‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -329,14 +329,14 @@ Module.register("weather", {
329329
addFilters () {
330330
this.nunjucksEnvironment().addFilter(
331331
"formatTime",
332-
function (date) {
332+
(date) => {
333333
return formatTime(this.config, date);
334-
}.bind(this)
334+
}
335335
);
336336

337337
this.nunjucksEnvironment().addFilter(
338338
"unit",
339-
function (value, type, valueUnit) {
339+
(value, type, valueUnit) => {
340340
let formattedValue;
341341
if (type === "temperature") {
342342
if (value === null || value === undefined) {
@@ -365,40 +365,40 @@ Module.register("weather", {
365365
formattedValue = WeatherUtils.convertWind(value, this.config.windUnits);
366366
}
367367
return formattedValue;
368-
}.bind(this)
368+
}
369369
);
370370

371371
this.nunjucksEnvironment().addFilter(
372372
"roundValue",
373-
function (value) {
373+
(value) => {
374374
return this.roundValue(value);
375-
}.bind(this)
375+
}
376376
);
377377

378378
this.nunjucksEnvironment().addFilter(
379379
"decimalSymbol",
380-
function (value) {
380+
(value) => {
381381
return value.toString().replace(/\./g, this.config.decimalSymbol);
382-
}.bind(this)
382+
}
383383
);
384384

385385
this.nunjucksEnvironment().addFilter(
386386
"calcNumSteps",
387-
function (forecast) {
387+
(forecast) => {
388388
return Math.min(forecast.length, this.config.maxNumberOfDays);
389-
}.bind(this)
389+
}
390390
);
391391

392392
this.nunjucksEnvironment().addFilter(
393393
"calcNumEntries",
394-
function (dataArray) {
394+
(dataArray) => {
395395
return Math.min(dataArray.length, this.config.maxEntries);
396-
}.bind(this)
396+
}
397397
);
398398

399399
this.nunjucksEnvironment().addFilter(
400400
"opacity",
401-
function (currentStep, numSteps) {
401+
(currentStep, numSteps) => {
402402
if (this.config.fade && this.config.fadePoint < 1) {
403403
if (this.config.fadePoint < 0) {
404404
this.config.fadePoint = 0;
@@ -413,7 +413,7 @@ Module.register("weather", {
413413
} else {
414414
return 1;
415415
}
416-
}.bind(this)
416+
}
417417
);
418418
}
419419
});

‎eslint.config.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export default defineConfig([
8282
"no-unneeded-ternary": "error",
8383
"no-useless-return": "error",
8484
"object-shorthand": ["error", "methods"],
85+
"prefer-arrow-callback": "error",
8586
"prefer-const": "error",
8687
"prefer-template": "error",
8788
"require-await": "error"

‎js/app.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ if (process.env.MM_CONFIG_FILE) {
4444

4545
// The next part is here to prevent a major exception when there
4646
// is no internet connection. This could probable be solved better.
47-
process.on("uncaughtException", function (err) {
47+
process.on("uncaughtException", (err) => {
4848
// ignore strange exceptions under aarch64 coming from systeminformation:
4949
if (!err.stack.includes("node_modules/systeminformation")) {
5050
Log.error("Whoops! There was an uncaught exception...");

‎js/electron.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function createWindow () {
122122
});
123123

124124
// Set responders for window events.
125-
mainWindow.on("closed", function () {
125+
mainWindow.on("closed", () => {
126126
mainWindow = null;
127127
});
128128

@@ -146,7 +146,7 @@ function createWindow () {
146146
}
147147

148148
// Quit when all windows are closed.
149-
app.on("window-all-closed", function () {
149+
app.on("window-all-closed", () => {
150150
if (process.env.mmTestMode) {
151151
// if we are running tests
152152
app.quit();
@@ -155,7 +155,7 @@ app.on("window-all-closed", function () {
155155
}
156156
});
157157

158-
app.on("activate", function () {
158+
app.on("activate", () => {
159159

160160
/*
161161
* On OS X it's common to re-create a window in the app when the

0 commit comments

Comments
 (0)