# @fmit/eslint-config 中文文档

规范地址：https://npmcn.com/package/%40fmit/eslint-config/

版本：4\.17\.0
npm 元数据更新时间：2026-10-26T13:19:23.917Z
中文译文更新时间：2026-11-15T03:16:02.770Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40fmit/eslint-config
原文对照：https://npmcn.com/package/%40fmit/eslint-config/?lang=original

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：11.1 kB，5 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：2 个
- peer 依赖：eslint ^9\.10\.0 \|\| ^10\.0\.0
- 首次发布：2024-01-24T14:28:21.627Z
- 最新版本发布：2026-10-26T13:19:23.728Z
- 近 30 天下载量：3738（2026-10-15 至 2026-11-13，npm 官方下载统计）
- 已发布版本数：27（近 12 个月 15 个）

## 中文简介

FMIT的ESLint配置

## 安装

```sh
npm install @fmit/eslint-config
```

也可以使用：`pnpm add @fmit/eslint-config`、`yarn add @fmit/eslint-config`、`bun add @fmit/eslint-config`

## README

# @ fmit/ eslint- config

此软件包从 [@antfu/eslint-config](https://github.com/antfu/eslint-config),有一些定制.

-   单引号, 半
-   用于格式化的自动修正( 改为单独使用) **无** 较高级)
-   排序的导入, 拼接逗号
-   合理缺省,最佳做法,只有一行配置
-   设计用于与TypeScript,JSX,Vue出道相通
-   还有Json, yaml, Toml, 减分
-   有观点,但 [非常自定义](https://github.com/antfu/eslint-config#customization)
-   [ESLint 平面配置](https://eslint.org/docs/latest/use/configure/configuration-files-new)轻而易举地写作!
-   使用 [ESLint 结构化](https://github.com/eslint-stylistic/eslint-stylistic)
-   尊重 `.gitignore` 默认
-   可选 [反应](https://npmcn.com/package/%40fmit/eslint-config/#readme-react), (中文(简体) ), [坚果](https://github.com/antfu/eslint-config#nuxt) 支助
-   可选 [格式化器](https://npmcn.com/package/%40fmit/eslint-config/#readme-formatters) 支持 CSS, HTML等.
-   **样式原则**: 阅读最小值, diff稳定, 一致

## 使用量

### 安装

```bash
pnpm i -D eslint @fmit/eslint-config
```

### 创建配置文件

与 [`"type": "module"`](https://nodejs.org/api/packages.html#type) 内 `package.json` (建议):

```js
// eslint.config.js
import fmit from '@fmit/eslint-config';

export default fmit();
```

与CJS:

```js
// eslint.config.js
const fmit = require('@fmit/eslint-config').default;

module.exports = fmit();
```

> \[TIP\] ESLint 只检测 `eslint.config.js` 作为平面配置条目,表示您需要设置 `type: module` 在你身边 `package.json` 或者你必须使用 CJS 在 `eslint.config.js`。如果您想要像 `.mjs` 或者说 `.cjs`,或甚至 `eslint.config.ts`,您可以安装 [`eslint-ts-patch`](https://github.com/antfu/eslint-ts-patch) 来修复它.

> 这个 `.eslintignore` 文件不再在平面配置中工作,参见 [定制](https://github.com/antfu/eslint-config#customization) 更多细节.

### 为 package.json 添加脚本

例如:

```json
{
  "scripts": {
    "lint": "eslint .",
    "lint:fix": "eslint . --fix"
  }
}
```

## 可选配置

我们提供了一些特定用途的可选配置, 即我们不包含它们的依赖性默认.

### 格式化器

使用外部格式化器来格式化ESLint尚不能处理的文件(.css,.html等). 电源 [`eslint-plugin-format`](https://github.com/antfu/eslint-plugin-format)。 。 。 .

```js
// eslint.config.js
import fmit from '@fmit/eslint-config';

export default fmit({
  formatters: {
    /**
     * Format CSS, LESS, SCSS files, also the `<style>` blocks in Vue
     * By default uses Prettier
     */
    css: true,
    /**
     * Format HTML files
     * By default uses Prettier
     */
    html: true,
    /**
     * Format Markdown files
     * Supports Prettier and dprint
     * By default uses Prettier
     */
    markdown: 'prettier'
  }
});
```

运行 `npx eslint` 如果您需要安装所需的依赖, 您可以手动安装 :

```bash
npm i -D eslint-plugin-format
```

### 反应

```js
// eslint.config.js
import fmit from '@fmit/eslint-config';

export default fmit({
  react: true,
});
```

运行 npx eslint 应提示您安装所需的依赖, 否则您可以手动安装 :

```bash
npm i -D eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refresh
```

## 类型意识规则

您可以通过将选项传递到打字符配置来选择启用该类型意识规则 :

```js
// eslint.config.js
import fmit from '@fmit/eslint-config';

export default fmit({
  typescript: {
    tsconfigPath: 'tsconfig.json',
  },
});
```

## VS 代码支持( 自动固定)

安装 [VS 代码 ESLint 扩展](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)

将以下设置添加到您的 `.vscode/settings.json`数字 :

```json5
{
  // Disable the default formatter, use eslint instead
  "prettier.enable": false,
  "editor.formatOnSave": false,

  // Auto fix
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit",
    "source.organizeImports": "never"
  },

  // Silent the stylistic rules in you IDE, but still auto fix them
  "eslint.rules.customizations": [
    { "rule": "style/*", "severity": "off", "fixable": true },
    { "rule": "format/*", "severity": "off", "fixable": true },
    { "rule": "*-indent", "severity": "off", "fixable": true },
    { "rule": "*-spacing", "severity": "off", "fixable": true },
    { "rule": "*-spaces", "severity": "off", "fixable": true },
    { "rule": "*-order", "severity": "off", "fixable": true },
    { "rule": "*-dangle", "severity": "off", "fixable": true },
    { "rule": "*-newline", "severity": "off", "fixable": true },
    { "rule": "*quotes", "severity": "off", "fixable": true },
    { "rule": "*semi", "severity": "off", "fixable": true }
  ],

  // Enable eslint for all supported languages
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact",
    "vue",
    "html",
    "markdown",
    "json",
    "jsonc",
    "yaml",
    "toml",
    "xml",
    "gql",
    "graphql",
    "astro",
    "svelte",
    "css",
    "less",
    "scss",
    "pcss",
    "postcss"
  ]
}
```

要查看所有可用的选项和扩展文档, 请访问原始的 repo : [@antfu/eslint-config](https://github.com/antfu/eslint-config)。 。 。 .

## 发布新版本

发布由 [语义释放](https://github.com/semantic-release/semantic-release) 当犯罪被推向 `main` 树枝.

### 所需的CI/CD变量

下列变量必须配置在 **设置 → CI/CD → 变量**数字 :

-   **`NPM_TOKEN`**: 用于向 npm 注册机构发布认证符
    
    -   创建网址:https://www.npmjs.com/ settings/\[用户名\]/tokens
    -   需要的范围: 自动化或出版
-   **`GITLAB_TOKEN`**: GitLab 操作的个人或项目访问令牌
    
    -   生成地点: 设置 – 访问托肯s
    -   所需范围 : `api`, (中文(简体) ), `write_repository`
    -   用于: 创建发布, 推动版本出错和 ChangeGELOG 更新

### 如何运作

1.  使用 [常规武器委员会](https://www.conventionalcommits.org/)
2.  合并到 `main` 分支
3.  GitLab CI 自动 :
    -   分析承诺确定版本凸起
    -   更新 `package.json` 财务报告和审定财务报表 `CHANGELOG.md`
    -   创建 Git 标签和 GitLab 发布
    -   向 npm 登记册发布

## 常见问题

### @fmit/eslint-config 是什么？

FMIT的ESLint配置

### 如何安装 @fmit/eslint-config？

在项目目录运行 npm install @fmit/eslint-config，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：eslint（^9\.10\.0 \|\| ^10\.0\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @fmit/eslint-config 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @fmit/eslint-config 支持 ESM 还是 CommonJS？

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

### @fmit/eslint-config 可以商用吗？

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

### @fmit/eslint-config 的下载量有多少？

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

### @fmit/eslint-config 还在维护吗？

最新版本 4\.17\.0 发布于 2026/10/26（20 天前）；至今共发布 27 个版本，其中过去 12 个月发布了 15 个；首次发布于 2024/01/24。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

