Skip to content

Commit e21a78c

Browse files
refactor: enable ESLint rule require-await and handle detected issues
Remove unnecessary async keywords from functions that don't use await.
1 parent 8ce0cda commit e21a78c

File tree

12 files changed

+24
-23
lines changed

12 files changed

+24
-23
lines changed

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export default defineConfig([
7575
"object-shorthand": ["error", "methods"],
7676
"one-var": "off",
7777
"prefer-template": "error",
78+
"require-await": "error",
7879
"sort-keys": "off"
7980
}
8081
},

js/loader.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ const Loader = (function () {
193193
* @param {string} fileName Path of the file we want to load.
194194
* @returns {Promise} resolved when the file is loaded
195195
*/
196-
const loadFile = async function (fileName) {
196+
const loadFile = function (fileName) {
197197
const extension = fileName.slice((Math.max(0, fileName.lastIndexOf(".")) || Infinity) + 1);
198198
let script, stylesheet;
199199

@@ -267,10 +267,10 @@ const Loader = (function () {
267267
* @param {Module} module The module that calls the loadFile function.
268268
* @returns {Promise} resolved when the file is loaded
269269
*/
270-
async loadFileForModule (fileName, module) {
270+
loadFileForModule (fileName, module) {
271271
if (loadedFiles.indexOf(fileName.toLowerCase()) !== -1) {
272272
Log.log(`File already loaded: ${fileName}`);
273-
return;
273+
return Promise.resolve();
274274
}
275275

276276
if (fileName.indexOf("http://") === 0 || fileName.indexOf("https://") === 0 || fileName.indexOf("/") !== -1) {

js/module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const Module = Class.extend({
4343
/**
4444
* Called when the module is started.
4545
*/
46-
async start () {
46+
start () {
4747
Log.info(`Starting module: ${this.name}`);
4848
},
4949

serveronly/watcher.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ function notifyClientsToReload () {
145145
* Restart the server process
146146
* @param {string} reason The reason for the restart
147147
*/
148-
async function restartServer (reason) {
148+
function restartServer (reason) {
149149
if (restartTimer) clearTimeout(restartTimer);
150150

151-
restartTimer = setTimeout(async () => {
151+
restartTimer = setTimeout(() => {
152152
Log.info(reason);
153153

154154
if (child) {

tests/e2e/clientonly_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ describe("Clientonly parameter handling", () => {
133133
});
134134

135135
describe("Display environment check", () => {
136-
it("should fail without DISPLAY or WAYLAND_DISPLAY when connecting to valid server", async () => {
136+
it("should fail without DISPLAY or WAYLAND_DISPLAY when connecting to valid server", () => {
137137
// This test needs a running server to get past the connection phase
138138
// Without DISPLAY, it should fail with display error
139139
// For now, we just verify it fails (connection error comes first without server)
@@ -159,7 +159,7 @@ describe("Clientonly with running server", () => {
159159
await delay(2000);
160160
});
161161

162-
afterAll(async () => {
162+
afterAll(() => {
163163
if (serverProcess && serverProcess.pid) {
164164
try {
165165
process.kill(-serverProcess.pid);

tests/e2e/config_variables_spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ describe("config with variables and secrets", () => {
99
await helpers.stopApplication();
1010
});
1111

12-
it("config.language should be \"de\"", async () => {
12+
it("config.language should be \"de\"", () => {
1313
expect(config.language).toBe("de");
1414
});
1515

16-
it("config.loglevel should be [\"ERROR\", \"LOG\", \"WARN\", \"INFO\"]", async () => {
16+
it("config.loglevel should be [\"ERROR\", \"LOG\", \"WARN\", \"INFO\"]", () => {
1717
expect(config.logLevel).toStrictEqual(["ERROR", "LOG", "WARN", "INFO"]);
1818
});
1919

20-
it("config.ipWhitelist should be [\"::ffff:127.0.0.1\", \"::1\", \"127.0.0.1\"]", async () => {
20+
it("config.ipWhitelist should be [\"::ffff:127.0.0.1\", \"::1\", \"127.0.0.1\"]", () => {
2121
expect(config.ipWhitelist).toStrictEqual(["::ffff:127.0.0.1", "::1", "127.0.0.1"]);
2222
});
2323

24-
it("config.timeFormat should be 12", async () => {
24+
it("config.timeFormat should be 12", () => {
2525
expect(config.timeFormat).toBe(12); // default is 24
2626
});
2727

tests/e2e/modules/newsfeed_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const fs = require("node:fs");
22
const { expect } = require("playwright/test");
33
const helpers = require("../helpers/global-setup");
44

5-
const runTests = async () => {
5+
const runTests = () => {
66
let page;
77

88
describe("Default configuration", () => {

tests/unit/classes/translator_spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ describe("Translator", () => {
9393
Translator.coreTranslationsFallback = coreTranslationsFallback;
9494
};
9595

96-
it("should return custom module translation", async () => {
96+
it("should return custom module translation", () => {
9797
const { Translator } = createTranslationTestEnvironment();
9898
setTranslations(Translator);
9999

@@ -104,7 +104,7 @@ describe("Translator", () => {
104104
expect(translation).toBe("Hallo fewieden");
105105
});
106106

107-
it("should return core translation", async () => {
107+
it("should return core translation", () => {
108108
const { Translator } = createTranslationTestEnvironment();
109109
setTranslations(Translator);
110110
let translation = Translator.translate({ name: "MMM-Module" }, "FOO");
@@ -113,28 +113,28 @@ describe("Translator", () => {
113113
expect(translation).toBe("Bar Lorem Ipsum");
114114
});
115115

116-
it("should return custom module translation fallback", async () => {
116+
it("should return custom module translation fallback", () => {
117117
const { Translator } = createTranslationTestEnvironment();
118118
setTranslations(Translator);
119119
const translation = Translator.translate({ name: "MMM-Module" }, "A key");
120120
expect(translation).toBe("A translation");
121121
});
122122

123-
it("should return core translation fallback", async () => {
123+
it("should return core translation fallback", () => {
124124
const { Translator } = createTranslationTestEnvironment();
125125
setTranslations(Translator);
126126
const translation = Translator.translate({ name: "MMM-Module" }, "Fallback");
127127
expect(translation).toBe("core fallback");
128128
});
129129

130-
it("should return translation with placeholder for missing variables", async () => {
130+
it("should return translation with placeholder for missing variables", () => {
131131
const { Translator } = createTranslationTestEnvironment();
132132
setTranslations(Translator);
133133
const translation = Translator.translate({ name: "MMM-Module" }, "Hello {username}");
134134
expect(translation).toBe("Hallo {username}");
135135
});
136136

137-
it("should return key if no translation was found", async () => {
137+
it("should return key if no translation was found", () => {
138138
const { Translator } = createTranslationTestEnvironment();
139139
setTranslations(Translator);
140140
const translation = Translator.translate({ name: "MMM-Module" }, "MISSING");

tests/unit/functions/server_functions_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ describe("server_functions tests", () => {
163163
expect(corsResponse.set.mock.calls[2][1]).toBe("value2");
164164
});
165165

166-
it("Gets User-Agent from configuration", async () => {
166+
it("Gets User-Agent from configuration", () => {
167167
const previousConfig = global.config;
168168
global.config = {};
169169
let userAgent;

tests/unit/functions/updatenotification_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ describe("Updatenotification", () => {
320320
describe("custom module", () => {
321321
const moduleName = "MMM-Fuel";
322322

323-
beforeEach(async () => {
323+
beforeEach(() => {
324324
gitRemoteOut = `origin\thttps://github.com/fewieden/${moduleName}.git (fetch)\norigin\thttps://github.com/fewieden/${moduleName}.git (push)\n`;
325325
gitRevParseOut = "9d8310163da94441073a93cead711ba43e8888d0";
326326
gitStatusOut = "## master...origin/master";

0 commit comments

Comments
 (0)