feat: no-historical-comments + no-bare-date-now#7
Merged
Conversation
Two new rules covering categories of agent-generated drift that the existing plugin set didn't catch: eslint-plugin-comment-hygiene/no-historical-comments Flags comments framing code relative to what it USED TO be or to a past incident: "Codex flagged X", "before the fix", "after the refactor", "we used to", "no longer", "kept for backwards compat", "historically", "Alpine-era workaround". History belongs in commit messages and PR descriptions where it stays pinned to the diff. eslint-plugin-code-flow/no-bare-date-now Flags direct Date.now() / new Date() (no args) / Date() (no args) / Math.random() outside an allowlisted set of utility paths. Determinism is required for snapshot tests, workflow replays, and time-travel debugging — consumers route through a typed util that can be faked. Configurable via the `allowedPaths` option. Both rules included in their plugin's `recommended` config. Tests + docs pages added. Plugin shape + recommended-config integrity tests in eslint-plugin-code-flow updated to enumerate the new rule.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two new rules covering categories of agent-generated drift the existing plugin set didn't catch.
eslint-plugin-comment-hygiene/no-historical-commentsFlags source comments that frame code relative to what it used to do or to a past incident:
// Codex flagged X// before the fix/// after the fix// after the refactor/// the X refactor// we used to/// this used to/// used to be// no longer// kept for backwards compat// (was|were) a footgun/bug// historically// Alpine-era workaroundSource comments must describe the current invariant. History belongs in the commit message or PR description, pinned to the diff it describes — inline comments rot the moment the code changes again. JSDoc-style block comments are exempt.
eslint-plugin-code-flow/no-bare-date-nowDisallows direct non-deterministic time/random sources outside an allowlisted set of utility paths:
Date.now()new Date()with zero argsDate()with zero argsMath.random()Explicit-argument forms like
new Date(1700000000000),new Date('2026-01-01'), andDate.parse(...)are unaffected (they're pure parsers, not clock reads).Determinism is required for snapshot tests, workflow replays, time-travel debugging, and resumable jobs. Consumers route through a typed util that can be faked in tests; the util's path is exempted via the
allowedPathsoption:{ "code-flow/no-bare-date-now": [ "error", { "allowedPaths": ["src/lib/time/", "src/lib/random/"] } ] }Why these two
Both came out of a real audit pass against an agent-built PR on a downstream consumer. The agent produced ~12 "Codex flagged", "before the fix", "after the refactor" comments that were caught by review but not by tooling. Separately, a determinism rule kept coming up as a near-miss when reviewing test failures rooted in stray
Date.now()/Math.random()calls.Tests
no-historical-comments)no-bare-date-now; +6 plugin-shape updates)Release plan
Standard changeset flow —
.changeset/no-historical-comments.mdand.changeset/no-bare-date-now.mdbump each plugin minor. Merging this PR opens the "Version Packages" PR; merging that publishes to npm.🤖 Built with Claude Code