Skip to content

Re-enable no-incorrect-query-selector and require-array-sort-compare#289

Merged
twschiller merged 1 commit into
mainfrom
reenable-query-sort-rules
Jun 22, 2026
Merged

Re-enable no-incorrect-query-selector and require-array-sort-compare#289
twschiller merged 1 commit into
mainfrom
reenable-query-sort-rules

Conversation

@twschiller

Copy link
Copy Markdown
Contributor

Reverses the blanket disable from #288 for these two rules now that we have a clean way to handle each site.

no-incorrect-query-selector → error

One site: placeholder.test.ts uses querySelectorAll("#target") deliberately to assert the match count (toHaveLength(1)), which getElementById can't express. Scoped inline disable with rationale.

require-array-sort-compare → error

The distinction is constant vs non-constant arrays:

Non-constant arrays now pass an explicit comparator (a, b) => a.localeCompare(b) (the appropriate fix, not a suppression):

  • build-site-data.ts, check-background-purity.ts, site-data.test.tsreaddirSync results
  • manifest-permission-diff.ts — computed permission-set diffs

Compile-time-constant catalog lists keep a scoped inline disablecatalog.test.ts sorts RULE_IDS, Object.keys(RULE_DEFAULTS), etc. only to compare set membership order-independently; the default order is fine and a comparator would add nothing.

Codegen output (site-data.generated.ts) is unchanged — localeCompare matches the previous default order for these filenames, so no generated-file drift.

Verification

  • bun run check exit 0 (both rules error; 0 violations; no-unused-disable clean)
  • bun run typecheck clean
  • bun run test — 2059/2059 pass
  • bun run build succeeds, generated file unchanged

Refs #279

Reverses the blanket disable from #288 for these two rules.

no-incorrect-query-selector → error. Its one site (placeholder.test.ts) is
a deliberate `querySelectorAll("#id")` used to assert the match *count*,
which getElementById can't express — scoped inline disable with rationale.

require-array-sort-compare → error. Non-constant arrays now pass an explicit
comparator instead of relying on the default sort:
- build-site-data.ts, check-background-purity.ts, site-data.test.ts: readdir
  results → `.toSorted((a, b) => a.localeCompare(b))`
- manifest-permission-diff.ts: computed permission diffs → same
The compile-time-constant catalog lists in catalog.test.ts (RULE_IDS,
Object.keys(RULE_DEFAULTS), …), sorted only to compare order-independently,
keep a scoped inline disable.

Codegen output (site-data.generated.ts) unchanged — localeCompare matches the
previous order for these filenames.

Refs #279

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-browser-shield-demo-site Ready Ready Preview, Comment Jun 22, 2026 12:46pm

Request Review

@twschiller twschiller merged commit 7c070ca into main Jun 22, 2026
7 checks passed
@twschiller twschiller deleted the reenable-query-sort-rules branch June 22, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant