eslint-config-ts-prefixer

raw JSON →
4.2.0 verified Fri May 01 auth: no javascript

A zero-extend ESLint flat config for TypeScript projects, providing a curated ruleset focused on runtime safety and import organization via eslint-plugin-import-x. Current stable version is v4.2.0, released in early 2025 with support for ESLint v9/v10 and TypeScript 5. It differs from other shared configs by avoiding any base config inheritance, making all rules explicit for transparency, and heavily emphasizing fixable import sorting and formatting rules. The package migrated from eslint-plugin-import to eslint-plugin-import-x in v4.1.5 and dropped prettier-plugin in v4.0.0, requiring manual prettier setup if needed.

error Error: Cannot find module 'eslint-config-ts-prefixer'
cause eslint cannot resolve the config; missing install or incorrect import path.
fix
Run npm install --save-dev eslint-config-ts-prefixer and ensure you import as 'eslint-config-ts-prefixer' (no scope).
error TypeError: defineConfig is not a function
cause Using wrong import for defineConfig (from 'eslint' instead of 'eslint/config').
fix
Import { defineConfig } from 'eslint/config'.
error Error: Config array must contain objects or functions, got array
cause Spreading tsPrefixer array incorrectly inside defineConfig arguments.
fix
Make sure to spread inside an array: defineConfig([...tsPrefixer, ...])
error Parsing error: The 'parserOptions.tsconfigRootDir' option must be set when using project service.
cause tsconfigRootDir not set in user config.
fix
Add languageOptions.parserOptions.tsconfigRootDir: import.meta.dirname
breaking v4.0.0 removed prettier-plugin; you must configure Prettier separately if you still want formatting.
fix Install prettier and eslint-plugin-prettier manually, or use Prettier standalone.
breaking v4.0.0 requires ESLint flat config (eslint.config.js) — legacy .eslintrc not supported.
fix Migrate to eslint.config.js using flat config format. See ESLint migration guide.
breaking v4.1.5 migrated from eslint-plugin-import to eslint-plugin-import-x — custom import rule overrides may need adjustment.
fix If you rely on old import plugin rules, update rule names to match eslint-plugin-import-x.
gotcha tsconfigRootDir must be set explicitly to avoid picking up wrong tsconfig from node_modules.
fix Set parserOptions.tsconfigRootDir to import.meta.dirname (or __dirname in CJS).
gotcha The config does not include any JavaScript-specific rules; only TypeScript files are linted.
fix Add separate overrides for .js/.mjs files if needed, or use a different config for JS.
deprecated v1.x used .eslintrc format; v4.x is incompatible.
fix Upgrade to flat config and eslint-config-ts-prefixer v4.
npm install eslint-config-ts-prefixer
yarn add eslint-config-ts-prefixer
pnpm add eslint-config-ts-prefixer

Basic setup: import config, spread into defineConfig, set tsconfigRootDir for type-aware rules.

// eslint.config.js
import { defineConfig } from 'eslint/config';
import tsPrefixer from 'eslint-config-ts-prefixer';

export default defineConfig([
  ...tsPrefixer,
  {
    languageOptions: {
      parserOptions: {
        tsconfigRootDir: import.meta.dirname,
      },
    },
  },
]);

// package.json script
// "lint": "eslint . --concurrency=auto --max-warnings=0"
// "lint:fix": "eslint . --fix --concurrency=auto --max-warnings=0"