@doist/eslint-config

中文文档
13.1.1发布于 2026/03/03MITTypeScriptCommonJS近 30 天下载 2159

Doist global eslint config.

原始使用文档
文档目录8 节
  1. Usage
  2. Install
  3. Flat Config
  4. .eslintrc Config (Legacy)
  5. Path alias support for import sorting
  6. Configuring with type-checking
  7. Release a new package
  8. Links

@doist/eslint-config

Doist ESLint config.

Usage

Install

npm install --save-dev @doist/eslint-config

Flat Config

// eslint.config.js
import eslintConfig from '@doist/eslint-config'

export default [
    // Core set of rules, recommended for all JS projects
    ...eslintConfig.recommended,
    // OR
    // Core set of rules, recommended for all TS projects
    ...eslintConfig.recommendedTypeChecked,

    // Additional rules for sorting/grouping import statements (optional)
    ...eslintConfig.simpleImportSort,

    // Recommended for projects using React.
    ...eslintConfig.react,
]

.eslintrc Config (Legacy)

In .eslintrc:

{
    // ...
    "extends": [
        // ...

        // Core set of rules, recommended for all projects.
        "@doist/eslint-config/eslintrc/recommended",

        // Additional rules requiring type information (recommended for TypeScript projects).
        "@doist/eslint-config/eslintrc/recommended-type-checked",

        // Additional rules for sorting/grouping import statements (optional)
        "@doist/eslint-config/eslintrc/simple-import-sort"

        // Recommended for projects using React.
        "@doist/eslint-config/eslintrc/react"
    ],

    // When using `recommended-type-checked`,
    // you need to link to `tsconfig.eslint.json` file (see section below) for the project.
    "parserOptions": {
        "project": "tsconfig.eslint.json"
    }
}

Path alias support for import sorting

If your project uses path aliases (e.g. @components maps to src/components/), you can configure simple-import-sort to group them together, between third-party and relative imports, by using simpleImportSortFactory.

Flat config:

// eslint.config.js
import eslintConfig from '@doist/eslint-config'

export default [
    ...eslintConfig.recommended,
    // Replace ...eslintConfig.simpleImportSort with a custom config:
    ...eslintConfig.simpleImportSortFactory({ aliases: ['@app', '@components'] }),
]

Legacy config — override the rule in .eslintrc:

const config = {
    extends: ['@doist/eslint-config/eslintrc/simple-import-sort'],
    rules: {
        'simple-import-sort/imports':
            require('@doist/eslint-config/lib/create-simple-import-sort').createSimpleImportSortConfig(
                { aliases: ['@app', '@components'] },
            ),
    },
}

Aliases are grouped together (no blank lines between them), ordered by their position in the array.

Configuring with type-checking

For type-based rules to work, project's tsconfig.json file needs to be specified in parserOptions.project. If you want to lint files not included in build, we recommend creating a separate tsconfig.eslint.json config and specifying it instead of the default one.

Note: In flat config, recommendedTypeChecked sets project: true by default, which auto-detects tsconfig.json.

Release a new package

This project uses semantic versioning. A new version will be published to both npm and GitHub Package Registry when a new tag is pushed. Please make sure an entry is added to CHANGELOG.md.

git checkout main
npm version <major|minor|patch>
git push --follow-tags

版本与发布记录

@doist/eslint-config 共发布 26 个版本,首次发布于 2021/01/04;过去 12 个月发布了 4 个版本。

版本发布日期距今
13.1.1latest2026/03/038 个月前
13.1.02026/02/288 个月前
13.0.02026/02/049 个月前
12.0.12025/11/1411 个月前
12.0.02025/10/251.1 年前
11.2.12025/04/091.6 年前

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

@doist/eslint-config 是什么?

Doist global eslint config.

如何安装 @doist/eslint-config?

在项目目录运行 npm install @doist/eslint-config,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:eslint(^8.57.0 || ^9.0.0)、eslint-plugin-react(^7.29.4)、eslint-plugin-import(^2.29.0)、eslint-plugin-prettier(^5.0.0)、@typescript-eslint/parser(^6.0.0 || ^7.0.0 || ^8.0.0)、eslint-plugin-react-hooks(^7.0.1)、@typescript-eslint/eslint-plugin(^6.0.0 || ^7.0.0 || ^8.0.0)、eslint-plugin-simple-import-sort(^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^12.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@doist/eslint-config 支持 TypeScript 吗?

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

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

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

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

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

@doist/eslint-config 可以商用吗?

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

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

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

@doist/eslint-config 还在维护吗?

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