Baseline Logoeslint-plugin-baseline-js

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.

eslint.config.ts
import baselineJs from 'eslint-plugin-baseline-js';

export default [
  { plugins: { 'baseline-js': baselineJs } }, 
  baselineJs.configs.baseline({ available: 'widely', level: "warn" }), 
];
Using constants (optional)
import baselineJs, { BASELINE } from 'eslint-plugin-baseline-js';

export default [
  { plugins: { 'baseline-js': baselineJs } },
  baselineJs.configs.baseline({ available: BASELINE.WIDELY }),
];

Enables Web APIs / JS Builtins detection (preset: auto). Works well without types.

eslint.config.ts
import baselineJs from 'eslint-plugin-baseline-js';

export default [
  { plugins: { 'baseline-js': baselineJs } }, 
  baselineJs.configs.recommended({ available: "widely", level: "warn" }), 
];
Using constants (optional)
import baselineJs, { BASELINE } from 'eslint-plugin-baseline-js';

export default [
  { plugins: { 'baseline-js': baselineJs } },
  baselineJs.configs.recommended({ available: BASELINE.WIDELY }),
];

Uses type information to detect instance members as well (preset: type-aware).

eslint.config.ts
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' }),
];
Using constants (optional)
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:

date.getYear()
const date = new Date();
const year = date.getYear();
             ^^^^^^^^^^^^^^^
Feature 'getYear()' is not a widely available Baseline feature. 

Further reading

Last updated on