coding-styleguide-js-ts

A set of JavaScript and TypeScript coding rules covering types, file structure, imports, formatting, functional style, and immutability.

In plain words
What is it for?
Use it when writing or reviewing JavaScript or TypeScript, especially when choosing module syntax, organizing files, typing JavaScript, and formatting code.
Why use it?
It gives a codebase consistent conventions, making files easier to read and reducing disagreements about implementation style.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/peerigon/configs/coding-styleguide-js-ts
Clone the repo
git clone --depth 1 https://github.com/peerigon/configs
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,154 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.02154
Opus 5 $0.00000 $0.01077
Sonnet 5 $0.00000 $0.00431
Haiku 4.5 $0.00000 $0.00215

Measured 2d ago against content hash 459b0a2c8644, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

coding-styleguide-js-ts scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

ai/coding-styleguide-js-ts.mdc · 215 lines

How it starts

The opening of the file, as written. The whole thing — 215 lines — stays where its author put it; the contents beside it link to each section on GitHub.

JavaScript & TypeScript

  • Use TypeScript. If .js files are requested, use JSDoc type annotations
  • Prefer functional over imperative
  • Prefer immutability
  • Priority rule (MUST): order every file by importance. Start with the primary logic and keep less important helpers/details at the end. Do not put small helpers, secondary types, or uninteresting constants above the main export just to satisfy "define before call".

Formatting

  • Use Prettier's default formatting

Imports & exports

  • Use ESM unless you're editing a CommonJS file
  • Follow the consuming repository's established import-specifier convention (extensions vs extensionless; .js vs .ts in TypeScript source files)
  • Determine convention from nearby files and configuration before introducing new imports
  • Keep import style consistent within a module/package; avoid mixed styles unless already established
  • If conventions are unclear or conflicting, ask the user before changing or introducing import-specifier style
  • Avoid default imports and default exports
  • Avoid barrel files (index files that only re-export) unless its a package entry file

File structure

  • Do not add a file header comment by default
  • For complex or high-impact files only, add a short context comment near the top (3-6 lines) that explains purpose, where to start reading, and non-obvious caveats
  • Then imports
  • Then the file's primary export(s) / main classes and functions (order by importance relative to the file purpose)
  • Then supporting types, less important constants/variables, and private helpers at the bottom
  • Calling a helper from a function body does not require the helper to appear above that function; only load-time / TDZ constraints do
  • Exception: when module execution requires a binding to be initialized before it is used at load time, define it earlier

Naming Conventions

  • camelCase for variables, functions, methods
  • PascalCase for classes, enums and React components
  • SCREAMING_SNAKE_CASE for build-time constants
  • kebab-case for file names, CSS classes and DOM ids
  • Stick to existing naming conventions if present (e.g. camelCase and PascalCase for file names)
  • Use specific names instead of unspecific abbreviations like obj, arr and err
  • Only use abbreviations when they are widely used like Api
  • Abbreviations should be treated as separate words (e.g. Api instead of API)
  • Use short names when the variable or function is private and only accessible in the current file
  • Use longer and more specific names when the variable or function is exported and visible across the whole project
  • Use auxiliary verbs (e.g., isLoading, hasError) for boolean variables and type guards
  • Name variables and parameters after their type, unless there is a good reason not to (e.g. multiple instances of the same type in scope, or a more meaningful domain name)

Read the full file on GitHub · 215 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 215 lines · 2,154 tokens per session scan A 459b0a2c8644

Subscribe to this mod's changes

coding-styleguide-js-ts is a cursor rule published in the GitHub repository peerigon/configs (4 stars, last pushed 21d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,154 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.