UNPKG

eslint-plugin-baseline-js

Version:

Enforce JavaScript Baseline (widely/newly/year) browser compatibility with a single ESLint rule. Prevent runtime errors by catching unsupported JavaScript features during development.

57 lines (55 loc) 1.8 kB
import { Rule } from "eslint"; //#region src/config.d.ts /** * Named constants for Baseline string options. * Prefer using these to avoid typos in user configs. */ declare const BASELINE: { readonly WIDELY: "widely"; readonly NEWLY: "newly"; }; /** String-only Baseline names*/ type BaselineName = (typeof BASELINE)[keyof typeof BASELINE]; /** Final option type: the named baseline or a year (YYYY) */ type BaselineOption = BaselineName | number; //#endregion //#region src/configs/baseline.d.ts /** * Recommended config: enable Baseline with Web APIs and JS builtins detection on auto preset. * - baseline: defaults to 'widely' * - includeWebApis/includeJsBuiltins: { preset: 'auto' } */ declare function recommendedConfig(opts?: { available?: BaselineOption; baseline?: BaselineOption; env?: "browser" | "worker" | "node"; level?: "error" | "warn"; }): { readonly files: readonly ["**/*.{js,cjs,mjs,jsx}"]; readonly rules: Record<string, unknown>; }; /** * Recommended config for TypeScript-aware projects: * - Uses 'type-aware' preset to require type information for instance-member checks. * - Falls back gracefully when types are unavailable (instance checks are skipped by the rule). */ declare function recommendedTsConfig(opts?: { available?: BaselineOption; baseline?: BaselineOption; env?: "browser" | "worker" | "node"; level?: "error" | "warn"; }): { readonly files: readonly ["**/*.{ts,tsx}"]; readonly rules: Record<string, unknown>; }; //#endregion //#region src/index.d.ts declare const _default: { readonly rules: Record<string, Rule.RuleModule>; readonly configs: { readonly recommended: typeof recommendedConfig; readonly "recommended-ts": typeof recommendedTsConfig; }; }; //#endregion export { BASELINE, _default as default };