Skip to content

feat(lint): check for a trailing newline - #362

Merged
tbhb-agent merged 2 commits into
mainfrom
agent/r13-eof
Nov 23, 2026
Merged

tbhb-agent merged 2 commits into
mainfrom
agent/r13-eof

Conversation

@tbhb-agent

@tbhb-agent tbhb-agent commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Why

Pre-commit runs end-of-file-fixer, but CI has no matching check. A hook bypass or a web edit can put a file without a final newline on main. @tbhb decided on 2026-11-22 that CI checks every new or changed text file.

Behavior change

  • Add //lint:trailing_newline. It lists the files changed between a base and a head commit and fails on each text file that lacks a final newline. The message gives the path.
  • The check skips empty files, binary files (a zero byte in the first 8 KiB) and deleted paths.
  • The check skips every path the hook skips. That covers the two gitleaks files and the hook-wide excludes, such as test fixtures, mutation output, generated D2 and Structurizr renders, workspace.json and Worker types.
  • repo-checks.yml runs it on pull requests. The range starts at the merge base from //lint:pr_merge_base, the helper that the commit checks use.

Decisions

  • The checker lists the excluded paths itself. Rules release archives omit the pre-commit configuration, so it can't read them from there. A comment points at the hook configuration as the source of the patterns.
  • The check isn't in the baseline manifest. The manifest covers files that consumers receive, and consumers get the check through the shared workflow.
  • The second commit fixes a review finding. Before it, the checker excluded only two paths, so 47 generated fixtures on main would have failed any pull request that regenerated them.

Deviations from the task

  • The runs couldn't start the full gate, because the lock script was missing on their host. The focused Bazel tests and the hooks passed. CI runs the full gate on this head.
  • The second commit adds the //lint:pr_merge_base files from fix(lint): range commit checks from the merge base #361, because this branch predates that merge. The files match main byte for byte.

Risk

Mode-only changes and renames of a file that already lacks a newline fail the check. No test compares the checker's excluded paths with the hook, so a new hook exclusion needs a matching edit here.

Verification

  • //lint:trailing_newline_test covers a missing newline, a present newline, an empty file, a binary file, a deleted file, each excluded family, a sibling of an excluded path that still fails, and a bad revision (exit 2).
  • A run of the checker over the whole tree, from the empty tree to the head, exited 0.
  • The test has the Windows exclusion from AGENTS.md. Tracker row: //lint:trailing_newline_test, verify the Git subprocess test on Windows and remove the exclusion.

Opened-by: LLM effort=medium;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:debb814921f029ad;surface=cli
Generated-by: LLM harness=codex;model=openai:gpt-6.2-sol
Generated-by: LLM effort=high;harness=codex:0.171.0;model=openai:gpt-6.2-sol;session=sha-256-64:538cbd04813c8b8f;surface=exec
Generated-by: LLM effort=high;harness=codex:0.171.0;model=openai:gpt-6.2-sol;session=sha-256-64:da550adca6cf25f3;surface=exec
Assisted-by: LLM effort=medium;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:debb814921f029ad;surface=cli

Check the files changed between the pull request merge base and head.
Skip empty files, binary files and deleted paths.

The two gitleaks exclusions duplicate the end-of-file-fixer hook.
Rules release archives omit the pre-commit configuration, so the
shared checker carries the same two paths.

Generated-by: LLM harness=codex;model=openai:gpt-6.2-sol
Generated-by: LLM effort=high;harness=codex:0.171.0;model=openai:gpt-6.2-sol;session=sha-256-64:538cbd04813c8b8f;surface=exec
Generated-by: LLM harness=codex;model=openai:gpt-6.2-sol
Generated-by: LLM effort=high;harness=codex:0.171.0;model=openai:gpt-6.2-sol;session=sha-256-64:da550adca6cf25f3;surface=exec
@tbhb-agent
tbhb-agent merged commit a05c418 into main Nov 23, 2026
58 checks passed
@tbhb-agent
tbhb-agent deleted the agent/r13-eof branch November 23, 2026 07:10
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