Skip to content

Switch from Eslint + Typescript-eslint + Prettier to Biome #2214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 0 additions & 88 deletions .eslintrc.cjs

This file was deleted.

3 changes: 1 addition & 2 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"*": "prettier --write",
"*.(ts|tsx)": ["eslint --fix"]
"*": ["biome check --no-errors-on-unmatched --files-ignore-unknown=true"]
}
21 changes: 0 additions & 21 deletions .prettierignore

This file was deleted.

1 change: 0 additions & 1 deletion .prettierrc.cjs

This file was deleted.

136 changes: 136 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"ignore": []
},
"formatter": {
"enabled": true,
"useEditorconfig": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 4,
"lineEnding": "lf",
"lineWidth": 120,
"attributePosition": "auto",
"bracketSpacing": true
},
"organizeImports": { "enabled": true },
"linter": {
"enabled": true,
"rules": {
"recommended": false,
"complexity": {
"noExtraBooleanCast": "error",
"noMultipleSpacesInRegularExpressionLiterals": "error",
"noUselessCatch": "error",
"noWith": "error"
},
"correctness": {
"noConstAssign": "error",
"noConstantCondition": "error",
"noEmptyCharacterClassInRegex": "error",
"noEmptyPattern": "error",
"noGlobalObjectCalls": "error",
"noInnerDeclarations": "error",
"noInvalidConstructorSuper": "error",
"noNewSymbol": "error",
"noNonoctalDecimalEscape": "error",
"noPrecisionLoss": "error",
"noSelfAssign": "error",
"noSetterReturn": "error",
"noSwitchDeclarations": "error",
"noUndeclaredVariables": "error",
"noUnreachable": "error",
"noUnreachableSuper": "error",
"noUnsafeFinally": "error",
"noUnsafeOptionalChaining": "error",
"noUnusedLabels": "error",
"noUnusedVariables": "error",
"useArrayLiterals": "error",
"useIsNan": "error",
"useValidForDirection": "error",
"useYield": "error"
},
"style": {
"noArguments": "error",
"noVar": "error",
"useBlockStatements": "off",
"useConsistentBuiltinInstantiation": "error",
"useConst": "error",
"useNodejsImportProtocol": "error",
"useSingleVarDeclarator": "error",
"useThrowOnlyError": "error",
"useImportType": "error",
"useExportType": "error"
},
"suspicious": {
"noAssignInExpressions": "error",
"noAsyncPromiseExecutor": "error",
"noCatchAssign": "error",
"noClassAssign": "error",
"noCompareNegZero": "error",
"noConsole": "off",
"noControlCharactersInRegex": "error",
"noDebugger": "error",
"noDuplicateCase": "error",
"noDuplicateClassMembers": "error",
"noDuplicateObjectKeys": "error",
"noDuplicateParameters": "error",
"noEmptyBlockStatements": "error",
"noFallthroughSwitchClause": "error",
"noFunctionAssign": "error",
"noGlobalAssign": "error",
"noImportAssign": "error",
"noMisleadingCharacterClass": "error",
"noPrototypeBuiltins": "error",
"noRedeclare": "error",
"noShadowRestrictedNames": "error",
"noSparseArray": "error",
"noUnsafeNegation": "error",
"useGetterReturn": "error",
"useIsArray": "error",
"useValidTypeof": "error"
}
}
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "all",
"semicolons": "always",
"arrowParentheses": "always",
"bracketSameLine": false,
"quoteStyle": "double",
"attributePosition": "auto",
"bracketSpacing": true
}
},
"overrides": [
{
"include": ["src/**/*.ts", "hak/**/*.ts", "scripts/**/*.ts", "playwright/**/*.ts"],
"linter": {
"rules": {
"style": { "noNonNullAssertion": "off" },
"suspicious": { "noExplicitAny": "off" }
}
}
},
{
"include": ["playwright/**/*.ts"],
"linter": {
"rules": {
"correctness": {
"noEmptyPattern": "off"
}
}
}
}
]
}
8 changes: 4 additions & 4 deletions electron-builder.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as os from "node:os";
import * as fs from "node:fs";
import { readFile, writeFile } from "node:fs/promises";
import * as os from "node:os";
import * as path from "node:path";
import * as plist from "plist";
import { AfterPackContext, Arch, Configuration as BaseConfiguration, Platform } from "electron-builder";
import { computeData } from "app-builder-lib/out/asar/integrity";
import { readFile, writeFile } from "node:fs/promises";
import { type AfterPackContext, Arch, type Configuration as BaseConfiguration, Platform } from "electron-builder";
import * as plist from "plist";

/**
* This script has different outputs depending on your os platform.
Expand Down
2 changes: 1 addition & 1 deletion hak/matrix-seshat/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
Please see LICENSE files in the repository root for full details.
*/

import type HakEnv from "../../scripts/hak/hakEnv.js";
import type { DependencyInfo } from "../../scripts/hak/dep.js";
import type HakEnv from "../../scripts/hak/hakEnv.js";

export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
const env = hakEnv.makeGypEnv();
Expand Down
6 changes: 3 additions & 3 deletions hak/matrix-seshat/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ Please see LICENSE files in the repository root for full details.
import childProcess from "node:child_process";
import fsProm from "node:fs/promises";

