# @grafana/eslint-config 中文文档

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

版本：10\.0\.0
npm 元数据更新时间：2026-07-21T17:40:29.326Z
中文译文更新时间：2026-11-16T21:45:08.232Z
软件包许可：Apache-2\.0

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

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

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

- 包体积（解压后）：9 kB，5 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：eslint \>=8\.57\.0，typescript \>=5\.5\.0，eslint-plugin-jsdoc \>=50\.4\.0，eslint-plugin-react \>=7\.37\.0，eslint-config-prettier \>=9\.1\.0，@stylistic/eslint-plugin \>=5\.0\.0，@typescript-eslint/parser \>=8\.9\.0，eslint-plugin-react-hooks \>=7\.1\.0，@typescript-eslint/eslint-plugin \>=8\.9\.0
- 首次发布：2020-01-31T17:00:00.581Z
- 最新版本发布：2026-06-11T09:19:20.833Z
- 近 30 天下载量：292008（2026-10-17 至 2026-11-15，npm 官方下载统计）
- 已发布版本数：30（近 12 个月 1 个）

## 中文简介

格拉法纳的ESLint配置

## 安装

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

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

## README

# grafana-slint - 配置

> 格拉法纳的 [ESLint 语录](https://eslint.org/) 相会.

## 安装

```shell
yarn add @grafana/eslint-config --dev
```

或:

```shell
npm install @grafana/eslint-config --save-dev
```

别忘了安装对等依赖.

1.  安装命令列出的每个软件包的正确版本:

```sh
npm info "@grafana/eslint-config@latest" peerDependencies
```

如果使用 **npm 5+ (韩语)**,使用此命令:

```sh
npx install-peerdeps --dev @grafana/eslint-config
```

如果使用不同的软件包管理器, 请运行 `npm info "@grafana/eslint-config@latest" peerDependencies` 以列出对等关系和版本。 然后运行 `yarn add --dev <dependency1>@<version> <dependency2>@<version> <dependency3>@<version>` 用于列出的对等关系.

## 配置( 新: eslint. config.js)

从v8.21.0起,埃斯林特引入了一个新的平面配置系统,其中 `eslint.config.js` 替换 `.eslintrc*` 作为默认配置文件名. [埃斯林特@8.x (英语)](mailto:Eslint@8.x) 支持两个系统,同时 [埃斯林特@9.x](mailto:Eslint@9.x) 只支持新的平面配置 .

可以找到如何向平面配置迁移的指南 [这里](https://eslint.org/docs/latest/extend/plugin-migration-flat-config)。 。 。 .

以下官方博客文章可供相关人士使用:

-   [https://eslint.org/blog/2022/08/new-config-system-part-1. 请检查isbn=值 (帮助)](https://eslint.org/blog/2022/08/new-config-system-part-1/)
-   [https://eslint.org/blog/2022/08/new-config-system-part-2. 页面存档备份,存于互联网档案馆](https://eslint.org/blog/2022/08/new-config-system-part-2/)
-   [https://eslint.org/blog/2022/08/new-config-system-part-3. 页面存档备份,存于互联网档案馆](https://eslint.org/blog/2022/08/new-config-system-part-3/)

此包包含一个单一的平面配置对象,可以这样导入:

```js
const grafanaConfig = require("@grafana/eslint-config/flat");

/**
 * @type {Array<import('eslint').Linter.Config>}
 */
module.exports = [
  ...grafanaConfig,
  … /* rest of your config */
];
```

您可自由添加/ 覆盖属性 .

注意: 我们的共享配置不预设 `files`, (中文(简体) ), `ignore`,或 `languageOptions.globals`。大多数情况下,您可能想要为您的工程配置一些属性.

```js
const grafanaConfig = require("@grafana/eslint-config/flat");

/**
 * @type {Array<import('eslint').Linter.Config>}
 */
module.exports = [
  {
    ignores: [".github", ".yarn", "**/build/", "**/compiled/", "**/dist/"],
  },
  ...grafanaConfig,
  {
    name: "myproject/defaults",
    files: ["**/*.{ts,tsx,js,jsx}"],
    rules: {
      // add custom rules here.
    },
  },
];
```

## 配置( legacy:.eslintrc \*)

扩展配置以获取合理的默认值 :

```json
{
  "extends": ["@grafana/eslint-config"]
}
```

它会自动处理 `*.(js|ts|tsx)` 文档.

## 常见问题

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

格拉法纳的ESLint配置

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

在项目目录运行 npm install @grafana/eslint-config，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：eslint（\>=8\.57\.0）、typescript（\>=5\.5\.0）、eslint-plugin-jsdoc（\>=50\.4\.0）、eslint-plugin-react（\>=7\.37\.0）、eslint-config-prettier（\>=9\.1\.0）、@stylistic/eslint-plugin（\>=5\.0\.0）、@typescript-eslint/parser（\>=8\.9\.0）、eslint-plugin-react-hooks（\>=7\.1\.0）、@typescript-eslint/eslint-plugin（\>=8\.9\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

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

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

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

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

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

@grafana/eslint-config 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

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

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

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

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

