react-doctor/html-no-invalid-table-nesting
Author each table element under its required host parent: thead/tbody/tfoot in <table>, tr in a row group, td/th in <tr>
- Status
- Active
- Category
- Correctness
- Assessment
- Evidence-required risk
- Required evidence
- source code
- Default configuration
- Enabled
- Default severity
- warn
Show technical metadata
- Scope
- All supported frameworks
- Active when
- always
- Priority
- 42 (P3)
- Source
- oxlint-plugin-react-doctor
- Rule set
- oxlint-plugin-react-doctor 0.9.3 (prompt schema 2)
- Documentation
- Official documentation
Validation prompt
Confirm the detector match and collect the required evidence before deciding whether an edit is warranted.
Fires on a lowercase-host JSXElement whose tag is in {table,thead,tbody,tfoot,tr,td,th} when its nearest JSXElement ancestor is a lowercase host element that violates HTML table nesting: thead/tbody/tfoot whose nearest host ancestor is not table; tr whose nearest host ancestor is neither a row group nor table; td/th whose nearest host ancestor is not tr; or a nested table whose enclosing host is another table element with no intervening td/th cell. The ancestor walk (findClosestHostAncestor) skips non-element wrappers: JSX fragments, {…} expression containers, ternary/logical/arrow-body wrappers: and stops at the FIRST JSXElement ancestor; a lowercase tag is that element's host parent, while a capitalized custom component, a member-expression name (<Table.Body>), or a namespaced name is opaque: the structural check bails and SUPPRESSES the moment such a non-host element is the first JSXElement encountered, rather than continuing up to find a real host. False positive boundary: SUPPRESS when the first JSXElement ancestor is a capitalized custom component (<TableBody>) or a member-expression name (<Table.Body>): runtime DOM under those is opaque; a namespaced JSX name (e.g. <svg:circle>) hits the same opaque branch though it has no dedicated test. Also SUPPRESS when there is no JSXElement ancestor at all (a top-level <td> fragment returned by a component, composed into a real <tr> elsewhere); on a bare <table><tr> with no row group (browsers auto-insert tbody, so it is valid); and on a <table> nested inside a <td> OR <th> cell (legal HTML: both are valid containers for a nested table).
Evidence boundary
The diagnostic proves only that the detector’s modeled source pattern matched. It does not prove runtime impact, product intent, rendered failure, or that one remediation is correct.
Establish the environment, repository policy, exceptions, and required rendered or runtime evidence before deciding the occurrence.
Record one outcome:
- Confirmed failure: The required evidence establishes the violation.
- Rejected: A documented exception or false-positive predicate applies.
- Needs evidence: Named evidence can still be collected.
- Unavailable: Required evidence cannot be collected in this run.
- Waived with evidence: An authorized, scoped exception applies to an established failure.
- Observation: The review records an optional tradeoff without claiming a defect.
A waiver records its scope, authority, evidence, and review condition. It is not a pass or false positive.
Default severity is registry metadata. Use the occurrence’s JSON severity after repository configuration when ordering real findings.
Fix prompt
Apply this candidate correction only after the required evidence confirms the risk.
Author the markup to the HTML table contract so the runtime DOM matches the JSX: put <thead>/<tbody>/<tfoot> as direct children of <table>, wrap <tr> in a row group (or directly in <table>), and wrap every <td>/<th> in a <tr>: e.g. rewrite <table><td>x</td></table> to <table><tbody><tr><td>x</td></tr></tbody></table>. For a table inside a table, place the inner <table> within a <td> or <th> cell of the outer one. If the offending element's first JSXElement ancestor is a wrapper component (<TableBody>, <Table.Body>), confirm the composed runtime parent is correct rather than restructuring the literal JSX. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table
Repository-wide copy prompt
Use this repository-wide prompt only after validating each occurrence. For one occurrence, use the guidance above.
Show repository-wide prompt
Fix every confirmed react-doctor/html-no-invalid-table-nesting diagnostic in the current repository.
Required change:
- Author the markup to the HTML table contract so the runtime DOM matches the JSX: put <thead>/<tbody>/<tfoot> as direct children of <table>, wrap <tr> in a row group (or directly in <table>), and wrap every <td>/<th> in a <tr>: e.g. rewrite <table><td>x</td></table> to <table><tbody><tr><td>x</td></tr></tbody></table>. For a table inside a table, place the inner <table> within a <td> or <th> cell of the outer one. If the offending element's first JSXElement ancestor is a wrapper component (<TableBody>, <Table.Body>), confirm the composed runtime parent is correct rather than restructuring the literal JSX. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table.
Validation before editing:
Fires on a lowercase-host JSXElement whose tag is in {table,thead,tbody,tfoot,tr,td,th} when its nearest JSXElement ancestor is a lowercase host element that violates HTML table nesting: thead/tbody/tfoot whose nearest host ancestor is not table; tr whose nearest host ancestor is neither a row group nor table; td/th whose nearest host ancestor is not tr; or a nested table whose enclosing host is another table element with no intervening td/th cell. The ancestor walk (findClosestHostAncestor) skips non-element wrappers: JSX fragments, {…} expression containers, ternary/logical/arrow-body wrappers: and stops at the FIRST JSXElement ancestor; a lowercase tag is that element's host parent, while a capitalized custom component, a member-expression name (<Table.Body>), or a namespaced name is opaque: the structural check bails and SUPPRESSES the moment such a non-host element is the first JSXElement encountered, rather than continuing up to find a real host. False positive boundary: SUPPRESS when the first JSXElement ancestor is a capitalized custom component (<TableBody>) or a member-expression name (<Table.Body>): runtime DOM under those is opaque; a namespaced JSX name (e.g. <svg:circle>) hits the same opaque branch though it has no dedicated test. Also SUPPRESS when there is no JSXElement ancestor at all (a top-level <td> fragment returned by a component, composed into a real <tr> elsewhere); on a bare <table><tr> with no row group (browsers auto-insert tbody, so it is valid); and on a <table> nested inside a <td> OR <th> cell (legal HTML: both are valid containers for a nested table).
Constraints:
- Make the smallest change that fixes the root cause.
- Preserve behavior and interfaces unrelated to this diagnostic.
- Reuse existing project components, utilities, and conventions.
- Adapt identifiers and framework details instead of copying blindly.
- Do not disable the rule or suppress matching code.
Assessment:
- Record detector evidence, applicability facts, assumptions, missing evidence, and the rule class for this occurrence.
- Return one outcome: Confirmed failure, Rejected, Needs evidence, Unavailable, Waived with evidence, or Observation.
- A waiver records the established failure, scope, authority, evidence, and review or expiry condition. It is not a pass or false positive.
Verification:
- Run focused tests for the changed behavior.
- Run React Doctor and confirm this diagnostic no longer appears from changed code.
- Run an unfiltered scan of the affected scope before claiming no cross-category regression.
- Report the files changed and any checks you could not run.