Skip to content

Commit 6501aab

Browse files
[linter] Enable ESLint rule no-console (#3810)
In PR #3806 I noticed that ESLint did not complain about the use of `console`. Then I realised that the rule `no-console` was not activated. I have now changed this and replaced a few places where `console` was used. We can't apply the rule to all .js files because not all of them use our logger. Therefore I had to add an extra config block for it.
1 parent 2194ffd commit 6501aab

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ planned for 2025-07-01
3838
- Removed as many of the date conversions as possible
3939
- Use `moment-timezone` when calculating recurring events, this will fix problems from the past with offsets and DST not being handled properly
4040
- Added some tests to test the behavior of the refactored methods to make sure the correct event dates are returned
41+
- [linter] Enable ESLint rule `no-console` and replace `console` with `Log` in some files
4142

4243
### Fixed
4344

eslint.config.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ export default defineConfig([
8484
"sort-keys": "off"
8585
}
8686
},
87+
{
88+
files: ["**/*.js"],
89+
ignores: [
90+
"clientonly/index.js",
91+
"modules/default/calendar/debug.js",
92+
"js/logger.js",
93+
"tests/**/*.js"
94+
],
95+
rules: {"no-console": "error"}
96+
},
8797
{
8898
files: ["**/package.json"],
8999
plugins: {packageJson},

js/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ function App () {
364364
}
365365
} catch (error) {
366366
Log.error(`Error when stopping node_helper for module ${nodeHelper.name}:`);
367-
console.error(error);
367+
Log.error(error);
368368
}
369369
}
370370

js/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ const MM = (function () {
617617
if (startUp !== curr) {
618618
startUp = "";
619619
window.location.reload(true);
620-
console.warn("Refreshing Website because server was restarted");
620+
Log.warn("Refreshing Website because server was restarted");
621621
}
622622
} catch (err) {
623623
Log.error(`MagicMirror not reachable: ${err}`);

js/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ module.exports = {
7070
fs.writeFileSync(discoveredPositionsJSFilename, `const modulePositions=${JSON.stringify(modulePositions)}`);
7171
}
7272
catch (error) {
73-
console.error("unable to write js/positions.js with the discovered module positions\nmake the MagicMirror/js folder writeable by the user starting MagicMirror");
73+
Log.error("unable to write js/positions.js with the discovered module positions\nmake the MagicMirror/js folder writeable by the user starting MagicMirror");
7474
}
7575
}
7676
// return the list to the caller

0 commit comments

Comments
 (0)