refactor(hooks): dedup INDEPENDENT_MODES into caveman-config#206
Open
d123d wants to merge 1 commit intoJuliusBrussee:mainfrom
Open
refactor(hooks): dedup INDEPENDENT_MODES into caveman-config#206d123d wants to merge 1 commit intoJuliusBrussee:mainfrom
d123d wants to merge 1 commit intoJuliusBrussee:mainfrom
Conversation
Before: 'commit', 'review', 'compress' set defined identically in both caveman-activate.js:40 and caveman-mode-tracker.js:81. Adding a new independent mode requires editing two files; one will drift. After: export INDEPENDENT_MODES from caveman-config.js (alongside VALID_MODES), import where needed. No behavior change. Node --check passes on all three files. Import smoke test confirms the set round-trips through require().
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.
Problem
`const INDEPENDENT_MODES = new Set(['commit', 'review', 'compress'])` is defined identically in two places:
Adding a new independent mode (or removing one) requires editing both files; one will inevitably drift.
Fix
Export `INDEPENDENT_MODES` from `hooks/caveman-config.js` alongside the existing `VALID_MODES` export. Import where needed.
Diff summary
```
hooks/caveman-activate.js | 6 +-----
hooks/caveman-config.js | 7 ++++++-
hooks/caveman-mode-tracker.js | 3 +--
3 files changed, 8 insertions(+), 8 deletions(-)
```
Verify
```
node --check hooks/caveman-config.js
node --check hooks/caveman-activate.js
node --check hooks/caveman-mode-tracker.js
node -e "const {INDEPENDENT_MODES}=require('./hooks/caveman-config'); console.log([...INDEPENDENT_MODES]);"
→ [ 'commit', 'review', 'compress' ]
```
All pass. No behavior change.