Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Formatting-only commits skipped by `git blame`.
# Enable once with: git config blame.ignoreRevsFile .git-blame-ignore-revs

# style: format TypeScript and scripts with Biome
ef1b86ca507c763f83850f308d7e7c7e63a62f94
14 changes: 14 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Keep trusted lock bytes exactly LF so their pinned SHA-256 hashes hold on
# every platform. core.autocrlf must never rewrite these files.
.github/security-drafts/*.lock text eol=lf

# Biome checks LF line endings; keep the files it formats LF on Windows checkouts
# too, so `biome ci` gives the same result with any core.autocrlf setting.
*.ts text eol=lf
*.tsx text eol=lf
*.js text eol=lf
*.mjs text eol=lf
*.cjs text eol=lf
*.css text eol=lf
/biome.json text eol=lf
/src/**/*.md text eol=lf
/scripts/**/*.md text eol=lf
/src/**/*.json text eol=lf
/scripts/**/*.json text eol=lf
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
- name: Install locked frontend dependencies
run: npm ci

- name: Biome lint and format
run: npx biome ci

- name: Frontend and script tests
run: npm test

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/linux-pr-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ jobs:
- name: Install locked frontend dependencies
run: npm ci

- name: Biome lint and format
run: npx biome ci

- name: Frontend and script tests
run: npm test

Expand Down
24 changes: 24 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,22 @@ These are the scripts declared in `package.json`:
| `npm run typecheck` | TypeScript checks |
| `npm test` | Vitest tests plus the release scripts' Node tests |
| `cd src-tauri; cargo test` | Rust tests |
| `npm run check` | Biome lint + format check (CI runs `npx biome ci`) |
| `npm run check:fix` | Apply Biome safe fixes and formatting |
| `npm run lint` / `npm run format` | Biome lint only / write formatting only |
| `npm run hooks:install` | Install the Lefthook `pre-push` hook (once per clone) |
| `node scripts/i18n-inventory.mjs` | Regenerate `docs/i18n-inventory.md` (CI runs it with `--check`); `--sites` prints `path:line \| text` rows |
| `npm run app:dev` | Run the desktop app with hot reload |
| `npm run app:build` | Build a local (unsigned) installer |

### Lint and formatting (Biome + Lefthook)

