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 sarifVS Code Extension
- Install from VS Code Marketplace: "Greenlight"
- Open a JavaScript/TypeScript/CSS file
- See real-time diagnostics for non-Baseline features
- 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 queryseverity.default: Default severity level ("error","warning","info")severity.features: Override severity for specific featuresinclude: Glob patterns for files to checkexclude: Glob patterns for files to ignoreignore.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 featureJSON (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.jsThis 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 buildTesting
# 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
- Fork the repository
- Create a feature branch
- Add tests for your changes
- Ensure all tests pass
- Submit a pull request
๐ License
MIT License - see LICENSE file for details.
๐ Links
A tool to help developers create more compatible web applications.