Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Discover web checks through a shared lint runner

Manav Rathib83a469852b0
diff --git a/.github/workflows/web-lint.yml b/.github/workflows/web-lint.yml
index f39623888b..37b5b554f1 100644
--- a/.github/workflows/web-lint.yml
+++ b/.github/workflows/web-lint.yml
@@ -59,6 +59,6 @@ jobs:
- run: npm run build:wasm
- - run: npm run lint
+ - run: node scripts/lint.mjs
- run: npm test
diff --git a/rust/crates/accounts/src/flow.rs b/rust/crates/accounts/src/flow.rs
index 4dd406ddce..7b8a707ec7 100644
--- a/rust/crates/accounts/src/flow.rs
+++ b/rust/crates/accounts/src/flow.rs
@@ -155,9 +155,12 @@ impl fmt::Debug for CheckSessionValidityParams {
}
#[derive(Debug)]
-#[expect(
- clippy::large_enum_variant,
- reason = "A single session-check result does not need a separate allocation"
+#[cfg_attr(
+ target_pointer_width = "64",
+ expect(
+ clippy::large_enum_variant,
+ reason = "A single session-check result does not need a separate allocation"
+ )
)]
pub enum SessionValidity {
Invalid,
diff --git a/web/checks/wasm-imports/check.mjs b/web/checks/wasm-imports/check.mjs
new file mode 100644
index 0000000000..3114c6dac7
--- /dev/null
+++ b/web/checks/wasm-imports/check.mjs
@@ -0,0 +1,22 @@
+import { execFileSync } from "node:child_process";
+import { resolve } from "node:path";
+
+const cwd = resolve(import.meta.dirname, "../..");
+for (const args of [
+ [
+ "node_modules/eslint/bin/eslint.js",
+ "--config",
+ "checks/wasm-imports/eslint.config.mjs",
+ "--parser",
+ "@typescript-eslint/parser",
+ "--no-inline-config",
+ "--max-warnings",
+ "0",
+ "apps",
+ "packages",
+ ],
+ ["checks/wasm-imports/entrypoints.mjs"],
+ ["--test", "checks/wasm-imports/test.mjs"],
+]) {
+ execFileSync(process.execPath, args, { cwd, stdio: "inherit" });
+}
diff --git a/web/checks/wasm-names/check.mjs b/web/checks/wasm-names/check.mjs
new file mode 100644
index 0000000000..b6d568a3b4
--- /dev/null
+++ b/web/checks/wasm-names/check.mjs
@@ -0,0 +1,18 @@
+import { execFileSync } from "node:child_process";
+import { resolve } from "node:path";
+
+const cwd = resolve(import.meta.dirname, "../..");
+for (const args of [
+ [
+ "node_modules/eslint/bin/eslint.js",
+ "--config",
+ "checks/wasm-names/eslint.config.mjs",
+ "--no-inline-config",
+ "--max-warnings",
+ "0",
+ "packages/wasm/*/pkg/*.d.ts",
+ ],
+ ["--test", "checks/wasm-names/test.mjs"],
+]) {
+ execFileSync(process.execPath, args, { cwd, stdio: "inherit" });
+}
diff --git a/web/package.json b/web/package.json
index 6ea61bbcde..92c00d386e 100644
--- a/web/package.json
+++ b/web/package.json
@@ -33,8 +33,6 @@
"build:space-wasm": "npm run build --workspace ente-space-wasm",
"build:twoof3": "npm exec --workspace twoof3 -- next build --webpack",
"build:wasm": "npm run build:prelogin-wasm && npm run build:cast-wasm && npm run build:ensu-wasm && npm run build:legacy-wasm && npm run build:locker-wasm && npm run build:paste-wasm && npm run build:photos-wasm && npm run build:space-wasm",
- "check:wasm-imports": "eslint --config checks/wasm-imports/eslint.config.mjs --parser @typescript-eslint/parser --no-inline-config --max-warnings 0 apps packages && node checks/wasm-imports/entrypoints.mjs && node --test checks/wasm-imports/test.mjs",
- "check:wasm-names": "eslint --config checks/wasm-names/eslint.config.mjs --no-inline-config --max-warnings 0 'packages/wasm/*/pkg/*.d.ts' && node --test checks/wasm-names/test.mjs",
"dev": "npm run dev:photos",
"dev:accounts": "npm run build:prelogin-wasm && npm exec --workspace accounts -- next dev --webpack -p 3001",
"dev:albums": "npm run build:prelogin-wasm && npm exec --workspace albums -- next dev --webpack -p 3002",
@@ -51,8 +49,8 @@
"dev:share": "npm run build:prelogin-wasm && npm exec --workspace share -- next dev --webpack -p 3005",
"dev:space": "npm run build:prelogin-wasm && npm run build:space-wasm && npm exec --workspace space -- next dev --webpack -p 3013",
"dev:twoof3": "npm exec --workspace twoof3 -- next dev --webpack -p 3012",
- "lint": "concurrently --names 'prettier,eslint,tsc,wasm-imports,wasm-names' \"prettier --check --log-level warn .\" \"npm exec --workspaces -- eslint --max-warnings 0\" \"npm exec --workspaces -- tsc\" \"npm run check:wasm-imports\" \"npm run check:wasm-names\"",
- "lint:fix": "concurrently --names 'prettier,eslint,tsc' \"prettier --write --log-level warn .\" \"npm exec --workspaces -- eslint --fix --max-warnings 0\" \"npm exec --workspaces -- tsc\"",
+ "lint": "node scripts/lint.mjs",
+ "lint:fix": "node scripts/lint.mjs --fix",
"test": "npm run test --workspace ente-prelogin-wasm && npm run test --workspace ente-locker-wasm && npm run test --workspace ente-paste-wasm && npm run test --workspace ente-contacts && npm run test --workspace locker && npm run test --workspace paste && npm run test --workspace photos && npm run test --workspace space"
},
"overrides": {
diff --git a/web/scripts/lint.mjs b/web/scripts/lint.mjs
new file mode 100644
index 0000000000..38d5852c0f
--- /dev/null
+++ b/web/scripts/lint.mjs
@@ -0,0 +1,29 @@
+import concurrently from "concurrently";
+import { globSync } from "node:fs";
+import { basename, dirname, resolve } from "node:path";
+
+const cwd = resolve(import.meta.dirname, "..");
+const fix = process.argv.includes("--fix");
+const commands = [
+ {
+ name: "prettier",
+ command: `npm exec -- prettier --${fix ? "write" : "check"} --log-level warn .`,
+ },
+ {
+ name: "eslint",
+ command: `npm exec --workspaces -- eslint ${fix ? "--fix " : ""}--max-warnings 0`,
+ },
+ { name: "tsc", command: "npm exec --workspaces -- tsc" },
+ ...globSync("checks/*/check.mjs", { cwd })
+ .sort()
+ .map((path) => ({
+ name: basename(dirname(path)),
+ command: `node ${path}`,
+ })),
+];
+
+try {
+ await concurrently(commands, { cwd }).result;
+} catch {
+ process.exitCode = 1;
+}