baseline-gardener
v1.2.0
Published
π± Nurture baseline-compatible web code - A CI/CD tool to check web feature baseline compatibility
Maintainers
Readme

π± Baseline Gardener
Nurture baseline-compatible web code - A CI/CD tool to check web feature baseline compatibility
A practical tool for modern web development workflows.
What is Baseline?

Baseline provides clear information about which web platform features work across modern browsers. Baseline Gardener helps you:
- β Avoid compatibility surprises - Know what won't work before users complain
- π Make informed decisions - Data-driven choices about when to adopt new features
- π Ship with confidence - Automated compatibility checking in CI/CD
- π Track adoption - See your baseline compatibility improve over time
Features
- π Multi-language support: JavaScript, CSS, HTML, Vue, Svelte
- π Multiple output formats: Text, JSON, Markdown, SARIF
- π¨ CI/CD integration: GitHub Actions, custom workflows
- βοΈ Configurable thresholds: Widely vs newly available features
- π Rich reporting: Detailed compatibility insights
- π Always fresh data: Auto-generates from latest web-features package
Quick Start
Installation
npm install -g baseline-gardenerBasic Usage
# Scan current directory
baseline-gardener scan
# Scan specific path
baseline-gardener scan ./src
# Require only widely available features
baseline-gardener scan --require-baseline widely
# Generate markdown report
baseline-gardener scan --format markdown -o report.mdCommand Line Options
baseline-gardener scan [path] [options]
Options:
-f, --format <format> Output format (text, json, markdown, sarif, ai)
--require-baseline <level> Required baseline level (widely, newly)
--allow-experimental Allow non-baseline features
--update-baseline Update to latest web-features data
--ai Generate AI-optimized markdown for LLM auto-fixing
-o, --output <file> Output file (default: stdout)
--config <path> Path to config file
-h, --help Display helpConfiguration
Create a .baselinerc.json file in your project root:
{
"minBaseline": "newly",
"ignorePaths": [
"node_modules/",
"dist/",
"*.min.js"
],
"ignoreFeatures": [
"experimental-feature-id"
],
"failOnNonBaseline": true
}What Gets Detected
JavaScript APIs
- Browser APIs (
navigator.*,window.*) - DOM methods (
document.querySelector, element methods) - Modern JS features (ES6+, Web APIs)
- Fetch API, Storage APIs, etc.
CSS Features
- Properties (
container-type,backdrop-filter) - Values (
grid,flex,subgrid) - Selectors (
:has(),:is(),::marker) - At-rules (
@container,@layer)
HTML Elements
- Modern elements (
<dialog>,<details>) - Input types (
email,date,color) - Attributes (
loading,decoding)
CI/CD Integration
GitHub Actions
name: Baseline Check
on: [push, pull_request]
jobs:
baseline:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm install -g baseline-gardener
- run: baseline-gardener scan --format sarif -o results.sarif
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarifOther CI Systems
# Any CI system
npm install -g baseline-gardener
baseline-gardener scan --format jsonOutput Formats
Text (Default)
Human-readable terminal output with colors and formatting.
JSON
Machine-readable format for integration with other tools:
{
"metadata": { "tool": "baseline-gardener", "version": "1.0.0" },
"summary": { "totalFiles": 12, "baselineFeatures": 45, "issues": 3 },
"issues": [...]
}Markdown
Perfect for documentation and reports:
# π Baseline Guardian Report
## π Summary
- Files scanned: 12
- Baseline compatible: 45
- Issues found: 3SARIF
For GitHub Code Scanning and security tools integration.
AI Format
AI-optimized markdown designed for LLM processing and automatic code fixing:
baseline-gardener scan --ai -o ai-report.mdThis format includes:
- Structured issue breakdown by file and location
- Code context with problematic snippets
- Fix suggestions with baseline-compatible alternatives
- AI processing instructions for automated remediation
- Explanation of issues to help LLMs understand the context
Perfect for feeding into Claude, GPT, or other LLMs for automatic baseline compatibility fixes.
Real-World Example
Check out our React demo repository that shows baseline-gardener in action with:
- β Baseline-safe code using widely available features
- β Experimental code using cutting-edge APIs
- π§ CI/CD setup with GitHub Actions
How It Works
Parse your code using industry-standard parsers:
- JavaScript: Babel AST parser
- CSS: css-tree parser
- HTML: htmlparser2
Detect feature usage through comprehensive mapping tables:
- JavaScript APIs (global functions, browser APIs, DOM methods)
- CSS properties and values (modern layout, styling features)
- HTML elements and attributes (semantic markup, input types)
Check baseline status against fresh web-features data:
- High: Widely available (safe everywhere)
- Low: Newly available (modern browsers)
- False: Limited availability (experimental)
Generate actionable reports with clear recommendations
Development
Build from source
git clone https://github.com/hjanuschka/baseline-gardener
cd baseline-gardener
npm install
npm run build
npm linkTesting
npm test
npm run lintUpdating Feature Mappings
# Update to latest web-features data
npm run baseline:updateArchitecture
baseline-gardener/
βββ src/
β βββ parsers/ # Language-specific parsers
β βββ detectors/ # Feature detection logic
β βββ baseline/ # web-features integration
β βββ reporters/ # Output format generators
β βββ cli.ts # Command-line interface
βββ mappings/ # Dynamic feature mapping tables
β βββ *-generated.json # Auto-generated from web-features
β βββ all-features-generated.json
βββ package.jsonContributing
We welcome contributions! Please see CONTRIBUTING.md for details.
Adding New Features
Feature mappings are automatically generated from the latest web-features data:
- Run mapping update:
npm run baseline:update - Update parsers if needed for new detection patterns
- Add tests for the new features
- Update documentation
FAQ
Q: How accurate is the baseline data? A: We use the official web-features package maintained by the WebDX Community Group and updated regularly.
Q: Can I customize which features to check?
A: Yes! Use .baselinerc.json to ignore specific features or file patterns.
Q: Does this replace caniuse.com? A: No, it complements it! This tool automates checking YOUR code against baseline data, while caniuse is for manual research.
Q: What about polyfills? A: Configure ignored features for APIs you're polyfilling. The tool focuses on native browser support.
License
MIT
Credits
- Built with web-features data
- Inspired by eslint-plugin-compat
β Star this repo if baseline-gardener helps you ship better web apps!
