JS-1803 Fix S6478 false positives for react-table headers#7126
JS-1803 Fix S6478 false positives for react-table headers#7126francois-mora-sonarsource wants to merge 2 commits into
Conversation
Ruling Report✅ No changes to ruling expected issues in this PR |
Code Review ✅ ApprovedExcludes react-table column headers from S6478 by treating them as render callbacks rather than nested component definitions. No issues found. OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
|
Rule Profile
function Parent() {
function Header() {
return <div />;
}
return <Header />;
}False Positive PatternThe false positives happen in function Parent() {
const columns = [
{
Header: () => <CustomHeader />,
accessor: 'name',
},
];
useTable({ columns });
return <Table columns={columns} />;
}False Negative RiskThe risk is bounded because the fix does not suppress all nested JSX-returning functions or all object properties named like components. It suppresses only static Fix SummaryThe implementation recognizes
|




Summary
Fixes a React false positive in S6478 by treating react-table column
Headerfunctions as render callbacks, not nested component definitions.The exemption is scoped to column-like objects containing
Headerplusaccessor,columns, orid, and a regression test keeps genericHeaderrenderer objects noncompliant.Validation
./node_modules/.bin/tsx --tsconfig packages/tsconfig.test.json --test packages/analysis/src/jsts/rules/S6478/unit.test.tsgit diff --checknpm run bridge:compilewas attempted, but this fresh worktree lacks the ignored generated rule metadata/index artifacts expected by the command, so it fails before branch-specific checking.