Quick Start
Get up and running with eslint-plugin-baseline-js.
What is this plugin?
eslint-plugin-baseline-js
enforces the JavaScript Baseline using the
web‑features dataset as the single source of truth. It flags usage that
exceeds your chosen Baseline threshold (widely
, newly
, or a year).
- Scope: JS Syntax / JS Builtins / Web APIs (web‑features
group: 'javascript'
) - One rule:
baseline-js/use-baseline
- Philosophy: report only when a feature exceeds the configured Baseline
Quick Start
Install
Add the plugin to your project:
pnpm add -D eslint-plugin-baseline-js
ESLint Config Setup
Pick one of the following Flat Config setups to get started.
Terminology
See Scope & Terms for the difference between JS Syntax, JS Builtins, and Web APIs.
JS Syntax only (Web APIs / JS Builtins off)
Checks only JS Syntax (delegated). Web APIs / JS Builtins are disabled.
import baselineJs from 'eslint-plugin-baseline-js';
export default [
{ plugins: { 'baseline-js': baselineJs } },
baselineJs.configs.baseline({ available: 'widely', level: "warn" }),
];
import baselineJs, { BASELINE } from 'eslint-plugin-baseline-js';
export default [
{ plugins: { 'baseline-js': baselineJs } },
baselineJs.configs.baseline({ available: BASELINE.WIDELY }),
];
Recommended (JavaScript projects)
Enables Web APIs / JS Builtins detection (preset: auto
). Works well without types.
import baselineJs from 'eslint-plugin-baseline-js';
export default [
{ plugins: { 'baseline-js': baselineJs } },
baselineJs.configs.recommended({ available: "widely", level: "warn" }),
];
import baselineJs, { BASELINE } from 'eslint-plugin-baseline-js';
export default [
{ plugins: { 'baseline-js': baselineJs } },
baselineJs.configs.recommended({ available: BASELINE.WIDELY }),
];
Recommended (TypeScript – type‑aware)
Uses type information to detect instance members as well (preset: type-aware
).
import tsParser from '@typescript-eslint/parser';
import baselineJs from 'eslint-plugin-baseline-js';
export default [
// Enable type information (required for instance member detection)
{
files: ['**/*.{ts,tsx}'],
languageOptions: { parser: tsParser, parserOptions: { project: ['./tsconfig.json'] } },
},
{ plugins: { 'baseline-js': baselineJs } },
baselineJs.configs['recommended-ts']({ available: 'widely' }),
];
import tsParser from '@typescript-eslint/parser';
import baselineJs, { BASELINE } from 'eslint-plugin-baseline-js';
export default [
{
files: ['**/*.{ts,tsx}'],
languageOptions: { parser: tsParser, parserOptions: { project: ['./tsconfig.json'] } },
},
{ plugins: { 'baseline-js': baselineJs } },
baselineJs.configs['recommended-ts']({ available: BASELINE.WIDELY }),
];
You’re all set
If everything is wired correctly, deprecated/limited APIs are reported like this:
const date = new Date();
const year = date.getYear();
^^^^^^^^^^^^^^^
Feature 'getYear()' is not a widely available Baseline feature.
Further reading
- W3C WebDX — Web Features (Baseline): What is Baseline?
- Case study: Bringing Baseline into Product Development — and Keeping It Safe in Practice
Last updated on