JavaScript
Untyped and loosely-typed JS: build scripts, config, serverless handlers, legacy app code.
Untyped and loosely-typed JS — build scripts, config, serverless handlers, legacy app code. Its BLOCKER rules concentrate on injection surfaces (prototype pollution, eval-family dynamic code execution, shell injection) and async correctness (floating promises, unvalidated boundary input); the HIGH tier catches JS-specific footguns TypeScript would otherwise rule out by construction — loose equality coercion, unchecked index access, regexes vulnerable to ReDoS.
Which repositories get it
A repository on any of these 11 profiles: fullstack-react-node, javascript-typescript, javascript-typescript-browser, mobile-react-native, service-express, service-node, web-angular, web-nextjs, web-react, web-svelte, web-vue. redline init detects the profile and --profile overrides it — see Profiles & stacks.
Within such a repository, a file gets these rules when it matches one of these globs:
**/*.js**/*.jsx**/*.mjs**/*.cjs**/*.vue**/*.svelte
The 21 rules
When a review comment cites one of these ids, this is where to look up what it catches. Of the 21, 8 BLOCKER, 9 HIGH and 4 SUGGESTION. A finding from this file opens like this:
Redline/BLOCKER [javascript/prototype-pollution]: <one-line problem>What each severity obliges you to do is on The output contract.
| Rule id | Severity | Catches |
|---|---|---|
javascript/prototype-pollution | BLOCKER | Prototype pollution sinks. Recursive merge/`Object.assign` over external input without rejecting `__proto__`, `constructor`, `prototype` keys. |
javascript/dynamic-code-execution | BLOCKER | `eval`, `new Function`, `setTimeout("string")` on anything derived from external input. |
javascript/floating-promises | BLOCKER | Floating promises. Every promise is `await`ed, returned, or `.catch`-handled. An unhandled rejection terminates the process on modern Node. |
javascript/loose-equality-coercion | BLOCKER | `==` against `null`/`undefined`/`0`/`''` where coercion changes the branch — use `===`, or `== null` only as a deliberate nullish check with a comment. |
javascript/shared-module-state-mutation | BLOCKER | Mutating a shared module-scope object/array used across requests or components. |
javascript/unvalidated-boundary-input | BLOCKER | Missing input validation at the boundary — `JSON.parse` of external payloads without try/catch and a size limit; `req.body` fields consumed without a schema check. |
javascript/scattered-env-access | BLOCKER | Secrets read ad hoc from `process.env` scattered across modules — one validated config module, fail fast at startup. |
javascript/shell-injection | BLOCKER | `child_process.exec` with an interpolated string — use `execFile`/`spawn` with argv. |
javascript/var-in-new-code | HIGH | `var` in new code — `const` by default, `let` when reassigned. |
javascript/for-in-over-arrays | HIGH | `for...in` over arrays, or without `hasOwnProperty` filtering over objects. |
javascript/unchecked-index-access | HIGH | Array index access assumed defined (`arr[0].x`) without a length or nullish check. |
javascript/unsafe-numeric-coercion | HIGH | `parseInt` without radix; `Number()`/`+` coercion of user input without `Number.isFinite`. |
javascript/async-callback-ignored-promise | HIGH | `async` callbacks passed to APIs that ignore the returned promise (`array.forEach`, most event emitters) — rejections vanish. |
javascript/hand-rolled-deep-clone | HIGH | Deep-equality or deep-clone hand-rolled instead of `structuredClone`/a maintained util. |
javascript/unsafe-date-arithmetic | HIGH | Date arithmetic on `Date` objects across DST boundaries or with implicit local timezone. |
javascript/try-catch-whole-function | HIGH | `try`/`catch` around a whole function body instead of the failing boundary call. |
javascript/redos | HIGH | Regexes built from external input (ReDoS), or catastrophic backtracking patterns (nested quantifiers over user-controlled length). |
javascript/prefer-optional-chaining | SUGGESTION | Optional chaining and nullish coalescing over `&&`/`||` ladders. |
javascript/prefer-named-exports | SUGGESTION | Named exports over default exports for tree-shaking and refactor safety. |
javascript/jsdoc-on-exports | SUGGESTION | JSDoc types on exported functions in files that will not be converted to TS soon. |
javascript/array-at-negative-index | SUGGESTION | `Array.prototype.at(-1)` over `arr[arr.length - 1]`. |
Changing a rule
Edit standards/stacks/javascript.md and nowhere else. Every other copy is generated from it. A merged change reaches every onboarded repository as a pull request, so treat it as a production change.
Rule ids are permanent. Reword a rule freely; it keeps its id. Renaming or removing an id orphans every telemetry record that cited it.
- Edit the markdownstandards/ is the only place a human edits a rule. AGENTS.md, CLAUDE.md, .github/copilot-instructions.md and .github/instructions/ are rendered from it, and the next render overwrites any hand edit there.
- node scripts/assign-rule-ids.mjsAssigns a permanent <stack>/<slug> id to any new rule bullet and rewrites the file in place. Do not invent an id by hand. CI runs the same script with --check and fails if a rule is missing one.
- node scripts/render-self.mjsRe-renders this repository's own copies of those files. CI runs it with --check, so a stale copy fails the build.
- Bump standards/manifest.json → versionIn the same pull request as the rule change. Sync pull requests quote the version, so every repository can tell which standards it is on.
- Add a CHANGELOG.md entryAlso in the same pull request. Say what changed and why, and record the seed score: a standards change with no measurement is an opinion.
- node scripts/validate.mjsThe self-check CI runs: the manifest is consistent, rule ids are well formed, the output contract is intact, and every glob is one Copilot can read.
Related
- The output contract — what each severity obliges you to do.
- Profiles & stacks — how a repository ends up with a set of rules.
- Seeded corpus: javascript — the known-bad code that tests whether reviewers catch these rules.
- All standards
The full file
# JavaScript Review Rules
Applies to untyped and loosely-typed JS (`.js`, `.jsx`, `.mjs`, `.cjs`), including build
scripts, config files, serverless handlers, and legacy app code. TypeScript rules in the
core standard apply wherever the file is typed.
## BLOCKER — request changes
- `javascript/prototype-pollution` — **Prototype pollution sinks.** Recursive merge/`Object.assign` over external input
without rejecting `__proto__`, `constructor`, `prototype` keys.
- `javascript/dynamic-code-execution` — **`eval`, `new Function`, `setTimeout("string")`** on anything derived from external input.
- `javascript/floating-promises` — **Floating promises.** Every promise is `await`ed, returned, or `.catch`-handled. An
unhandled rejection terminates the process on modern Node.
- `javascript/loose-equality-coercion` — **`==` against `null`/`undefined`/`0`/`''` where coercion changes the branch** — use
`===`, or `== null` only as a deliberate nullish check with a comment.
- `javascript/shared-module-state-mutation` — **Mutating a shared module-scope object/array** used across requests or components.
- `javascript/unvalidated-boundary-input` — **Missing input validation at the boundary** — `JSON.parse` of external payloads without
try/catch and a size limit; `req.body` fields consumed without a schema check.
- `javascript/scattered-env-access` — **Secrets read ad hoc from `process.env` scattered across modules** — one validated
config module, fail fast at startup.
- `javascript/shell-injection` — **`child_process.exec` with an interpolated string** — use `execFile`/`spawn` with argv.
## HIGH
- `javascript/var-in-new-code` — `var` in new code — `const` by default, `let` when reassigned.
- `javascript/for-in-over-arrays` — `for...in` over arrays, or without `hasOwnProperty` filtering over objects.
- `javascript/unchecked-index-access` — Array index access assumed defined (`arr[0].x`) without a length or nullish check.
- `javascript/unsafe-numeric-coercion` — `parseInt` without radix; `Number()`/`+` coercion of user input without `Number.isFinite`.
- `javascript/async-callback-ignored-promise` — `async` callbacks passed to APIs that ignore the returned promise (`array.forEach`,
most event emitters) — rejections vanish.
- `javascript/hand-rolled-deep-clone` — Deep-equality or deep-clone hand-rolled instead of `structuredClone`/a maintained util.
- `javascript/unsafe-date-arithmetic` — Date arithmetic on `Date` objects across DST boundaries or with implicit local timezone.
- `javascript/try-catch-whole-function` — `try`/`catch` around a whole function body instead of the failing boundary call.
- `javascript/redos` — Regexes built from external input (ReDoS), or catastrophic backtracking patterns
(nested quantifiers over user-controlled length).
## SUGGESTION
- `javascript/prefer-optional-chaining` — Optional chaining and nullish coalescing over `&&`/`||` ladders.
- `javascript/prefer-named-exports` — Named exports over default exports for tree-shaking and refactor safety.
- `javascript/jsdoc-on-exports` — JSDoc types on exported functions in files that will not be converted to TS soon.
- `javascript/array-at-negative-index` — `Array.prototype.at(-1)` over `arr[arr.length - 1]`.