Fix nested card detection, drop identical-card-grid

- Nested cards: fixed dedup to use WeakSet on actual elements instead
  of tag-name key, so all nested card instances are found (not just
  the first div-in-div pair). Now catches all 4+ nesting examples.
- Dropped identical-card-grid: too many legitimate uses (data displays,
  pricing cards, navigation tiles) make false positives unavoidable.
- Removed from CLI, browser script, tests, and ANTIPATTERNS registry.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Paul Bakaus
2026-03-17 15:54:00 -07:00
co-authored by Claude Opus 4.6
parent 94a20d811b
commit f90e640892
4 changed files with 12 additions and 129 deletions
+4 -12
View File
@@ -282,14 +282,11 @@ describe('partials skip page-level checks', () => {
// ---------------------------------------------------------------------------
describe('detectHtml — layout', () => {
test('layout-should-flag: detects nested cards', async () => {
test('layout-should-flag: detects all nested cards', async () => {
const f = await detectHtml(path.join(FIXTURES, 'layout-should-flag.html'));
expect(f.some(r => r.antipattern === 'nested-cards')).toBe(true);
});
test('layout-should-flag: detects identical card grid', async () => {
const f = await detectHtml(path.join(FIXTURES, 'layout-should-flag.html'));
expect(f.some(r => r.antipattern === 'identical-card-grid')).toBe(true);
const nested = f.filter(r => r.antipattern === 'nested-cards');
// Classic, 3-level (2 inner cards), CSS, shadcn = at least 5 nested card findings
expect(nested.length).toBeGreaterThanOrEqual(4);
});
test('detects monotonous spacing via regex', () => {
@@ -320,11 +317,6 @@ describe('detectHtml — layout', () => {
expect(f.filter(r => r.antipattern === 'nested-cards')).toHaveLength(0);
});
test('layout-should-pass: no identical-card-grid false positives', async () => {
const f = await detectHtml(path.join(FIXTURES, 'layout-should-pass.html'));
expect(f.filter(r => r.antipattern === 'identical-card-grid')).toHaveLength(0);
});
test('layout-should-pass: no monotonous-spacing false positives', async () => {
const f = await detectHtml(path.join(FIXTURES, 'layout-should-pass.html'));
expect(f.filter(r => r.antipattern === 'monotonous-spacing')).toHaveLength(0);