0.1.8 โ€ข Published 4 months ago

@alexberriman/visual-dom-auditor v0.1.8

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

๐Ÿ“– Table of Contents


โœจ Why Visual DOM Auditor?

Your CSS looks perfect. Your code validates. But your site still breaks visually. Visual DOM Auditor catches what other tools miss โ€” the real layout issues that frustrate users.


๐Ÿ”ฅ Features


โšก Installation

# Use directly (recommended)
npx @alexberriman/visual-dom-auditor --url https://example.com

# Or install globally
npm install -g @alexberriman/visual-dom-auditor

๐ŸŽฏ Quick Examples

Basic Usage

# Analyze a single page
npx @alexberriman/visual-dom-auditor --url https://example.com

# Test mobile layout
npx @alexberriman/visual-dom-auditor --url https://example.com --viewport mobile

# Save results
npx @alexberriman/visual-dom-auditor --url https://example.com --save report.json

Advanced Usage

# Test multiple pages with custom viewport
npx @alexberriman/visual-dom-auditor \
  --urls https://example.com https://example.com/about \
  --viewport 1366x768 \
  --save results.json

# Crawl entire site
npx @alexberriman/visual-dom-auditor \
  --url https://example.com \
  --crawl \
  --max-pages 50 \
  --max-threads 5

# Run specific detectors only
npx @alexberriman/visual-dom-auditor \
  --url https://example.com \
  --detectors "overlap,console-error"

๐Ÿ› ๏ธ Command Reference

Core Options

OptionDescriptionDefault
--urlSingle URL to analyze-
--urlsMultiple URLs to analyze-
--viewportdesktop, tablet, mobile, or WIDTHxHEIGHTdesktop
--saveSave results to file-
--formatOutput formatjson
--verboseShow detailed logsfalse
--exit-earlyStop on first critical errorfalse

Detector Options

OptionDescriptionDefault
--detectorsComma-separated list of detectorsAll enabled

Crawling Options

OptionDescriptionDefault
--crawlEnable site crawlingfalse
--max-depthMaximum crawl depth (1-10)3
--max-pagesMaximum pages to crawl (1-1000)50
--max-threadsConcurrent threads (1-10)3

๐Ÿงช Detectors

๐ŸŽฏ Enabled by Default

{
  "type": "overlap",
  "severity": "critical",
  "elements": [
    {"selector": ".header-logo", "description": "Header logo"},
    {"selector": ".nav-menu", "description": "Navigation menu"}
  ],
  "overlapPercentage": 65
}
{
  "type": "padding",
  "severity": "major",
  "element": {"selector": ".submit-btn", "description": "Submit button"},
  "insufficientSides": ["top", "bottom"]
}
{
  "type": "spacing",
  "severity": "minor",
  "spacing": 2,
  "recommendedSpacing": 8
}
{
  "type": "container-overflow",
  "severity": "major",
  "overflowDirection": "right",
  "overflowAmount": 15
}
{
  "type": "scrollbar",
  "severity": "critical",
  "overflowAmount": 320
}
{
  "type": "flex-grid",
  "severity": "major",
  "issue": "overflow"
}
{
  "type": "console-error",
  "severity": "critical",
  "level": "error",
  "message": "TypeError: Cannot read property 'foo' of undefined"
}

๐Ÿ”ต Disabled by Default

  • Centering Detector โ€” Enable with --detectors centering

๐Ÿ•ท๏ธ Site Crawling

Automatically discover and analyze your entire website.

# Basic crawl
npx @alexberriman/visual-dom-auditor --url https://example.com --crawl

# Advanced crawl with limits
npx @alexberriman/visual-dom-auditor \
  --url https://example.com \
  --crawl \
  --max-depth 5 \
  --max-pages 100 \
  --max-threads 5 \
  --save crawl-report.json

How It Works

  1. ๐Ÿš€ Starts from your URL
  2. ๐Ÿ” Discovers internal links
  3. ๐Ÿงน Filters external/asset links
  4. โšก Analyzes pages concurrently
  5. ๐Ÿ“Š Reports aggregated results

๐Ÿ“Š Output Formats

Single URL

{
  "url": "https://example.com",
  "timestamp": "2023-05-20T10:15:30Z",
  "issues": [...],
  "metadata": {
    "totalIssuesFound": 3,
    "criticalIssues": 1,
    "issuesByType": {...}
  }
}

Multiple URLs / Crawl

{
  "timestamp": "2023-05-20T10:15:30Z",
  "results": [...],
  "summary": {
    "totalUrls": 15,
    "urlsWithIssues": 8,
    "totalIssuesFound": 23
  },
  "crawlMetadata": {
    "startUrl": "https://example.com",
    "pagesSkipped": 32,
    "crawlDuration": 45000
  }
}

๐Ÿ”„ CI/CD Integration

GitHub Actions

name: Visual Audit
on: [push, pull_request]

jobs:
  audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Install Playwright
        run: npx playwright install chromium
      - name: Run Visual Audit
        run: |
          npx @alexberriman/visual-dom-auditor \
            --url https://staging.example.com \
            --crawl \
            --exit-early \
            --save report.json
      - uses: actions/upload-artifact@v3
        with:
          name: audit-report
          path: report.json

Quick CI Commands

# Fail fast on critical issues
npx @alexberriman/visual-dom-auditor --url $STAGING_URL --exit-early

# Full site audit
npx @alexberriman/visual-dom-auditor --url $STAGING_URL --crawl --max-pages 25

๐ŸŽจ Advanced Usage

Pipe to Other Tools

# Pretty print with jq
npx @alexberriman/visual-dom-auditor --url https://example.com | jq '.'

# Extract critical issues
npx @alexberriman/visual-dom-auditor --url https://example.com | \
  jq '.issues[] | select(.severity == "critical")'

# Count issues by type
npx @alexberriman/visual-dom-auditor --url https://example.com | \
  jq '.metadata.issuesByType'

Programmatic Usage

import { analyzePage } from "@alexberriman/visual-dom-auditor/core/analyzer";
import { allDetectors } from "@alexberriman/visual-dom-auditor/core/detectors";

// Custom analysis
const result = await analyzePage(page, config, allDetectors);

๐Ÿค Contributing

We love contributions! Check out our contributing guide to get started.

# Fork and clone
git clone https://github.com/YOUR_USERNAME/visual-dom-auditor
cd visual-dom-auditor

# Install dependencies
npm install

# Make your changes
# ...

# Test
npm test

# Submit PR

๐Ÿ“œ License

MIT ยฉ Alex Berriman

0.1.8

4 months ago

0.1.7

4 months ago

0.1.6

5 months ago

0.1.5

5 months ago

0.1.4

5 months ago

0.1.3

5 months ago

0.1.2

5 months ago

0.1.1

5 months ago