{"id":24981,"library":"base-lint","title":"base-lint CLI","description":"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.","status":"active","version":"1.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/ej-sanmartin/base-lint","tags":["javascript","lint","baseline","eslint","stylelint","typescript","css","cli"],"install":[{"cmd":"npm install base-lint","lang":"bash","label":"npm"},{"cmd":"yarn add base-lint","lang":"bash","label":"yarn"},{"cmd":"pnpm add base-lint","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Parses TypeScript and JavaScript source files to detect feature usage.","package":"@typescript-eslint/typescript-estree","optional":true},{"reason":"Alternative parser for ESLint integration (not directly required by CLI but commonly used).","package":"@typescript-eslint/parser","optional":true}],"imports":[{"note":"The package is ESM-only since v1.2.0; CommonJS require() will fail.","wrong":"const baseLint = require('base-lint')","symbol":"default","correct":"import baseLint from 'base-lint'"},{"note":"Named export available for programmatic use; ESM import must use named syntax.","wrong":"const { scan } = require('base-lint')","symbol":"scan","correct":"import { scan } from 'base-lint'"},{"note":"enforce is a top-level named export, not a submodule.","wrong":"import enforce from 'base-lint/enforce'","symbol":"enforce","correct":"import { enforce } from 'base-lint'"}],"quickstart":{"code":"// Initialize a new base-lint configuration and run a diff scan\nimport { scan, init, clean } from 'base-lint';\nimport { writeFileSync, mkdirSync, existsSync } from 'fs';\nimport { resolve } from 'path';\n\nasync function main() {\n  // Step 1: Initialize config (scaffold .base-lintrc.json, .base-lintignore)\n  await init({ cwd: process.cwd() });\n\n  // Step 2: Scan the current diff (default mode) and get report\n  const result = await scan({\n    cwd: process.cwd(),\n    mode: 'diff', // or 'repo' for full scan\n    outputDir: '.base-lint-report',\n  });\n\n  console.log('Report generated at:', result.outputPath);\n\n  // Step 3: Enforce thresholds (e.g., max violations: 0)\n  const enforceResult = await enforce({\n    reportPath: resolve('.base-lint-report/report.json'),\n    thresholds: { errors: 0, warnings: 5 },\n  });\n\n  if (!enforceResult.passed) {\n    console.error('Enforcement failed:', enforceResult.violations);\n    process.exit(1);\n  }\n\n  // Step 4: Clean up report artifacts (optional)\n  await clean({ outputDir: '.base-lint-report' });\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Demonstrates programmatic usage of init, scan, enforce, and clean functions with ESM imports."},"warnings":[{"fix":"Use import instead of require; for CommonJS projects, upgrade to Node.js 20+ and use dynamic import or await import().","message":"ESM-only since v1.2.0: package no longer supports CommonJS require().","severity":"breaking","affected_versions":">=1.2.0"},{"fix":"Replace '--action' with '--github-action' when scaffolding GitHub Action workflow.","message":"base-lint init --action flag is deprecated; use --github-action instead.","severity":"deprecated","affected_versions":">=1.1.0"},{"fix":"Ensure all changes are staged (git add) before running base-lint scan, or use --mode=repo for full codebase scan.","message":"Diff mode (default) only scans staged changes; uncommitted files are ignored unless --mode=repo is passed.","severity":"gotcha","affected_versions":"*"},{"fix":"Remove any cache configuration from .base-lintrc.json; manual caching via CI artifacts is still possible.","message":"Removed caching in v1.1.1 due to bundle size bloat; cache support no longer available.","severity":"breakin","affected_versions":">=1.1.1"},{"fix":"Check @typescript-eslint/typescript-estree peer dependency version and keep TypeScript within supported range (≤5.4.x).","message":"TypeScript parsing errors may occur with TS versions not supported by @typescript-eslint/typescript-estree.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Switch to ESM (type: module in package.json) and use import statements, or use dynamic import: const baseLint = await import('base-lint');","cause":"Using CommonJS require() on an ESM-only package (v1.2.0+).","error":"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."},{"fix":"Stage changes with git add before running scan, or pass --mode=repo for full scan.","cause":"Running diff mode without any staged files in git.","error":"Error: Command 'scan' failed with exit code 1: No staged changes found. Use --mode=repo to scan the entire repository."},{"fix":"Run npm install --save-dev @types/base-lint (note: typings may be bundled in future versions).","cause":"Typings not installed; base-lint requires @types/base-lint for TypeScript.","error":"TypeScript Error: Cannot find module 'base-lint' or its corresponding type declarations."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}