# @boehringer-ingelheim/eslint-config 中文文档

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

版本：10\.0\.0
npm 元数据更新时间：2026-07-10T11:17:19.289Z
中文译文更新时间：2026-11-08T10:05:29.628Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40boehringer-ingelheim/eslint-config
原文对照：https://npmcn.com/package/%40boehringer-ingelheim/eslint-config/?lang=original
项目主页：https://github.com/Boehringer-Ingelheim/eslint-config
源码仓库：https://github.com/Boehringer-Ingelheim/eslint-config

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

- 包体积（解压后）：121 kB，107 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：16 个
- peer 依赖：eslint \>= 9\.34\.0
- 首次发布：2023-02-07T09:20:26.584Z
- 最新版本发布：2026-07-10T11:17:18.973Z
- 近 30 天下载量：2781（2026-10-09 至 2026-11-07，npm 官方下载统计）
- 已发布版本数：106（近 12 个月 30 个）

## 中文简介

Boehringer Ingelheim 用于代码样式的共享eslint配置

## 安装

```sh
npm install @boehringer-ingelheim/eslint-config
```

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

## README

# ESLint 配置

> ESLint静态分析您的代码以快速发现问题. 它包含在大多数文本编辑器中 你可以运行 ESLint 作为您持续集成管道的一部分。 - [https://eslint.org/ (中文(简体) )](https://eslint.org/)

这是共享的 ESLint 配置 [博埃林格·伊格尔海姆](https://github.com/orgs/Boehringer-Ingelheim) 代码样式.

[![npm version](https://img.shields.io/npm/v/@boehringer-ingelheim/eslint-config?style=for-the-badge)](https://www.npmjs.com/package/@boehringer-ingelheim/eslint-config) [![npm downloads](https://img.shields.io/npm/dm/@boehringer-ingelheim/eslint-config?style=for-the-badge)](https://www.npmjs.com/package/@boehringer-ingelheim/eslint-config) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=for-the-badge)](https://github.com/boehringer-ingelheim/eslint-config/blob/master/LICENSE) [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg?style=for-the-badge)](https://github.com/boehringer-ingelheim/eslint-config/graphs/commit-activity) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-green.svg?logo=conventional-commits&style=for-the-badge)](https://conventionalcommits.org/) [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-494949?logo=semantic-release&style=for-the-badge)](https://github.com/semantic-release/semantic-release)

## 使用量

### 安装软件包

```sh
npm install --save-dev @boehringer-ingelheim/eslint-config
```

### 添加配置

创建或更新 `eslint.config.mjs` (单位:千美元)`eslint.config.cjs` 如果偏爱commonjs)文件,也可以在您的工程根目录中相应使用.

```js
import boehringer from '@boehringer-ingelheim/eslint-config';
import { defineConfig } from 'eslint/config';

export default defineConfig(
  boehringer.configs.strict
)
```

#### 扩展或覆盖配置

不建议这样做,因为目标是在所有项目中都有类似的代码样式,但是如果出于某种原因需要添加或改变配置,则可以采取以下方式: 设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计设计,设计,设计,设计,设计,设计,设计,设计,设计,设计,设计

```js
import boehringer from '@boehringer-ingelheim/eslint-config';
import { defineConfig } from 'eslint/config';

export default defineConfig(
  boehringer.configs.strict, 
  {
    rules: {
      'no-empty-function': 'off',
    },
  }
);
```

#### `boehringer.includeIgnoreFile()`

这个 `includeIgnoreFile` 函数允许您包含 `.gitignore` 使用相对路径的 ESLint 配置中的文件. 这是由ESLint(英语:S[忽略文件](https://eslint.org/docs/latest/use/configure/ignore#including-gitignore-files)) (中文(简体) ). 建议使用此功能,以确保您 `.gitignore` 文件已适当包含在您的 ESLint 设置中.

```js
import boehringer from '@boehringer-ingelheim/eslint-config';
import { defineConfig } from 'eslint/config';

export default defineConfig(
  boehringer.includeIgnoreFile(), // default value '.gitignore'
  boehringer.configs.strict,
);
```

或者,如果你有不同的路径 `.gitignore` 文件 :

```js
import boehringer from '@boehringer-ingelheim/eslint-config';
import { defineConfig } from 'eslint/config';

export default defineConfig(
  boehringer.includeIgnoreFile('./backend/.gitignore'),
  boehringer.includeIgnoreFile('./frontend/.gitignore'),
  boehringer.configs.strict,
);
```

更多信息 : [ESLint - 配置文件](https://eslint.org/docs/latest/use/configure/configuration-files#extending-configuration-files)

### 运行

```sh
npx eslint .
```

## 共享配置

与标准/推荐的ESLint配置不同的意见选项.

### 基础

```js
import boehringer from '@boehringer-ingelheim/eslint-config';
import { defineConfig } from 'eslint/config';

export default defineConfig(
  boehringer.configs.base
)
```

这种共享的ESLint配置是为遵循现代JavaScript标准的TypeScript项目而设置的. 它使用TypeScript(ES2022)的最新版本,并扩展了几个插件和建议的规则来强制实施最佳做法并捕捉潜在的出错.

在此配置中使用以下插件:

-   [`@typescript-eslint/eslint-plugin`](https://typescript-eslint.io/rules/)
-   [`eslint-plugin-import-x`](https://github.com/un-es/eslint-plugin-import-x)
-   [`eslint-plugin-sonarjs`](https://github.com/SonarSource/SonarJS/blob/master/packages/jsts/src/rules/README.md)

此外 [`eslint-plugin-perfectionist`](https://github.com/azat-io/eslint-plugin-perfectionist) 用于自动解决排序问题.

此配置还设置了 TypeScript 解析器 [`@typescript-eslint/parser`](https://typescript-eslint.io/packages/parser/) 财务报告和审定财务报表 [`eslint-import-resolver-typescript`](https://github.com/import-js/eslint-import-resolver-typescript)。 。 。 .

### 当地

```js
import boehringer from '@boehringer-ingelheim/eslint-config';
import { defineConfig } from 'eslint/config';

export default defineConfig(
  boehringer.configs.base,
  boehringer.configs.local
);
```

这个共享的 ESLint 配置可以配置或禁用一些规则, 以便本地更好的性能 。 在帮助下 [`is-ci`](https://www.npmjs.com/package/is-ci) 这些配置仅适用于CI管道外的环境.

### 严格

```js
import boehringer from '@boehringer-ingelheim/eslint-config';
import { defineConfig } from 'eslint/config';

export default defineConfig(
  boehringer.configs.strict
);
```

此共享的 ESLint 配置扩展 [基础配置](https://npmcn.com/package/%40boehringer-ingelheim/eslint-config/#readme-base) ,并从打字-slint插件中添加额外的严格林入规则。 这些严格的规则旨在实施高标准的代码质量,并改进代码的可维护性.

### 反应

```js
import boehringer from '@boehringer-ingelheim/eslint-config';
import { defineConfig } from 'eslint/config';

export default defineConfig(
  boehringer.configs.strict,
  boehringer.configs.react
);
```

这个共享的 ESLint 配置是专门为 [反应](https://reactjs.org/) 工程,并扩展 [基础配置](https://npmcn.com/package/%40boehringer-ingelheim/eslint-config/#readme-base)它使用浏览器环境,包括下列插件的建议配置:

-   [`eslint-plugin-jsx-a11y`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y)
-   [`eslint-plugin-react`](https://github.com/jsx-eslint/eslint-plugin-react)
-   [`eslint-plugin-react-hooks`](https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks)
-   [`eslint-plugin-react-refresh`](https://github.com/ArnaudBarre/eslint-plugin-react-refresh) (有规则严重性) `warn`(中文(简体) )

配置设置了若干自定义规则,包括 [`@typescript-eslint/no-restricted-types`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-restricted-types.mdx) 财务报告和审定财务报表 [`@typescript-eslint/consistent-type-definitions`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/consistent-type-definitions.mdx),以及组织和格式化进口报表的规则. 此外,限制使用enum [`no-restricted-syntax`](https://github.com/eslint/eslint/blob/main/docs/src/rules/no-restricted-syntax.md)。 。 。 .

### 下一个.js

```js
import boehringer from '@boehringer-ingelheim/eslint-config';
import { defineConfig } from 'eslint/config';

export default defineConfig(
  boehringer.configs.strict,
  boehringer.configs.nextjs
);
```

这个共享的 ESLint 配置是专门为 [下一个.js](https://nextjs.org/) 项目。 它延伸 [反应配置](https://npmcn.com/package/%40boehringer-ingelheim/eslint-config/#readme-react) 并包括 [`@next/eslint-plugin-next`](https://nextjs.org/docs/app/api-reference/config/eslint) 带有推荐和 [`core-web-vital`](https://nextjs.org/docs/app/api-reference/config/eslint#with-core-web-vitals) 规则设定。 配置也会调整规则 `react-refresh/only-export-components` 与 Next.js 兼容.

### 剧作家

```js
import boehringer from '@boehringer-ingelheim/eslint-config';
import { defineConfig } from 'eslint/config';

export default defineConfig(
  boehringer.configs.strict,
  boehringer.configs.playwright
);
```

仅用于特定文件:

```js
import boehringer from '@boehringer-ingelheim/eslint-config';
import { defineConfig } from 'eslint/config';

export default defineConfig(
  boehringer.configs.strict,
  {
    files: ['src/**/*.test.{ts,tsx}'],
    ...boehringer.configs.playwright[0],
  },
);
```

这个共享的ESLint配置旨在与Playwright一起编写测试时执行最佳做法和建议. 它延伸 [`eslint-plugin-playwright`](https://github.com/playwright-community/eslint-plugin-playwright) 配置并添加以下规则:

-   [`playwright/prefer-to-be`](https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-to-be.md): 强制使用 `.toBe()` 改为 `.toEqual()` 当测试平等.
-   [`playwright/prefer-to-have-length`](https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-to-have-length.md): 强制使用 `.toHaveLength()` 改为 `.toEqual(n)` 当测试对象的长度时.
-   [`playwright/require-top-level-describe`](https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/require-top-level-describe.md): 要求将测试组织到顶层 `describe()` 块.

### (实验)命名公约

```js
import boehringer from '@boehringer-ingelheim/eslint-config';
import { defineConfig } from 'eslint/config';

export default defineConfig(
  boehringer.configs.strict,
  // possibly other configs,
  boehringer.configs.experimentalNamingConvention
);
```

这种共享的ESLint配置旨在强制实施一些命名惯例. 它使用 [`@typescript-eslint/naming-convention`](https://typescript-eslint.io/rules/naming-convention/) 执行命名公约的规则。 强制执行的公约可见于 [配置/命名-公约js](https://npmcn.com/package/%40boehringer-ingelheim/eslint-config/configs/naming-convention.js#L7-L65)

### 较初步残疾

```js
import boehringer from '@boehringer-ingelheim/eslint-config';
import prettier from 'eslint-plugin-prettier/recommended';
import { defineConfig } from 'eslint/config';

export default defineConfig(
  boehringer.configs.strict,
  // Following needs eslint-plugin-prettier to be installed as described by https://github.com/prettier/eslint-plugin-prettier
  // Should be second to last
  prettier,
  // Should be last
  boehringer.configs.prettierDisable,
);
```

这个共享的 ESLint 配置是围绕 [`eslint-config-disable`](https://github.com/prettier/eslint-config-prettier),用于关闭所有不必要的或可能与Pretier相冲突的规则。 这种包装可重复使用一些规则,在我们使用与Prettier兼容的规则的具体选项时,可以使用我们共享的配置(参见: [特别规则](https://github.com/prettier/eslint-config-prettier#special-rules)) (中文(简体) ). 重新启用以下规则:

-   [`curly`](https://github.com/eslint/eslint/blob/main/docs/src/rules/curly.md) 使用(默认)选项“全部”: 对所有控制语句执行一致的括号样式
-   [`no-confusing-arrow`](https://github.com/eslint/eslint/blob/main/docs/src/rules/no-confusing-arrow.md) 与允许的Parens `false` 只有一个小帕拉姆 `true`: 断开箭头函数,它们可以与比较相混淆.

## 已知问题

### 分析错误

ESLint可能对一些文件(甚至对于它自己的eslint.config.js)抛出以下错误之一:

-   `ESLint was configured to run ... However, that TSConfig does not / none of those TSConfigs include this file`。 。 。 .
-   `... was not found by the project service. Consider either including it in the tsconfig.json or including it in allowDefaultProject`

造成这一错误的原因是将各自文件纳入ESLint的范围,而不是TypeScript的范围. 欲了解更多有关此错误的信息及更多如何解决该错误的建议,您可以查看 [排字失败](https://typescript-eslint.io/troubleshooting/typed-linting/#i-get-errors-telling-me--was-not-found-by-the-project-service-consider-either-including-it-in-the-tsconfigjson-or-including-it-in-allowdefaultproject)。 。 。 .

我们的建议是保持对这些文件的排入意识.

#### 解决方案1

包含 . (c|m)?js 文件在您的主 tsconfig.json 中 :

```jsonc
{
  "include": [
    // your existing includes
    "*.*js", // this will include all .js, .cjs, .mjs files and similar in your project root
    "*.ts", // this will include all .ts files and similar in your project root
    // Add all other files/folders in which this error occurs
  ]
}
```

#### 解决方案2

你可以用新车 [`allowDefaultProject`](https://typescript-eslint.io/packages/parser#allowdefaultproject) 选项,这与我们的 [`projectService` 配置](https://npmcn.com/package/%40boehringer-ingelheim/eslint-config/configs/base.js#L25)数字 :

```js
import boehringer from '@boehringer-ingelheim/eslint-config';
import { defineConfig } from 'eslint/config';

export default defineConfig(
  // other configs,
  {
    languageOptions: {
      parserOptions: {
        projectService: {
          allowDefaultProject: [
            '*.*js', 
            '.*.*js',
          ],
          // defaultProject can be used to specify separate tsconfig options for "out-of-project" files included by allowDefaultProject
          // defaultProject: 'tsconfig.eslint.json',
        },
      },
    },
  },
)
```

## 地方发展

### 安装依赖关系

```sh
npm install
```

### 测试

```sh
npm test
```

### 维修

当遇到模糊错误或问题时,此命令可能有用 。 它清除并重建了您的项目的依赖性.

```sh
npm run repair
```

### 释放

> \[大  
> 不支持确保一致性和安全性的人工发布,见: [https://docs.npmjs.com/ 受托出版商](https://docs.npmjs.com/trusted-publishers)

通过 GitHub 动作自动发布 [语义释放](https://github.com/semantic-release)。 。 。 . 它会按照常规承诺来撞倒版本,将软件包发布到npm并发布到GitHub.

```sh
npm run release
```

## 路线图

-   [ ] 共享配置:角
-   [ ] 共享配置:节点.js
-   [ ] 测试案例
-   [x] " (中文(简体) )[平调](https://eslint.org/docs/latest/use/configure/configuration-files-new)" 配置

## 显示您的支持

如果这个计划能帮助你的话,就给你一个!

## 许可证

版权 2026 [博埃林格·伊格尔海姆](https://github.com/boehringer-ingelheim)。 。 。 .  
这个项目是 [麻省理工学院](https://github.com/boehringer-ingelheim/eslint-config/blob/master/LICENSE) 有执照.

## 资源

-   [https://eslint.org/ (中文(简体) )](https://eslint.org/)
-   [https://typescript-eslint.io/ (英语)](https://typescript-eslint.io/)
-   [https://react-typescript-cheatsheet.netlify.app/ 页面存档备份,存于互联网档案馆](https://react-typescript-cheatsheet.netlify.app/)
-   [https://prettier.io/ 互联网档案馆的存檔,存档日期2013-12-02](https://prettier.io/)
-   [https://conventionalcommitts.org/en/v1.0.0 (英语)](https://conventionalcommits.org/en/v1.0.0/)
-   [https://semantic-release.gitbook.io/ 页面存档备份,存于互联网档案馆](https://semantic-release.gitbook.io/)
-   [https://semver.org/ (中文(简体) )](https://semver.org/)

## 常见问题

### @boehringer-ingelheim/eslint-config 是什么？

Boehringer Ingelheim 用于代码样式的共享eslint配置

### 如何安装 @boehringer-ingelheim/eslint-config？

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

### @boehringer-ingelheim/eslint-config 支持 TypeScript 吗？

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

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

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

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

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

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

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

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

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

