Summary
ignore.files is currently all-or-nothing: any file matched by a glob has every rule suppressed. There's no way to say "ignore rule X for files matching glob Y while keeping all other rules active." The result is that legitimate file-level exemptions force overshooting — losing coverage for unrelated rules.
(This is distinct from #86, which is a bug about ignore.files not matching at all. This request is for a config-shape extension assuming #86 is fixed.)
Current shape
{
"ignore": {
"rules": ["react-doctor/prefer-useReducer"],
"files": ["app/(dev)/**", "components/modules/diff/**"]
}
}
Requested shape
{
"ignore": {
"rules": ["react-doctor/prefer-useReducer"],
"files": ["app/(dev)/**"],
"filesByRule": [
{
"files": ["components/modules/diff/**"],
"rules": ["react-doctor/no-array-index-as-key", "react-doctor/no-render-in-render"]
},
{
"files": ["components/search/HighlightedSnippet.tsx"],
"rules": ["react/no-danger"]
}
]
}
}
Concrete cases from one cleanup
| File / glob |
Rules legitimately suppressed |
Other rules we'd like to keep enforced |
components/modules/diff/** |
no-array-index-as-key (diff segments have no item identity), no-render-in-render (extracted render helpers are local to this single file) |
js-combine-iterations, prefer-useReducer, no-effect-event-handler, etc. |
components/ai-assistant/AIMessage.tsx |
no-array-index-as-key (markdown lines parsed once from immutable message content) |
every other react-doctor rule |
components/search/HighlightedSnippet.tsx |
react/no-danger (file's sole purpose is rendering pre-escaped HTML) |
every other rule |
**/*PresetList* |
no-array-index-as-key for skeleton placeholder lists |
the rest |
In every row, the current ignore.files shape forces us to disable react-doctor entirely for the file. That regresses coverage for any future violation we'd actually want to know about.
Workarounds today
- Per-site inline suppressions — works but verbose at scale (e.g. 10 sites in one diff file)
- Whole-file ignore.files entry — what we've been doing; loses coverage for unrelated rules
- Helper-component extraction with the helper isolated to its own file — works for the dangerouslySetInnerHTML case but adds files
Suggested implementation
filesByRule (or whatever the name) is a list of { files, rules } pairs. Each pair operates as "for files matching files, disable rules in rules." Rules disabled here do not affect non-matching files; rules disabled in ignore.rules still apply globally.
Repro environment
Related
Summary
ignore.filesis currently all-or-nothing: any file matched by a glob has every rule suppressed. There's no way to say "ignore rule X for files matching glob Y while keeping all other rules active." The result is that legitimate file-level exemptions force overshooting — losing coverage for unrelated rules.(This is distinct from #86, which is a bug about
ignore.filesnot matching at all. This request is for a config-shape extension assuming #86 is fixed.)Current shape
{ "ignore": { "rules": ["react-doctor/prefer-useReducer"], "files": ["app/(dev)/**", "components/modules/diff/**"] } }Requested shape
{ "ignore": { "rules": ["react-doctor/prefer-useReducer"], "files": ["app/(dev)/**"], "filesByRule": [ { "files": ["components/modules/diff/**"], "rules": ["react-doctor/no-array-index-as-key", "react-doctor/no-render-in-render"] }, { "files": ["components/search/HighlightedSnippet.tsx"], "rules": ["react/no-danger"] } ] } }Concrete cases from one cleanup
components/modules/diff/**no-array-index-as-key(diff segments have no item identity),no-render-in-render(extracted render helpers are local to this single file)js-combine-iterations,prefer-useReducer,no-effect-event-handler, etc.components/ai-assistant/AIMessage.tsxno-array-index-as-key(markdown lines parsed once from immutable message content)components/search/HighlightedSnippet.tsxreact/no-danger(file's sole purpose is rendering pre-escaped HTML)**/*PresetList*no-array-index-as-keyfor skeleton placeholder listsIn every row, the current
ignore.filesshape forces us to disable react-doctor entirely for the file. That regresses coverage for any future violation we'd actually want to know about.Workarounds today
Suggested implementation
filesByRule(or whatever the name) is a list of{ files, rules }pairs. Each pair operates as "for files matchingfiles, disable rules inrules." Rules disabled here do not affect non-matching files; rules disabled inignore.rulesstill apply globally.Repro environment
Related
ignore.filesglob matching is broken