agentleFS
tomasz-tomczyktomasz-tomczyk/crit/.cursor/rules/frontend-js.mdc

crit / rules

Cursor rule1.2k starsChanged 2 months agoMITView on GitHub

crit — frontend js

Trending

Less talk lately.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 2 mentionsApr 2026: 1 mentionMay 2026: 1 mentionJun 2026: 9 mentionsJul 2026: 10 mentionsAug 2026: 11 mentionsSep 2026: 11 mentionsOct 2026: 5 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the tomasz-tomczyk/crit repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about tomasz-tomczyk/crit

The biggest 5 of 50 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 50

Talked about on GitHub, Bluesky and Hacker News (50 times).

On GitHub · 46

41 more on GitHub

On Hacker News · 1

The file

We split this frontend-js.mdc into the rules it gives an agent

9 rules. About 0 are common, 2 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use addEventListener, not inline onclick handlers in new code.

    line 10
  2. Very specific:

    When async operations can be triggered from multiple sources, add dedup guards (e.g., reloadInFlight promise pattern).

    line 14
  3. Distinctive:

    When implementing UI state logic that counts comments, account for ALL comment types (file-scoped AND review-level).

    line 16
  4. Very specific:

    Use cookies for any setting that should persist across crit invocations.

    line 19
  5. Very specific:

    Always check response.ok after fetch() calls.

    line 25
  6. Distinctive:

    Every async operation must have error recovery that restores interactivity (re-attach listeners, undo optimistic UI).

    line 26
  7. Very specific:

    Never call .remove() directly on elements with CSS exit animations.

    line 27
  8. Very specific:

    Never call .blur() on interactive elements — it breaks keyboard navigation.

    line 30
  9. Very specific:

    When an SSE event signals a specific data change (e.g., comments-changed), only re-fetch that data — not everything.

    line 33

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
frontend-js.mdc
---
description: crit — frontend js
globs: web/app.js,web/*.js
alwaysApply: false
---

# Frontend JS Rules (semantic — ESLint handles syntax/style)

## DOM & Events
- Use `addEventListener`, not inline `onclick` handlers in new code.
- Cache repeated DOM queries into const variables.

## State Management
- When async operations can be triggered from multiple sources, add dedup guards (e.g., `reloadInFlight` promise pattern).
- Reset ALL navigation/UI state when context changes (scope change, session reload, comment delete).
- When implementing UI state logic that counts comments, account for ALL comment types (file-scoped AND review-level).

## Persisted Settings (cookies, not localStorage)
- Use cookies for any setting that should persist across `crit` invocations. Crit defaults to a random port (`port=0`), and localStorage is scoped per origin (scheme + host + **port**), so localStorage settings reset every run. Cookies are host-scoped and survive port changes.
- Persisted settings live in a single `crit-settings` JSON cookie via `getSetting(key, fallback)` / `setSetting(key, value)`. The exception is `crit-templates`, which stays in its own cookie because it's user-defined and can be longer.
- localStorage is fine for transient per-session data (e.g., `crit-draft-*` autosave keys that are review-specific anyway).
- Before adding persistence to a setting, ask whether it should be sticky. Transient view state (active filter, sort order on a list) usually shouldn't be — users coming back to a new review with "resolved-only" active would miss new open comments. Persist preferences (theme, width, hide-resolved), not transient views.

## Error Handling
- Always check `response.ok` after `fetch()` calls. Throw on unexpected statuses.
- Every async operation must have error recovery that restores interactivity (re-attach listeners, undo optimistic UI).
- Never call `.remove()` directly on elements with CSS exit animations. Use class toggle + animationend listener.

## Accessibility (axe-core in E2E catches missing aria-labels, dialog roles, tab roles)
- Never call `.blur()` on interactive elements — it breaks keyboard navigation. axe-core catches the effect (no focus indicator) but not the cause.

## SSE Events
- When an SSE event signals a specific data change (e.g., `comments-changed`), only re-fetch that data — not everything.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.