@fido.id/eslint-config-fido

中文文档
2.2.2发布于 2025/09/15MITCommonJS近 30 天下载 5820

Fido.id shared ESLint configs, aiming to improve code quality of react applications

原始使用文档
文档目录9 节
  1. Table of Contents
  2. Installation
  3. Usage
  4. Exported Configurations
  5. Example: eslint.config.js
  6. CLI Usage
  7. Customizing Prettier
  8. Custom Rules
  9. Philosophy

eslint-config-fido

Shared ESLint configs for Typescript & React projects.

Table of Contents

Installation

yarn add --dev @fido.id/eslint-config-fido

You will also need to install eslint and prettier:

yarn add --dev eslint prettier

Usage

Exported Configurations

This package exports two main configurations:

  • recommended: Base rules for all TypeScript projects (no React/JSX-specific rules).
  • react: Extends the base config with additional rules for React/JSX projects.

Example: eslint.config.js

const fido = require("@fido.id/eslint-config-fido");
module.exports = [
  // For TypeScript projects:
  ...fido.configs.recommended,
  // For React/JSX projects, use:
  // ...fido.configs.react,
  {
    rules: {
      // your custom rules here
    },
  },
];

CLI Usage

This package provides a CLI for running tests, linting, and installing dependencies:

  • ./cli start — Install all project dependencies inside a Docker container.
  • ./cli tests — Run all tests.
  • ./cli tests --fix — Run linting and automatically fix problems.

Note: The CLI requires Docker to be installed and running on your system.

Customizing Prettier

If you would like to customize the Prettier settings, create a file named .prettierrc in your project directory. This file must declare a Prettier configuration like this:

{
  "printWidth": 100,
  "tabWidth": 2,
  "singleQuote": true,
  "jsxBracketSameLine": true,
  "trailingComma": "es5"
}

Custom Rules

This package provides the following custom ESLint rules:

Rule NameDescriptionValid ExampleInvalid ExampleExplanation
no-nested-ternary-operatorsDisallow nested ternary operators for better readability.const x = a ? b : c;const x = a ? (b ? 1 : 2) : 3;Nested ternaries are hard to read and should be avoided.
prefer-early-returnsPrefer early returns (guard clauses) over else-if and else blocks that only contain an if.function f(a){ if (!a) return; doWork(a); }function f(a,b){ if (a > 0) { doA(); } else if (b > 0) { doB(); } else { doC(); } }Avoids deep nesting and improves code clarity by using guard clauses instead of else/else-if.
prefer-object-parametersPrefer a single object parameter for functions with many parameters, to improve readability and extensibility.function foo({a, b, c, d, e}) {}function foo(a, b, c, d, e) {}When a function takes more than a set number of parameters (default: 4), use a single object parameter instead of multiple positional arguments.
mui-prefer-componentsPrefer Material UI components over native HTML elements in JSX when an equivalent exists.<Box><Typography>Text</Typography></Box><div><p>Text</p></div>Enforces use of MUI components (e.g., Box, Typography, Button) instead of native HTML tags in JSX for consistency with the design system.

Philosophy

This config is designed to mark severe problems (ex: syntax errors) as errors and stylistic issues as warnings. This lets your team apply policies like, "make sure a commit has no errors but ignore warnings if the commit didn't introduce them."

版本与发布记录

@fido.id/eslint-config-fido 共发布 11 个版本,首次发布于 2022/09/23;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.2.2latest2025/09/151.2 年前
2.2.12025/09/051.2 年前
2.2.02025/09/051.2 年前
2.1.02025/08/291.2 年前
2.0.02025/08/081.3 年前
1.3.02024/05/102 年前

关于 @fido.id/eslint-config-fido 的常见问题

@fido.id/eslint-config-fido 是什么?

Fido.id shared ESLint configs, aiming to improve code quality of react applications

如何安装 @fido.id/eslint-config-fido?

在项目目录运行 npm install @fido.id/eslint-config-fido,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:eslint(>=9.34.0 <10.0.0)、prettier(>=3.6)、typescript(>=4.2.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@fido.id/eslint-config-fido 支持 TypeScript 吗?

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

@fido.id/eslint-config-fido 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@fido.id/eslint-config-fido 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@fido.id/eslint-config-fido 可以商用吗?

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

@fido.id/eslint-config-fido 的下载量有多少?

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

@fido.id/eslint-config-fido 还在维护吗?

最新版本 2.2.2 发布于 2025/09/15(1.2 年前);至今共发布 11 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/09/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。