Skip to content

✨ Add configurable per-file thresholds for no-giant-component#4

Merged
mateuszchoma merged 1 commit into
mainfrom
feat/configurable-thresholds
Apr 2, 2026
Merged

✨ Add configurable per-file thresholds for no-giant-component#4
mateuszchoma merged 1 commit into
mainfrom
feat/configurable-thresholds

Conversation

@mateuszchoma

Copy link
Copy Markdown
Collaborator

Problem

The no-giant-component rule 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 rules section in react-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 wins

How it works

  1. Config is loaded from react-doctor.config.json
  2. rules config is injected into the plugin JS via globalThis.__REACT_DOCTOR_RULES__ preamble
  3. The no-giant-component rule reads config, matches context.getFilename() against override globs
  4. Falls back to global maxLines, then to hardcoded default

Backwards compatible — no rules config = same behavior as before.

Version

0.0.30-proda.3

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
@mateuszchoma mateuszchoma force-pushed the feat/configurable-thresholds branch from 240a400 to 36427f1 Compare April 2, 2026 12:56

@ioanfagarasan ioanfagarasan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@mateuszchoma mateuszchoma merged commit c18ad0d into main Apr 2, 2026
2 checks passed
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.

2 participants