ESLint Plugin fp-ts

raw JSON →
0.5.0 verified Sat Apr 25 auth: no javascript

An ESLint plugin providing fp-ts-specific lint rules, including auto-fixable rules to detect deprecated imports (no-lib-imports, no-pipeable, no-module-imports) and to reduce redundant functional patterns (no-redundant-flow, prefer-traverse, prefer-chain, prefer-bimap), plus a rule to catch discarded pure expressions (no-discarded-pure-expression). Current stable version v0.5.0 requires ESLint ^9.0 and ships TypeScript definitions. The plugin has migrated to the new flat config format and now only supports ESLint v9, dropping support for v8. It relies on typescript-eslint for rules that need type checking.

error Error [ERR_REQUIRE_ESM]: require() of ES Module
cause Using require() to load the plugin when the package is ESM-only.
fix
Use import syntax: import fptsPlugin from 'eslint-plugin-fp-ts';
error Configuration for rule "fp-ts/no-discarded-pure-expression" is invalid: has no properties.
cause Missing parser options for type-checking rules.
fix
Add languageOptions.parserOptions.projectService: true to your flat config.
error ESLint couldn't find the plugin "eslint-plugin-fp-ts".
cause Plugin not installed or incorrectly referenced in config.
fix
Ensure eslint-plugin-fp-ts is installed and imported as shown in the quickstart.
breaking Plugin v0.5.0 drops support for ESLint v8; only ESLint v9 flat config is supported.
fix Upgrade ESLint to ^9.0 and migrate to flat config (eslint.config.mjs).
breaking Plugin v0.4.0 migrated to ESLint v9 and dropped CommonJS support; require() will fail.
fix Use ESM imports and flat config or downgrade to v0.3.x if using eslintrc and CJS.
breaking Plugin v0.3.0 upgraded to ESLint v8, dropping ESLint v7 support.
fix Upgrade ESLint to ^8.0 or use v0.2.x for ESLint v7.
gotcha Rules that require type-checking (e.g., no-discarded-pure-expression) will not work without configuring parserOptions.projectService or project.
fix Set parserOptions.projectService: true (or project) and tsconfigRootDir in languageOptions.
deprecated Importing from 'fp-ts/lib/' is deprecated; use 'fp-ts/<module>' instead.
fix Use rule 'fp-ts/no-lib-imports' to enforce the new import style.
npm install eslint-plugin-fp-ts
yarn add eslint-plugin-fp-ts
pnpm add eslint-plugin-fp-ts

Flat config example enabling 'no-lib-imports', 'no-redundant-flow', and 'no-discarded-pure-expression' rules with parser options for type checking.

import { defineConfig } from 'eslint/config';
import fptsPlugin from 'eslint-plugin-fp-ts';

export default defineConfig({
  plugins: {
    'fp-ts': fptsPlugin,
  },
  languageOptions: {
    parserOptions: {
      projectService: true,
      tsconfigRootDir: import.meta.dirname,
    },
  },
  rules: {
    'fp-ts/no-lib-imports': 'error',
    'fp-ts/no-redundant-flow': 'error',
    'fp-ts/no-discarded-pure-expression': 'warn',
  },
});