mirror of
https://github.com/MichMich/MagicMirror.git
synced 2026-04-23 14:27:01 +00:00
This PR updates ESLint and the ESLint plugins to their latest versions
and takes advantage of the new versions to simplify the config.
The main cleanup: removed all explicit `plugins: {}` registrations from
`eslint.config.mjs`. When passing direct config objects like
`js.configs.recommended`, the plugin registration is already included –
we were just doing it twice.
Two lint warnings are also fixed:
- A wrong import style for `eslint-plugin-package-json` (named vs.
default)
- `playwright/no-duplicate-hooks` is disabled for e2e tests – the rule
doesn't handle plain `beforeAll()`/`afterAll()` (Vitest style) correctly
and produces false positives. I've created an issue for that:
https://github.com/mskelton/eslint-plugin-playwright/issues/443.
Built-in Node.js imports were manually updated to use the `node:` prefix
(e.g. `require("fs")` → `require("node:fs")`). Minor formatting fixes
were applied automatically by `eslint --fix`.
32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
// Internal alias mapping for default and 3rd party modules.
|
|
// Provides short require identifiers: "logger" and "node_helper".
|
|
// For a future ESM migration, replace this with a public export/import surface.
|
|
|
|
const path = require("node:path");
|
|
const Module = require("node:module");
|
|
|
|
const root = path.join(__dirname, "..");
|
|
|
|
// Keep this list minimal; do not add new aliases without architectural review.
|
|
const ALIASES = {
|
|
logger: "js/logger.js",
|
|
node_helper: "js/node_helper.js"
|
|
};
|
|
|
|
// Resolve to absolute paths now.
|
|
const resolved = Object.fromEntries(
|
|
Object.entries(ALIASES).map(([k, rel]) => [k, path.join(root, rel)])
|
|
);
|
|
|
|
// Prevent multiple patching if this file is required more than once.
|
|
if (!Module._mmAliasPatched) {
|
|
const origResolveFilename = Module._resolveFilename;
|
|
Module._resolveFilename = function (request, parent, isMain, options) {
|
|
if (Object.prototype.hasOwnProperty.call(resolved, request)) {
|
|
return resolved[request];
|
|
}
|
|
return origResolveFilename.call(this, request, parent, isMain, options);
|
|
};
|
|
Module._mmAliasPatched = true; // non-enumerable marker would be overkill here
|
|
}
|