feat(eslint): add config snapshots and tighten string coercion rules#228
Merged
Conversation
Snapshot resolved ESLint preset rules to catch dependency drift, enable no-base-to-string and restrict-plus-operands (allowing string + number), and restore es2024 lib typing for the root tsconfig.
commit: |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances @peerigon/configs’ ESLint preset maintenance and tightens TypeScript string-coercion safety by adding deterministic config snapshot tests and enabling stricter coercion-related rules.
Changes:
- Add an ESLint config snapshot test harness (
calculateConfigForFile) and commit resolved rule snapshots for all presets, plustest:snapshotscripts. - Tighten TypeScript preset behavior by enabling
@typescript-eslint/no-base-to-stringand configuring@typescript-eslint/restrict-plus-operands(allowing onlystring + number). - Align repository typechecking with intended lib typings by restoring
lib: ["es2024"]in the roottsconfig.json, and document snapshot review workflow inAGENTS.md.
Reviewed changes
Copilot reviewed 9 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Restores lib: ["es2024"] for repo typechecking consistency. |
| package.json | Adds test:snapshot / test:snapshot:update scripts. |
| eslint/rules/typescript.js | Enables no-base-to-string via defaults and configures restrict-plus-operands with strict operands. |
| eslint/review-config-snapshot.prompt.md | Adds documented workflow for reviewing snapshot diffs. |
| eslint/presets/typescript.test/string-coercion.ts | Adds fixture coverage for the tightened coercion rules. |
| eslint/config-snapshot.test.js | Introduces snapshot runner resolving effective rules per preset/file. |
| eslint/snapshots/*.json | Adds committed resolved-rule snapshots for each preset. |
| AGENTS.md | Documents when/how to run and review snapshot tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Reuse one ESLint instance per preset instead of per file, and throw a targeted error with recovery hint when a snapshot file is missing.
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
calculateConfigForFile, with committed JSON ineslint/__snapshots__/andtest:snapshot/test:snapshot:updatescripts@typescript-eslint/no-base-to-stringand@typescript-eslint/restrict-plus-operands(withallowNumberAndString: trueand other operands kept strict), plus a fixture demonstrating both ruleslib: ["es2024"]on the roottsconfig.jsonso typechecking matchesbase.jsonintent, and document snapshot review workflow inAGENTS.mdTest plan
npm run test:snapshotnpm run test:presets:typescriptnpm run test:types