Switch from eslint to oxlint (#34166)

* Fix type imports

* Fix jsdoc

* Fixup types

* Fix stray awaits on non-thenables

* Fixup imports

* Fix splats

* Fix this-context on callbacks

* Memoise react contexts

* Prefer find/flatMap

* Make oxlint happier about our React keys

* Avoid unsafe default function params

* Fixup jsdoc

* Fixup contexts

* Switch from eslint to oxlint

* Some oxlint-related tweaks

* Iterate

* Partial revert to defer some changes and shrink diff

* Iterate

* Add eslint-plugin-element-call and enable the copyright rule

* Set strictStorePkgContentCheck

* Iterate

* Make sonar happy

* Fix new lints
This commit is contained in:
Michael Telatynski
2026-07-10 09:47:41 +00:00
committed by GitHub
parent 549dd1b7a8
commit 15c85ec50f
176 changed files with 1294 additions and 2876 deletions
-97
View File
@@ -1,97 +0,0 @@
module.exports = {
plugins: ["matrix-org", "n"],
extends: ["plugin:matrix-org/javascript"],
parserOptions: {
ecmaVersion: 2021,
project: ["tsconfig.json"],
},
env: {
es6: true,
node: true,
// we also have some browser code (ie. the preload script)
browser: true,
},
// NOTE: These rules are frozen and new rules should not be added here.
// New changes belong in https://github.com/matrix-org/eslint-plugin-matrix-org/
rules: {
"quotes": "off",
"indent": "off",
"prefer-promise-reject-errors": "off",
"no-async-promise-executor": "off",
"n/file-extension-in-import": ["error", "always"],
"unicorn/prefer-node-protocol": ["error"],
},
overrides: [
{
files: ["src/**/*.ts"],
extends: ["plugin:matrix-org/typescript"],
rules: {
// Things we do that break the ideal style
"prefer-promise-reject-errors": "off",
"quotes": "off",
"@typescript-eslint/no-explicit-any": "off",
// We're okay with assertion errors when we ask for them
"@typescript-eslint/no-non-null-assertion": "off",
},
},
{
files: ["hak/**/*.ts"],
extends: ["plugin:matrix-org/typescript"],
parserOptions: {
project: ["hak/tsconfig.json"],
},
rules: {
// Things we do that break the ideal style
"prefer-promise-reject-errors": "off",
"quotes": "off",
"n/file-extension-in-import": "off",
"@typescript-eslint/no-explicit-any": "off",
// We're okay with assertion errors when we ask for them
"@typescript-eslint/no-non-null-assertion": "off",
},
},
{
files: ["scripts/**/*.ts"],
extends: ["plugin:matrix-org/typescript"],
parserOptions: {
project: ["scripts/tsconfig.json"],
},
rules: {
// Things we do that break the ideal style
"prefer-promise-reject-errors": "off",
"quotes": "off",
"n/file-extension-in-import": "off",
"@typescript-eslint/no-explicit-any": "off",
// We're okay with assertion errors when we ask for them
"@typescript-eslint/no-non-null-assertion": "off",
},
},
{
files: ["playwright/**/*.ts"],
extends: ["plugin:matrix-org/typescript"],
parserOptions: {
project: ["playwright/tsconfig.json"],
},
rules: {
// Things we do that break the ideal style
"prefer-promise-reject-errors": "off",
"quotes": "off",
"@typescript-eslint/no-explicit-any": "off",
// We're okay with assertion errors when we ask for them
"@typescript-eslint/no-non-null-assertion": "off",
},
},
{
files: ["src/**/*.test.ts", "electron-builder.ts", "vitest.config.ts"],
extends: ["plugin:matrix-org/typescript"],
parserOptions: {
project: ["tsconfig.node.json"],
},
},
],
};
-4
View File
@@ -1,4 +0,0 @@
{
"*": "oxfmt --no-error-on-unmatched-pattern",
"*.(ts|tsx)": ["eslint --fix"]
}
+7
View File
@@ -1,3 +1,10 @@
/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
module.exports = {
presets: [["@babel/preset-env", { targets: { node: "current" } }], "@babel/preset-typescript"],
};
+7
View File
@@ -1,3 +1,10 @@
/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
import * as os from "node:os";
import * as fs from "node:fs";
import * as path from "node:path";
+2 -1
View File
@@ -9,7 +9,8 @@
"lib": ["es2022"],
"types": ["node"],
"allowImportingTsExtensions": true,
"skipLibCheck": true
"skipLibCheck": true,
"noEmit": true
},
"include": ["../scripts/@types/*.d.ts", "./**/*.ts"]
}
+2 -14
View File
@@ -29,9 +29,7 @@
"fetch": "pnpm run mkdirs && node scripts/fetch-package.ts",
"asar-webapp": "asar p webapp webapp.asar",
"start": "nx start",
"lint": "pnpm lint:types && pnpm lint:js",
"lint:js": "eslint --max-warnings 0 src hak playwright scripts",
"lint:js-fix": "eslint --fix --max-warnings 0 src hak playwright scripts",
"lint": "pnpm lint:types",
"lint:types": "pnpm lint:types:src && pnpm lint:types:node && pnpm lint:types:test && pnpm lint:types:scripts && pnpm lint:types:hak",
"lint:types:src": "tsc --noEmit",
"lint:types:node": "tsc --noEmit -p tsconfig.node.json",
@@ -75,14 +73,11 @@
"@electron/asar": "4.2.0",
"@electron/fuses": "^2.1.1",
"@playwright/test": "catalog:",
"@stylistic/eslint-plugin": "^5.0.0",
"@types/auto-launch": "^5.0.1",
"@types/counterpart": "^0.18.1",
"@types/minimist": "^1.2.1",
"@types/node": "catalog:",
"@types/pacote": "^11.1.1",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"app-builder-lib": "26.15.3",
"chokidar": "^5.0.0",
"detect-libc": "^2.0.0",
@@ -90,12 +85,6 @@
"electron-builder": "26.15.3",
"electron-builder-squirrel-windows": "26.15.3",
"electron-devtools-installer": "^4.0.0",
"eslint": "^8.26.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-matrix-org": "^3.0.0",
"eslint-plugin-n": "^17.12.0",
"eslint-plugin-unicorn": "^56.0.0",
"glob": "^13.0.0",
"matrix-web-i18n": "catalog:",
"memfs": "^4.57.2",
@@ -112,8 +101,7 @@
},
"nx": {
"includedScripts": [
"lint:types",
"lint:js"
"lint:types"
]
}
}
+7
View File
@@ -1,5 +1,12 @@
#!/usr/bin/env node
/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
// copies resources into the lib directory.
import parseArgs from "minimist";
+6
View File
@@ -1,4 +1,10 @@
#!/usr/bin/env node
/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
import * as path from "node:path";
import { createWriteStream, promises as fs } from "node:fs";
@@ -1,4 +1,10 @@
#!/usr/bin/env node
/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
/**
* Script to generate incremental Nightly build versions, based on the latest Nightly build version of that kind.
+6
View File
@@ -1,4 +1,10 @@
#!/usr/bin/env node
/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
/*
* Checks for the presence of a webapp, inspects its version and prints it
+6
View File
@@ -1,4 +1,10 @@
#!/usr/bin/env node
/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
/*
* Checks for the presence of a webapp, inspects its version and sets the
+2 -1
View File
@@ -10,7 +10,8 @@
"strict": true,
"lib": ["es2022"],
"types": ["node"],
"allowImportingTsExtensions": true
"allowImportingTsExtensions": true,
"noEmit": true
},
"include": ["../src/@types", "./**/*.ts"]
}
+2
View File
@@ -385,11 +385,13 @@ app.on("ready", async () => {
desktopCapturer
.getSources({ types: ["screen", "window"] })
.then((sources) => {
// oxlint-disable-next-line promise/no-callback-in-promise
callback({ video: sources[0] });
})
.catch((err) => {
// If the user cancels the dialog an error occurs "Failed to get sources"
console.error("Wayland: failed to get user-selected source:", err);
// oxlint-disable-next-line promise/no-callback-in-promise
callback({ video: { id: "", name: "" } }); // The promise does not return if no dummy is passed here as source
});
} else {
+1 -1
View File
@@ -144,7 +144,7 @@ ipcMain.on("ipcCall", async function (_ev: IpcMainEvent, payload) {
}));
break;
case "callDisplayMediaCallback":
await getDisplayMediaCallback()?.({ video: args[0] });
getDisplayMediaCallback()?.({ video: args[0] });
setDisplayMediaCallback(null);
ret = null;
break;
+2 -2
View File
@@ -113,7 +113,7 @@ export class AppLocalization {
locales = [locales];
}
const loadedLocales = locales.filter((locale) => {
const chosenLocale = locales.find((locale) => {
const translations = this.fetchTranslationJson(locale);
if (translations !== null) {
counterpart.registerTranslations(locale, translations);
@@ -121,7 +121,7 @@ export class AppLocalization {
return !!translations;
});
counterpart.setLocale(loadedLocales[0]);
counterpart.setLocale(chosenLocale!);
this.store.set(AppLocalization.STORE_KEY, locales);
this.resetLocalizedUI();
+1 -1
View File
@@ -8,7 +8,7 @@ Please see LICENSE files in the repository root for full details.
// This file is compiled to CommonJS rather than ESM otherwise the browser chokes on the import statement.
import { ipcRenderer, contextBridge, IpcRendererEvent } from "electron";
import { ipcRenderer, contextBridge, type IpcRendererEvent } from "electron";
import type { ConfigOptions } from "./config.js" with { "resolution-mode": "import" };
// Expose only expected IPC wrapper APIs to the renderer process to avoid