JSPM

@hyandreas/greenlight

1.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • 0
    • Score
      100M100P100Q22672F
    • License MIT

    VS Code extension and GitHub Action for detecting non-Baseline web features

    Package Exports

    • @hyandreas/greenlight
    • @hyandreas/greenlight/dist/extension/extension.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@hyandreas/greenlight) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Greenlight

    A comprehensive VS Code extension and GitHub Action that detects non-Baseline web features and provides compatibility warnings with quick fixes.

    Features

    • ๐Ÿ” Real-time Detection: Parses JavaScript/TypeScript and CSS to detect non-Baseline web features
    • ๐Ÿ“Š Multiple Output Formats: Console, JSON, Markdown, and SARIF for CI/CD integration
    • โš™๏ธ Flexible Configuration: Support for Baseline 2024/2025 targets or custom browserslist
    • ๐Ÿ”ง VS Code Integration: Real-time diagnostics with MDN links and polyfill suggestions
    • ๐Ÿค– GitHub Action: Automated PR comments with compatibility reports
    • ๐Ÿ“ˆ Code Scanning: SARIF output for GitHub Advanced Security integration

    ๐Ÿš€ Quick Start

    CLI Usage

    # Install globally
    npm install -g @hyandreas/greenlight
    
    # Check a single file
    greenlight check src/components/modern-features.js
    
    # Check multiple files with configuration
    greenlight check "src/**/*.{js,ts,css}" --config baseline.config.json
    
    # Generate different output formats
    greenlight check src/app.js --format json
    greenlight check src/app.js --format markdown
    greenlight check src/app.js --format sarif

    VS Code Extension

    1. Install from VS Code Marketplace: "Greenlight"
    2. Open a JavaScript/TypeScript/CSS file
    3. See real-time diagnostics for non-Baseline features
    4. Use quick fixes to add polyfills or alternative implementations

    GitHub Action

    name: Baseline Compatibility Check
    on: [pull_request]
    
    jobs:
      baseline-check:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v4
          - uses: ./  # Use your greenlight action
            with:
              files: 'src/**/*.{js,ts,css}'
              baseline-target: '2024'
              output-format: 'markdown'
              comment-pr: true

    โš™๏ธ Configuration

    Create a baseline.config.json in your project root:

    {
      "baseline": {
        "target": "2024"
      },
      "severity": {
        "default": "warning",
        "features": {
          "optional-chaining": "info",
          "css-has-selector": "error"
        }
      },
      "include": [
        "src/**/*.{js,jsx,ts,tsx,css,scss,less}"
      ],
      "exclude": [
        "**/node_modules/**",
        "**/dist/**"
      ],
      "ignore": {
        "features": []
      }
    }

    Configuration Options

    • baseline.target: "2024", "2025", or custom browserslist query
    • severity.default: Default severity level ("error", "warning", "info")
    • severity.features: Override severity for specific features
    • include: Glob patterns for files to check
    • exclude: Glob patterns for files to ignore
    • ignore.features: Array of feature names to ignore

    ๐Ÿ” Detected Features

    JavaScript/TypeScript

    • Optional chaining (obj?.prop)
    • Nullish coalescing (value ?? default)
    • Private class fields (#privateField)
    • Top-level await
    • Array.at() method
    • Static class blocks
    • And many more...

    CSS

    • :has() selector
    • Container queries (@container)
    • Cascade layers (@layer)
    • CSS subgrid
    • color-mix() function
    • Individual transform properties
    • CSS nesting
    • And many more...

    Web APIs

    • Clipboard API
    • Web Share API
    • Dialog element
    • Intersection Observer v2
    • CSS Typed OM
    • And many more...

    ๐Ÿ“Š Output Formats

    Console (Human-readable)

    โš ๏ธ  Non-Baseline features detected:
    
    ๐Ÿ“„ src/components/modern-features.js
      Line 3:  Optional chaining (?.) - Limited support in older browsers
      Line 5:  Private class field (#field) - ES2022 feature with limited support
      Line 12: Top-level await - Requires modern module support
    
    ๐Ÿ“„ src/styles/modern.css
      Line 2:  :has() selector - Limited browser support
      Line 8:  Container queries - Experimental feature

    JSON (Machine-readable)

    {
      "results": [
        {
          "file": "src/app.js",
          "line": 3,
          "column": 12,
          "feature": "optional-chaining",
          "message": "Optional chaining (?.) requires modern browsers",
          "severity": "warning",
          "baseline": "unknown",
          "browserSupport": ["chrome", "firefox", "safari"]
        }
      ],
      "summary": {
        "totalFiles": 1,
        "totalIssues": 1,
        "byFeature": {
          "optional-chaining": 1
        }
      }
    }

    SARIF (GitHub Code Scanning)

    Full SARIF 2.1.0 format for integration with GitHub Advanced Security and other static analysis tools.

    ๐Ÿงช Demo

    Run the comprehensive demonstration:

    node demo.js

    This will showcase:

    • Configuration system
    • Feature detection across multiple file types
    • All output formats
    • Error handling
    • Performance testing
    • Integration capabilities

    ๐Ÿ—๏ธ Development

    Setup

    git clone <repository>
    cd greenlight
    npm install
    npm run build

    Testing

    # Run all tests
    npm test
    
    # Run with coverage
    npm run test:coverage
    
    # Run specific test suites
    npm test -- test/parsers/
    npm test -- test/integration/

    Building

    # Build CLI
    npm run build:cli
    
    # Build VS Code extension
    npm run build:extension
    
    # Package extension
    npm run package:extension
    
    # Build GitHub Action
    npm run build:action

    ๐Ÿ“ Project Structure

    greenlight/
    โ”œโ”€โ”€ src/
    โ”‚   โ”œโ”€โ”€ cli/                 # Command-line interface
    โ”‚   โ”œโ”€โ”€ core/                # Core detection logic
    โ”‚   โ”‚   โ”œโ”€โ”€ parsers/         # JavaScript & CSS parsers
    โ”‚   โ”‚   โ”œโ”€โ”€ config/          # Configuration system
    โ”‚   โ”‚   โ””โ”€โ”€ output/          # Output formatters
    โ”‚   โ”œโ”€โ”€ extension/           # VS Code extension
    โ”‚   โ”œโ”€โ”€ action/              # GitHub Action
    โ”‚   โ””โ”€โ”€ data/                # Web features dataset
    โ”œโ”€โ”€ test/                    # Test suites
    โ”œโ”€โ”€ sample-project/          # Demo project with modern features
    โ””โ”€โ”€ docs/                    # Documentation

    ๐Ÿค Contributing

    1. Fork the repository
    2. Create a feature branch
    3. Add tests for your changes
    4. Ensure all tests pass
    5. Submit a pull request

    ๐Ÿ“„ License

    MIT License - see LICENSE file for details.


    A tool to help developers create more compatible web applications.