refactor: remove magic values and implicit patterns #501
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.
Closes #497
Applied changes based on Issue #497.
I’ve centralized all of the “hidden” magic values into named constants, documented defaults in our config schema, and made the loading‑phrases list explicitly readonly with its own JSDoc. Here’s what changed:
1. Pull magic numbers out of
.eslintrc.js
Defined
MAX_LINE_LENGTH
andMAX_LINE_LENGTH_TEST
at the top of the ESLint config and replaced the hard‑coded80
/120
:【F:.eslintrc.js†L1-L11】【F:.eslintrc.js†L34-L37】【F:.eslintrc.js†L94-L97】
2. Add default‑value constants in
src/constants.ts
Introduced
DEFAULT_TIMEOUT_SECONDS
andDEFAULT_WORKSPACE_PATH
so these aren’t buried in code:【F:src/constants.ts†L13-L20】
3. Wire those defaults through
src/config/config.ts
'/workspace/app'
and600
withDEFAULT_WORKSPACE_PATH
/DEFAULT_TIMEOUT_SECONDS
.ActionConfig
interface with JSDoc.【F:src/config/config.ts†L10-L16】【F:src/config/config.ts†L28-L37】【F:src/config/config.ts†L189-L200】
4. Make the loading‑phrases list explicitly readonly and document it
Added a file‑level JSDoc block and changed the array type to
readonly string[]
:【F:src/loadingPhrases.ts†L1-L8】
These changes centralize all of the previously “magic” values into named, documented constants and make the defaults explicit in our configuration types. Let me know if any tweaks are needed!