✨ Add configurable per-file thresholds for no-giant-component#4
Merged
Conversation
Support `rules` config in react-doctor.config.json:
```json
{
"rules": {
"no-giant-component": {
"maxLines": 250,
"overrides": [
{ "files": ["**/views/**/createView*.tsx"], "maxLines": 500 }
]
}
}
}
```
- Inject rules config into plugin via globalThis preamble
- Match filenames against glob overrides (first match wins)
- Fall back to global maxLines, then hardcoded default
- Backwards compatible — no config = same behavior
240a400 to
36427f1
Compare
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
The
no-giant-componentrule uses a hardcoded ~300-line threshold. View factory components (e.g.createViewRentRolls.tsx) legitimately exceed this because they wire up state, callbacks, and JSX in one place. Extracting sub-components leads to prop drilling with 15+ props.Solution
Support a
rulessection inreact-doctor.config.json:{ "rules": { "no-giant-component": { "maxLines": 250, "overrides": [ { "files": ["**/views/**/createView*.tsx"], "maxLines": 500 } ] } } }maxLines— global threshold (default: hardcoded 300)overrides— per-file-pattern overrides, first match winsHow it works
react-doctor.config.jsonrulesconfig is injected into the plugin JS viaglobalThis.__REACT_DOCTOR_RULES__preambleno-giant-componentrule reads config, matchescontext.getFilename()against override globsmaxLines, then to hardcoded defaultBackwards compatible — no
rulesconfig = same behavior as before.Version
0.0.30-proda.3