@e18e/eslint-plugin

May 11, 2026 ยท View on GitHub

The official e18e ESLint plugin for modernizing JavaScript/TypeScript code and improving performance.

This plugin focuses on applying the e18e community's best practices and advise to JavaScript/TypeScript codebases.

Overview

There are a few categories of rules in this plugin:

  • Modernization - New syntax and APIs which improve code readability and performance
  • Module replacements - Community recommended alternatives to popular libraries, focused on performance and size
  • Performance improvements - Patterns that can be optimized for better runtime performance

Each of these can be enabled individually, or you can use the recommended configuration to enable all rules.

Installation

npm install --save-dev @e18e/eslint-plugin

Usage

Add the plugin to your eslint.config.js:

import e18e from '@e18e/eslint-plugin';

export default [
  // Use the recommended configuration (includes all categories)
  e18e.configs.recommended,

  // Or use specific category configurations
  e18e.configs.modernization,
  e18e.configs.moduleReplacements,
  e18e.configs.performanceImprovements,

  // Or configure rules manually
  {
    plugins: {
      e18e
    },
    rules: {
      'e18e/prefer-array-at': 'error',
      'e18e/prefer-array-fill': 'error',
      'e18e/prefer-includes': 'error'
    }
  }
];

Usage with oxlint

If you're using oxlint, you can enable the e18e plugin by adding it to your .oxlintrc.json file:

{
  "jsPlugins": ["@e18e/eslint-plugin"],
  "rules": {
    "e18e/prefer-includes": "error"
  }
}

You can enable the recommended configuration by copying the rules from each of the ESLint configuration files into your .oxlintrc.json file.

Copying these rules into your rules object will achieve the same effect as using the recommended configuration in ESLint.

Note

Our type-aware rules depend on TypeScript ESLint's parser, which means they will not work with oxlint at this time.

Linting package.json

Some rules (e.g. ban-dependencies) can be used against your package.json.

You can achieve this by using @eslint/json or jsonc-eslint-parser.

For example, with @eslint/json and eslint.config.js:

import e18e from '@e18e/eslint-plugin';
import json from '@eslint/json';
import {defineConfig} from 'eslint/config';

export default defineConfig([
  {
    files: ['package.json'],
    language: 'json/json',
    plugins: {
      e18e,
      json
    },
    extends: ['e18e/recommended'],
  }
]);

Or with jsonc-eslint-parser and eslint.config.js:

import e18e from '@e18e/eslint-plugin';
import jsonParser from 'jsonc-eslint-parser';
import {defineConfig} from 'eslint/config';

export default defineConfig([
  {
    files: ['package.json'],
    languageOptions: {
      parser: jsonParser
    },
    plugins: {
      e18e
    },
    extends: ['e18e/recommended'],
  }
]);

Read more at the @eslint/json docs and jsonc-eslint-parser docs.

Rules

Legend:

  • โœ… = Yes / Enabled
  • โœ–๏ธ = No / Disabled
  • ๐Ÿ’ก = Has suggestions (requires user confirmation for fixes)
  • ๐Ÿ”ถ = Optionally uses types (works without TypeScript but more powerful with it)

Modernization

RuleDescriptionRecommendedFixableRequires Types
prefer-array-atPrefer Array.prototype.at() over length-based indexingโœ…โœ…๐Ÿ”ถ
prefer-array-fillPrefer Array.prototype.fill() over Array.from() or map() with constant valuesโœ…โœ…โœ–๏ธ
prefer-includesPrefer .includes() over indexOf() comparisons for arrays and stringsโœ…โœ…โœ–๏ธ
prefer-array-to-reversedPrefer Array.prototype.toReversed() over copying and reversing arraysโœ…โœ…๐Ÿ”ถ
prefer-array-to-sortedPrefer Array.prototype.toSorted() over copying and sorting arraysโœ…โœ…๐Ÿ”ถ
prefer-array-to-splicedPrefer Array.prototype.toSpliced() over copying and splicing arraysโœ…โœ…โœ–๏ธ
prefer-exponentiation-operatorPrefer the exponentiation operator ** over Math.pow()โœ…โœ…โœ–๏ธ
prefer-nullish-coalescingPrefer nullish coalescing operator (?? and ??=) over verbose null checksโœ…โœ…โœ–๏ธ
prefer-object-has-ownPrefer Object.hasOwn() over Object.prototype.hasOwnProperty.call() and obj.hasOwnProperty()โœ…โœ…โœ–๏ธ
prefer-spread-syntaxPrefer spread syntax over Array.concat(), Array.from(), Object.assign({}, ...), and Function.apply()โœ…โœ…๐Ÿ”ถ
prefer-url-canparsePrefer URL.canParse() over try-catch blocks for URL validationโœ…๐Ÿ’กโœ–๏ธ

Module replacements

RuleDescriptionRecommendedFixableRequires Types
ban-dependenciesDisallow dependencies in favor of more performant or secure alternativesโœ…โœ–๏ธโœ–๏ธ

Performance improvements

RuleDescriptionRecommendedFixableRequires Types
no-indexof-equalityPrefer startsWith() for strings and direct array access over indexOf() equality checksโœ–๏ธโœ…โœ…
prefer-array-from-mapPrefer Array.from(iterable, mapper) over [...iterable].map(mapper) to avoid intermediate array allocationโœ…โœ…โœ–๏ธ
prefer-array-somePrefer Array.some() over Array.find() and Array.filter().length checks when checking for element existenceโœ…โœ…โœ–๏ธ
prefer-timer-argsPrefer passing function and arguments directly to setTimeout/setInterval instead of wrapping in an arrow function or using bindโœ…โœ…โœ–๏ธ
prefer-date-nowPrefer Date.now() over new Date().getTime() and +new Date()โœ…โœ…โœ–๏ธ
prefer-regex-testPrefer RegExp.test() over String.match() and RegExp.exec() when only checking for match existenceโœ…โœ…๐Ÿ”ถ
prefer-static-regexPrefer defining regular expressions at module scope to avoid re-compilation on every function callโœ…โœ–๏ธ๐Ÿ”ถ
prefer-inline-equalityPrefer inline equality checks over temporary object creation for simple comparisonsโœ–๏ธโœ…๐Ÿ”ถ
prefer-string-fromcharcodePrefer String.fromCharCode() over String.fromCodePoint() for code points below 0x10000โœ…โœ…โœ–๏ธ
prefer-includes-over-regex-testPrefer s.includes() / startsWith / endsWith over /literal/.test(s) when the regex has no metacharacters or flagsโœ–๏ธโœ…โœ–๏ธ
no-delete-propertyDisallow delete on properties โ€” V8 deoptimizes the object to dictionary modeโœ–๏ธ๐Ÿ’กโœ–๏ธ
no-spread-in-reduceDisallow spreading the accumulator inside a .reduce() callback โ€” it's O(Nยฒ)โœ–๏ธโœ–๏ธโœ–๏ธ
prefer-static-collatorPrefer hoisting an Intl.Collator over calling localeCompare inside a sort/toSorted callbackโœ–๏ธโœ–๏ธโœ–๏ธ

Sponsors

e18e community sponsors

License

MIT