Files
orca/config/ast-grep/rules/no-eager-qrcode-import.yml
Neil 5447a26fd1 perf(lint): keep JS plugins out of default oxlint and adopt ast-grep (#33430)
* perf(lint): keep JS plugins out of default oxlint and adopt ast-grep

Any jsPlugin makes Oxlint hand every file's AST to Node, so the seven custom
plugins cost the default `oxlint` run several times its native time.

- Move app-store-performance, quadratic-buffer-concat, renderer-scrollbar-style
  and ime-enter-guard (scope- or dataflow-aware) to config/oxlint-js-plugins.json,
  run by `pnpm lint:js-plugins`, CI, lint-staged and the changed-lines gate.
- Port sort-comparator-performance, mobile-pairing and native-chat-design-tokens
  to ast-grep rules with rule tests, and delete the plugins.
- Add @ast-grep/cli, config/sgconfig.yml, `pnpm lint:ast-grep` / `test:ast-grep`,
  a CI step, and an ast-grep pass in check-changed-code-quality.
- Add flaky-test rules (wall-clock reads, real-time waits, polling loops,
  unquarantined skips, unexplained timeout bumps), baselined by a count ratchet.

* Enforce flaky-test ratchet on changed files; refresh baseline

* docs(agents): keep custom-rule details out of AGENTS.md

* Resolve ast-grep from the repo so gate scans of other roots work
2026-10-25 00:23:38 -07:00

34 lines
1.4 KiB
YAML

# Startup must not parse the qrcode bundle; only mobile pairing reaches it.
# The TSX document below mirrors the TypeScript one; keep them in sync.
id: no-eager-qrcode-import
language: typescript
severity: error
message: qrcode is only reachable from mobile pairing. Use `import type` plus `await import('qrcode')` so startup does not parse its bundle.
rule:
kind: import_statement
has: { field: source, regex: '^.qrcode.$' }
not:
any:
- regex: '^import\s+type\b'
# `import { type A, type B } from 'qrcode'` erases too.
- all:
- has: { kind: import_clause, has: { kind: named_imports } }
- not: { has: { kind: import_clause, has: { kind: identifier } } }
- not: { has: { stopBy: end, kind: import_specifier, not: { regex: '^type\s' } } }
---
id: no-eager-qrcode-import-tsx
language: tsx
severity: error
message: qrcode is only reachable from mobile pairing. Use `import type` plus `await import('qrcode')` so startup does not parse its bundle.
rule:
kind: import_statement
has: { field: source, regex: '^.qrcode.$' }
not:
any:
- regex: '^import\s+type\b'
# `import { type A, type B } from 'qrcode'` erases too.
- all:
- has: { kind: import_clause, has: { kind: named_imports } }
- not: { has: { kind: import_clause, has: { kind: identifier } } }
- not: { has: { stopBy: end, kind: import_specifier, not: { regex: '^type\s' } } }