import type { DependencyInfo } from "../../scripts/hak/dep.js";
import type HakEnv from "../../scripts/hak/hakEnv.js";
import type { Tool } from "../../scripts/hak/hakEnv.js";
import type { DependencyInfo } from "../../scripts/hak/dep.js";

export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
export default async function (hakEnv: HakEnv, _moduleInfo: DependencyInfo): Promise<void> {
const tools: Tool[] = [
["rustc", "--version"],
["python", "--version"], // node-gyp uses python for reasons beyond comprehension
Expand All @@ -33,7 +33,7 @@ export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Prom
const rustc = childProcess.execFile(
"rustc",
["--target", hakEnv.getTargetId(), "--emit=obj", "-o", "tmp", "-"],
(err, out) => {
(err) => {
if (err) {
reject(
"rustc can't build for target " +
Expand Down
2 changes: 1 addition & 1 deletion knip.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { KnipConfig } from "knip";
import type { KnipConfig } from "knip";

export default {
entry: ["src/electron-main.ts", "src/preload.ts", "electron-builder.ts", ".eslintrc-*.js", "scripts/**", "hak/**"],
Expand Down
18 changes: 4 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
"scripts": {
"i18n": "matrix-gen-i18n && yarn i18n:sort && yarn i18n:lint",
"i18n:sort": "jq --sort-keys '.' src/i18n/strings/en_EN.json > src/i18n/strings/en_EN.json.tmp && mv src/i18n/strings/en_EN.json.tmp src/i18n/strings/en_EN.json",
"i18n:lint": "prettier --log-level=silent --write src/i18n/strings/ --ignore-path /dev/null",
"i18n:lint": "biome format --log-level=none --write src/i18n/strings/",
"i18n:diff": "cp src/i18n/strings/en_EN.json src/i18n/strings/en_EN_orig.json && yarn i18n && matrix-compare-i18n-files src/i18n/strings/en_EN_orig.json src/i18n/strings/en_EN.json",
"mkdirs": "mkdirp packages deploys",
"fetch": "yarn run mkdirs && tsx scripts/fetch-package.ts",
"asar-webapp": "asar p webapp webapp.asar",
"start": "yarn run build:ts && yarn run build:res && electron .",
"lint": "yarn lint:types && yarn lint:js && yarn lint:workflows",
"lint:js": "eslint --max-warnings 0 src hak playwright scripts && prettier --check .",
"lint:js-fix": "eslint --fix --max-warnings 0 src hak playwright scripts && prettier --log-level=warn --write .",
"lint:js": "biome check",
"lint:js-fix": "biome check --write",
"lint:types": "yarn lint:types:src && yarn lint:types:test && yarn lint:types:scripts && yarn lint:types:hak",
"lint:types:src": "tsc --noEmit",
"lint:types:test": "tsc --noEmit -p playwright/tsconfig.json",
Expand Down Expand Up @@ -74,30 +74,21 @@
"@babel/core": "^7.18.10",
"@babel/preset-env": "^7.18.10",
"@babel/preset-typescript": "^7.18.6",
"@biomejs/biome": "^1.9.4",
"@electron/asar": "3.3.1",
"@playwright/test": "1.51.0",
"@stylistic/eslint-plugin": "^3.0.0",
"@types/auto-launch": "^5.0.1",
"@types/counterpart": "^0.18.1",
"@types/minimist": "^1.2.1",
"@types/node": "18.19.79",
"@types/pacote": "^11.1.1",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"app-builder-lib": "26.0.11",
"chokidar": "^4.0.0",
"detect-libc": "^2.0.0",
"electron": "34.3.1",
"electron-builder": "26.0.11",
"electron-builder-squirrel-windows": "26.0.11",
"electron-devtools-installer": "^4.0.0",
"eslint": "^8.26.0",
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^10.0.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-matrix-org": "^2.0.1",
"eslint-plugin-n": "^17.12.0",
"eslint-plugin-unicorn": "^56.0.0",
"glob": "^11.0.0",
"husky": "^9.1.6",
"knip": "^5.0.0",
Expand All @@ -106,7 +97,6 @@
"mkdirp": "^3.0.0",
"pacote": "^21.0.0",
"plist": "^3.1.0",
"prettier": "^3.0.0",
"rimraf": "^6.0.0",
"tar": "^7.0.0",
"tsx": "^4.19.2",
Expand Down
4 changes: 2 additions & 2 deletions playwright/e2e/launch/config-options.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
Please see LICENSE files in the repository root for full details.
*/

import { resolve, dirname } from "node:path";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";

import { test, expect } from "../../element-desktop-test.js";
import { expect, test } from "../../element-desktop-test.js";

const __dirname = dirname(fileURLToPath(import.meta.url));

Expand Down
4 changes: 2 additions & 2 deletions playwright/e2e/launch/launch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Please see LICENSE files in the repository root for full details.

import { platform } from "node:os";

import { test, expect } from "../../element-desktop-test.js";
import { expect, test } from "../../element-desktop-test.js";

declare global {
interface Window {
Expand Down Expand Up @@ -63,7 +63,7 @@ test.describe("App launch", () => {

// XXX: this test works fine locally but in CI the app start races with the test plumbing up the stdout/stderr pipes
// which means the logs are missed, disabling for now.
test.skip("should respect option", async ({ page, stdout }) => {
test.skip("should respect option", async ({ page: _page, stdout }) => {
expect(stdout.data.toString()).toContain("Auto update disabled via command line flag");
});
});
Expand Down
Loading