@fuf-stack/eslint-config-fuf

中文文档
2.1.2发布于 2026/11/13MITES Module构建来源已验证近 30 天下载 4787

fuf base eslint config for typescript

原始使用文档
文档目录11 节
  1. Install
  2. Usage
  3. Base (Node/JS/TS) — Flat config (ESLint 9)
  4. React (JS/TS + React + Storybook overrides) — Flat config (…
  5. Vitest (test files only)
  6. What’s inside
  7. TypeScript interface members
  8. Opt-in JSDoc Strict
  9. Prettier configuration helper
  10. Scripts
  11. License

@fuf-stack/eslint-config-fuf

Opinionated Fröhlich ∧ Frei ESLint + Prettier configuration for JavaScript/TypeScript projects, with optional React, Storybook, Vitest and Tailwind CSS integrations.

  • Base: Airbnb Extended (recommended, flat) + ESLint recommended + Prettier + Fröhlich ∧ Frei defaults
  • TypeScript: @typescript-eslint with sensible rules and type-aware parsing via root tsconfig.json
  • React: Airbnb React + Hooks, JSX runtime, Storybook overrides
  • JSDoc Strict: Opt-in descriptions for TypeScript interface members
  • Vitest: plugin:vitest/recommended for test files
  • Prettier: Import sorting, optional Tailwind class sorting, and optional Astro/PHP support

Install

Choose a package manager.

# pnpm
pnpm add -D @fuf-stack/eslint-config-fuf

# npm
npm i -D @fuf-stack/eslint-config-fuf

# yarn
yarn add -D @fuf-stack/eslint-config-fuf

This package bundles the required peer tooling (eslint, prettier, plugins) so you do not need to install them separately.

Migrating to v1.0.0 (ESLint 9 flat config)? See MIGRATION.md in this package.

Usage

Create an ESLint config that extends one of the provided entry points.

Base (Node/JS/TS) — Flat config (ESLint 9)

// eslint.config.mjs
import path from 'node:path';

import { includeIgnoreFile } from '@eslint/compat';

import base from '@fuf-stack/eslint-config-fuf/base';

const gitignorePath = path.resolve('.', '.gitignore');

export default [includeIgnoreFile(gitignorePath), ...base];

React (JS/TS + React + Storybook overrides) — Flat config (ESLint 9)

// eslint.config.mjs
import path from 'node:path';

import { includeIgnoreFile } from '@eslint/compat';

import react from '@fuf-stack/eslint-config-fuf/react';

const gitignorePath = path.resolve('.', '.gitignore');

export default [includeIgnoreFile(gitignorePath), ...react];

Vitest (test files only)

If you want Vitest rules for test files, add the vitest config after your base/react config:

// eslint.config.mjs
import path from 'node:path';

import { includeIgnoreFile } from '@eslint/compat';

import react from '@fuf-stack/eslint-config-fuf/react';
import vitest from '@fuf-stack/eslint-config-fuf/vitest';

const gitignorePath = path.resolve('.', '.gitignore');

export default [includeIgnoreFile(gitignorePath), ...react, ...vitest];

Notes:

  • Type-aware linting uses your root tsconfig.json. Add any extra files (e.g. Vitest configs) to include there and do not use a separate tsconfig.eslint.json.

Example root tsconfig.json additions:

{
  "extends": "@fuf-stack/typescript-config/base.json",
  "include": ["src", "test", "vitest.config.mts", "vitest.workspace.ts"]
}

What’s inside

  • base composes: Airbnb base via eslint-config-airbnb-extended + Fröhlich ∧ Frei base/ts rules (docs)
  • react composes: Airbnb react + hooks via eslint-config-airbnb-extended + jsx-runtime + Fröhlich ∧ Frei base/react/ts rules; Storybook overrides for *.stories.ts(x)
  • vitest extends: plugin:vitest/recommended for *.spec.* / *.test.* files of every JS/TS extension (js, mjs, cjs, jsx, ts, mts, cts, tsx) and relaxes import/no-extraneous-dependencies in tests and in vitest.config.* / vitest.workspace.*
  • Fröhlich ∧ Frei rules include:
    • Allow leading underscore for intentionally unused vars
    • Enforce arrow-function components; default props via function default args
    • Consistent type-only imports; import extensions off for ts/tsx/js/jsx (import-x)
    • Interface members sort alphabetically within blank-line groups
    • Prettier formatting as the single source of truth

TypeScript interface members

Both base and react use perfectionist/sort-interfaces to sort members alphabetically, ignoring case. Optional and required members sort together. Blank lines separate groups: members sort within each group and never move across those boundaries. Comments stay attached to their members; comments alone do not create a new group. eslint --fix applies ordering changes and preserves group spacing. Documentation is optional.

interface RequestOptions {
  retry?: boolean;
  timeout: number;

  onError?: (error: Error) => void;
  onSuccess?: () => void;
}

Existing overload adjacency checks remain enabled for interfaces, functions and classes. Projects can customize sorting by overriding perfectionist/sort-interfaces after the shared config.

Opt-in JSDoc Strict

Add jsdoc-strict after base or react to require descriptions on every TypeScript interface property, method and index signature in .ts and .tsx files:

// eslint.config.mjs
import base from '@fuf-stack/eslint-config-fuf/base';
import jsdocStrict from '@fuf-stack/eslint-config-fuf/jsdoc-strict';

export default [...base, ...jsdocStrict];

This additive preset uses the TypeScript parser provided by base or react. jsdoc/require-jsdoc requires a /** ... */ comment, and jsdoc/require-description requires description text. Ordinary // comments, empty docblocks and tags without descriptions (for example, /** @deprecated */) do not satisfy these rules. Autofix does not insert empty documentation placeholders.

interface RequestOptions {
  /** Whether failed requests should be retried automatically. */
  retry?: boolean;
  /** Maximum time in milliseconds before cancellation. */
  timeout: number;
}

This preset covers interface members only; it does not require documentation on functions, object type aliases, call signatures or construct signatures. It adds no sorting or spacing rules of its own.

Prettier configuration helper

This package also exports a small helper to generate a Prettier config with import sorting and optional plugins (Astro, PHP, Tailwind).

Create prettier.config.mjs and call the factory (ESM):

// prettier.config.mjs
import createConfig from '@fuf-stack/eslint-config-fuf/prettier';

export default createConfig({
  // Enable Astro support
  enableAstro: false,
  // Enable PHP support
  enablePhp: false,
  // Absolute path to your Tailwind config to enable Tailwind class sorting
  // e.g. './tailwind.config.ts' or './tailwind.config.js'
  tailwindConfig: undefined,
  // Additional function names that contain Tailwind classes (besides classNames, cn, tv)
  tailwindAdditionalFunctions: [],
  // If using a monorepo, group internal packages (e.g. "@acme/") as a separate block in import order
  workspacePackagePrefix: undefined,
});

Highlights:

  • Import sorting powered by @ianvs/prettier-plugin-sort-imports with opinionated groups (types, vitest, builtins, react, third-party, monorepo packages, src/**, relative, assets)
  • Optional Tailwind class sorting via prettier-plugin-tailwindcss (plugin must be last)
  • Optional prettier-plugin-astro and @prettier/plugin-php
  • Markdown note: with Prettier 3.9+, valid Setext headings (Title + ===) are preserved instead of auto-converted to ATX (# Title)

Scripts

Typical scripts:

{
  "lint": "eslint .",
  "lint:fix": "eslint . --fix",
  "format": "prettier . --write"
}

License

MIT

版本与发布记录

@fuf-stack/eslint-config-fuf 共发布 74 个版本,首次发布于 2024/04/05;过去 12 个月发布了 20 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.1.2latest2026/11/132 天前
2.1.12026/11/133 天前
2.1.02026/10/2224 天前
2.0.82026/10/121 个月前
2.0.72026/09/211 个月前
2.0.62026/08/103 个月前

关于 @fuf-stack/eslint-config-fuf 的常见问题

@fuf-stack/eslint-config-fuf 是什么?

fuf base eslint config for typescript

如何安装 @fuf-stack/eslint-config-fuf?

在项目目录运行 npm install @fuf-stack/eslint-config-fuf,或使用 pnpm add / yarn add / bun add。

@fuf-stack/eslint-config-fuf 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/fuf-stack__eslint-config-fuf 是否存在。

@fuf-stack/eslint-config-fuf 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@fuf-stack/eslint-config-fuf 可以商用吗?

@fuf-stack/eslint-config-fuf 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fuf-stack/eslint-config-fuf 的下载量有多少?

根据 npm 官方下载统计,@fuf-stack/eslint-config-fuf 在 2026/10/16 – 2026/11/14 这 30 天内被下载 4,787 次,日均约 160 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fuf-stack/eslint-config-fuf 还在维护吗?

最新版本 2.1.2 发布于 2026/11/13(2 天前);至今共发布 74 个版本,其中过去 12 个月发布了 20 个;首次发布于 2024/04/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。