Registry / testing / base-lint

base-lint

JSON →
library1.2.1jsnpmunverified

base-lint scans repositories for usage of modern Web Platform features and evaluates them against the Baseline dataset to ensure new features ship with fallbacks. Version 1.2.1 is current, with active maintenance and a GitHub Action for CI integration. Key differentiators include diff-mode analysis (default), Markdown and JSON reports, threshold-based enforcement (base-lint enforce), GitHub Checks annotation (base-lint annotate), and PR comment creation (base-lint comment). It relies on @typescript-eslint/typescript-estree for parsing TypeScript/JavaScript, requiring Node.js 18.17+ or 20.x LTS. Alternatives like Lighthouse or caniuse require external dataset integration, whereas base-lint provides an out-of-the-box CLI with built-in Baseline compliance tooling.

npm install base-lint
INSTALL
IMPORT
SIG · BASE-LINT
B
base-lint
testingjavascriptv1.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import baseLint from 'base-lint'
const baseLint = require('base-lint')
The package is ESM-only since v1.2.0; CommonJS require() will fail.
scan
import { scan } from 'base-lint'
const { scan } = require('base-lint')
Named export available for programmatic use; ESM import must use named syntax.
enforce
import { enforce } from 'base-lint'
import enforce from 'base-lint/enforce'
enforce is a top-level named export, not a submodule.

Demonstrates programmatic usage of init, scan, enforce, and clean functions with ESM imports.

// Initialize a new base-lint configuration and run a diff scan import { scan, init, clean } from 'base-lint'; import { writeFileSync, mkdirSync, existsSync } from 'fs'; import { resolve } from 'path'; async function main() { // Step 1: Initialize config (scaffold .base-lintrc.json, .base-lintignore) await init({ cwd: process.cwd() }); // Step 2: Scan the current diff (default mode) and get report const result = await scan({ cwd: process.cwd(), mode: 'diff', // or 'repo' for full scan outputDir: '.base-lint-report', }); console.log('Report generated at:', result.outputPath); // Step 3: Enforce thresholds (e.g., max violations: 0) const enforceResult = await enforce({ reportPath: resolve('.base-lint-report/report.json'), thresholds: { errors: 0, warnings: 5 }, }); if (!enforceResult.passed) { console.error('Enforcement failed:', enforceResult.violations); process.exit(1); } // Step 4: Clean up report artifacts (optional) await clean({ outputDir: '.base-lint-report' }); } main().catch(console.error);
base-lint --version
Debug
Known issues
breakingESM-only since v1.2.0: package no longer supports CommonJS require().
fix
Use import instead of require; for CommonJS projects, upgrade to Node.js 20+ and use dynamic import or await import().
affects: >=1.2.0
deprecatedbase-lint init --action flag is deprecated; use --github-action instead.
fix
Replace '--action' with '--github-action' when scaffolding GitHub Action workflow.
affects: >=1.1.0
gotchaDiff mode (default) only scans staged changes; uncommitted files are ignored unless --mode=repo is passed.
fix
Ensure all changes are staged (git add) before running base-lint scan, or use --mode=repo for full codebase scan.
affects: *
breakinRemoved caching in v1.1.1 due to bundle size bloat; cache support no longer available.
fix
Remove any cache configuration from .base-lintrc.json; manual caching via CI artifacts is still possible.
affects: >=1.1.1
gotchaTypeScript parsing errors may occur with TS versions not supported by @typescript-eslint/typescript-estree.
fix
Check @typescript-eslint/typescript-estree peer dependency version and keep TypeScript within supported range (≤5.4.x).
affects: *
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/base-lint/dist/index.js from /path/to/project/index.js not supported.
Using CommonJS require() on an ESM-only package (v1.2.0+).
fix
Switch to ESM (type: module in package.json) and use import statements, or use dynamic import: const baseLint = await import('base-lint');
Error: Command 'scan' failed with exit code 1: No staged changes found. Use --mode=repo to scan the entire repository.
Running diff mode without any staged files in git.
fix
Stage changes with git add before running scan, or pass --mode=repo for full scan.
TypeScript Error: Cannot find module 'base-lint' or its corresponding type declarations.
Typings not installed; base-lint requires @types/base-lint for TypeScript.
fix
Run npm install --save-dev @types/base-lint (note: typings may be bundled in future versions).
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies
@typescript-eslint/typescript-estreeoptionalParses TypeScript and JavaScript source files to detect feature usage.
@typescript-eslint/parseroptionalAlternative parser for ESLint integration (not directly required by CLI but commonly used).
Agent activity
20 hits · last 30 days
node
16
Amazon
1
OpenAI (training)
1
Resources
base-lint — npm install base-lint · libregistry