TypeScript and JavaScript under `src/`, `scripts/` and `vite.config.ts` are linted and formatted by [Biome](https://biomejs.dev) (`biome.json`); CSS is linted but not formatted, because tests assert literal CSS text. Excluded: the vendored design-system bundle `src/ds/egdev/` (a copy that must not be edited by hand) and the provider logos in `src/assets/logos/` (raw SVGs checked by security tests). CI runs `npx biome ci` in `ci.yml` and `linux-pr-ci.yml`; any lint error or unformatted file fails the check, warnings do not.

After `npm install`, run `npm run hooks:install` once per clone to install the [Lefthook](https://lefthook.dev) `pre-push` hook (`lefthook.yml`; it is not automatic because the repository policy allows no npm lifecycle scripts). The hook runs `npx biome ci` and the Rust format check before every push. If it fails, run `npm run check:fix` (and `cargo fmt` for Rust), commit, and push again. Skipping it with `--no-verify` only moves the failure to CI.

The repository-wide Biome formatting landed as a formatting-only commit listed in `.git-blame-ignore-revs`; run `git config blame.ignoreRevsFile .git-blame-ignore-revs` once so `git blame` skips it. If you had a branch open before that commit, rebase it on `main` and run `npm run check:fix` to resolve formatting conflicts.

### Rust formatting

Rust formatting is checked by CI (`cargo fmt --manifest-path src-tauri/Cargo.toml --all -- --check` in `ci.yml` and `linux-pr-ci.yml`). Locally: `cd src-tauri && cargo fmt --all`, then commit the result as a formatting-only commit such as `chore(style): cargo fmt`, so functional changes stay reviewable.
Expand Down Expand Up @@ -184,9 +196,21 @@ Estos son los scripts declarados en `package.json`:
| `npm run typecheck` | Comprobar TypeScript |
| `npm test` | Tests de Vitest y tests Node de los scripts de release |
| `cd src-tauri; cargo test` | Tests de Rust |
| `npm run check` | Lint y comprobación de formato con Biome (CI ejecuta `npx biome ci`) |
| `npm run check:fix` | Aplicar los arreglos seguros y el formato de Biome |
| `npm run lint` / `npm run format` | Solo lint de Biome / solo escribir el formato |
| `npm run hooks:install` | Instalar el hook `pre-push` de Lefthook (una vez por clon) |
| `npm run app:dev` | Ejecutar la app de escritorio con hot reload |
| `npm run app:build` | Compilar un instalador local (sin firma) |

### Lint y formato (Biome + Lefthook)

El TypeScript y JavaScript de `src/`, `scripts/` y `vite.config.ts` se analizan y formatean con [Biome](https://biomejs.dev) (`biome.json`); el CSS se analiza pero no se formatea, porque hay tests que comprueban su texto literal. Se excluyen el bundle del design system `src/ds/egdev/` (una copia que no se edita a mano) y los logos de `src/assets/logos/` (SVG crudos validados por tests de seguridad). CI ejecuta `npx biome ci` en `ci.yml` y `linux-pr-ci.yml`: cualquier error de lint o archivo sin formatear hace fallar el check; los warnings no.

Después de `npm install`, ejecutá una vez por clon `npm run hooks:install` para instalar el hook `pre-push` de [Lefthook](https://lefthook.dev) (`lefthook.yml`; no es automático porque la política del repositorio no admite scripts de ciclo de vida de npm). El hook ejecuta `npx biome ci` y la comprobación de formato de Rust antes de cada push. Si falla, ejecutá `npm run check:fix` (y `cargo fmt` para Rust), commiteá y volvé a hacer push. Saltarlo con `--no-verify` solo traslada el fallo a CI.

El formato de Biome de todo el repositorio entró como commit solo-formato, listado en `.git-blame-ignore-revs`; ejecutá una vez `git config blame.ignoreRevsFile .git-blame-ignore-revs` para que `git blame` lo ignore. Si tenías una rama abierta antes de ese commit, rebaseala sobre `main` y ejecutá `npm run check:fix` para resolver los conflictos de formato.

### Formato de Rust

El formato de Rust se controla en CI (`cargo fmt --manifest-path src-tauri/Cargo.toml --all -- --check` en `ci.yml` y `linux-pr-ci.yml`). Localmente: `cd src-tauri && cargo fmt --all` y commiteá el resultado como commit solo-formato, por ejemplo `chore(style): cargo fmt`, para que los cambios funcionales sigan siendo revisables.
Expand Down
38 changes: 38 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true,
"defaultBranch": "main"
},
"files": {
"includes": ["src/**", "scripts/**", "vite.config.ts", "!src/ds/egdev", "!src/assets/logos"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 160
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"jsxQuoteStyle": "double"
}
},
"assist": {
"enabled": false
},
"linter": {
"enabled": true,
"rules": {
"preset": "recommended"
}
},
"css": {
"formatter": {
"enabled": false
}
}
}
2 changes: 1 addition & 1 deletion docs/i18n-inventory.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# i18n inventory (egdev6/quorb#66)

Generated by `node scripts/i18n-inventory.mjs` from the source trees `src/` = `5d1f8cd9a87b8308b2397ee124ddf7895400568b` and `src-tauri/src/` = `4e040c3e38251119abf3e7d0de46376d82d9c885`.
Generated by `node scripts/i18n-inventory.mjs` from the source trees `src/` = `82db1dfd8212733b638db35f84da395cbde06e1b` and `src-tauri/src/` = `4e040c3e38251119abf3e7d0de46376d82d9c885`.
Any commit whose `git rev-parse <commit>:src` and `<commit>:src-tauri/src` match has these exact texts.
Do not edit by hand: regenerate, or verify with `node scripts/i18n-inventory.mjs --check`.

Expand Down
11 changes: 11 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Git hooks managed by Lefthook (https://lefthook.dev).
# Install once per clone with `npm run hooks:install`. There is no `prepare` script on purpose:
# the repository policy (.github/security/policy.json) allows no root npm lifecycle hooks.
# CI runs the same checks, so skipping the hook with `--no-verify` only delays the failure.
pre-push:
parallel: true
jobs:
- name: biome
run: npx biome ci
- name: cargo-fmt
run: cargo fmt --manifest-path src-tauri/Cargo.toml --all -- --check
32 changes: 32 additions & 0 deletions odd/tasks/biome-lefthook.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Biome lint/format + Lefthook pre-push + CI gate
Branch: `chore/biome-lefthook`; base: `72f443d`. Delivery: work-unit commits on the branch; push, PR, merge and the Discord announcement after merge remain user decisions.
Risk: item 5 (dev dependencies, git hooks and CI gates); item 6 for lint fixes that touch runtime code (each fix covered by existing tests or justified).

## Specs

- S1: "tenemos metido biome y lefthook para hacer lint en pre-push?" → answer was no; proposal accepted with "si": "¿Querés que lo agregue (Biome con `lint`/`format`, Lefthook en pre-push y el mismo chequeo en CI)?"
- S2: Scope chosen by the user: "lint + format + arreglo de errores + aviso en dicord de que lo hemos añadido avisando de que tienen que sincronizar"
- S3: Baseline measured (Biome 2.6.8, defaults): 106 lint errors, 280 warnings, 32 infos over `src/` and `scripts/`. Formatter with single quotes and lineWidth 160 rewrites 178 files when the vendored `src/ds/egdev/` ("No editar a mano") is excluded.

## Tasks

- T1 | S1-S2 | parent inline | done | `biome.json`, `lefthook.yml` (pre-push: `biome ci` + `cargo fmt --check`), npm scripts (`lint`, `format`, `check`, `prepare`), CI step in `ci.yml` and `linux-pr-ci.yml`, CONTRIBUTING EN/ES. Commit: `7006d90`
- T2 | S2-S3 | parent inline | done | Format-only commit with `biome format --write`, plus `.git-blame-ignore-revs`. CSS formatter disabled (12 tests assert literal theme/styles CSS). Tests 1241/1241, tsc OK. Commits: `81e387f` (config + 2 whitespace-tolerant test regexes), `ef1b86c` (format only), blame-ignore commit. PR must NOT be squash-merged or the ignored SHA is lost.
- T3 | S2-S3 | parent inline | done | Exclude raw-imported `src/assets/logos/*.svg` (vendored brand marks, validated by security tests) from Biome. Commit: `81e387f`
- T3a | S2-S3 | parent inline (writer launch refused: overlapping surfaces) | done | Fix every Biome lint error in test files and scripts: `scripts/**`, `src/**/*.test.ts`, `src/**/*.test.tsx`. Commit: `5b0075e`
- T3b | S2-S3 | parent inline | done | Fix every Biome lint error in app source: `src/*.tsx`, `src/components/**` (non-test). 21 type=button, 3 for...of, 2 role=img; 17 hook dep lists kept with biome-ignore; 5 justified ignores (index keys, label, radio, innerHTML, static interactions). Commit: `71119c1`
- T4 | S1-S2 | parent inline | done | Verify: `npm test`, `npm run build`, `npx biome ci`, `cargo fmt --check`, lefthook pre-push dry run. Evidence: vitest 1241/1241, node --test 329/0, build OK, `biome ci` 0 errors (224 warnings), cargo fmt OK, inventory --check OK after refresh `fd14fe9`; pre-push exits 1 with a probe lint error and 0 when clean; `prepare` tolerates non-git checkouts (`lefthook install || exit 0`). Commit: final docs commit
- T5 | S2 | parent | blocked (waits for merge to main) | Discord announcement draft (sync instructions: `npm install`, hooks, rebase over the format commit); publish after merge to `main` in #coordinación (1559199240020959303). Draft: /tmp/quorb-discord-biome.md. Commit: n/a

## Log

L1 — User verbatim: "tenemos metido biome y lefthook para hacer lint en pre-push?"
L2 — User verbatim: "si" (accepting: add Biome lint/format, Lefthook pre-push and the same check in CI).
L3 — User verbatim scope answer: "lint + format + arreglo de errores + aviso en dicord de que lo hemos añadido avisando de que tienen que sincronizar"
L5 — Lint fix rules for T3a/T3b: no behavior change. No `<form>` exists in `src/`, so `type="button"` is neutral. `useExhaustiveDependencies`: add or remove a dependency only when provably safe (stable setters/refs, or the effect is idempotent); otherwise keep the deps and add `// biome-ignore lint/correctness/useExhaustiveDependencies: <concrete reason>`. Same for any rule where the fix would change runtime behavior: a justified `biome-ignore` beats a risky rewrite. Never disable a rule globally. `npm test` and `npm run typecheck` must stay green.

L6 — Slice boundary: T1-T2 form the tooling+format slice (format commit is mechanical, ~9.7k lines, reviewed by reproduction: `npx biome format --write` on `81e387f` yields `ef1b86c`). Inventory `docs/i18n-inventory.md` is refreshed once at the end (tree hashes move with every commit).

L4 — Decision: exclude vendored `src/ds/egdev/` from Biome (header says it is a copied bundle, not to be edited by hand). lineWidth 160 chosen because it produced the smallest diff among 100/120/140/160 for the existing code.

L7 — User verbatim: "fallan checks". PR #307 CI: (a) Static code safety blocked `lifecycle-hook` in package.json: `.github/security/policy.json` sets `allowedRootLifecycleHooks: []` on purpose, so `prepare` was replaced by `npm run hooks:install` (policy not weakened). (b) Windows `biome ci` failed on every file because the runner checks out with core.autocrlf (CRLF); `.gitattributes` now pins LF for Biome-checked files. Reproduced and fixed locally with a `core.autocrlf=true` clone (`biome ci` exit 0); `check-repository.mjs` ok: true. Commits `389506a` and its parent.
Loading
Loading