# @exodus/eslint-plugin-import 中文文档

规范地址：https://npmcn.com/package/%40exodus/eslint-plugin-import/

版本：2\.31\.0
npm 元数据更新时间：2025-10-13T19:13:48.465Z
中文译文更新时间：2026-11-14T04:32:32.841Z
软件包许可：MIT

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

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

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

- 包体积（解压后）：1.4 MB，130 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- Node.js 要求：\>=4
- 运行依赖：19 个
- peer 依赖：eslint ^2 \|\| ^3 \|\| ^4 \|\| ^5 \|\| ^6 \|\| ^7\.2\.0 \|\| ^8 \|\| ^9
- 首次发布：2024-03-27T11:31:57.073Z
- 最新版本发布：2024-11-21T09:53:21.795Z
- 近 30 天下载量：2949（2026-10-14 至 2026-11-12，npm 官方下载统计）
- 已发布版本数：3（近 12 个月 0 个）

## 中文简介

以智入入.

## 安装

```sh
npm install @exodus/eslint-plugin-import
```

也可以使用：`pnpm add @exodus/eslint-plugin-import`、`yarn add @exodus/eslint-plugin-import`、`bun add @exodus/eslint-plugin-import`

## README

# 埃斯林特-插头-进口

[![github actions](https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/import-js/eslint-plugin-import)](https://github.com/import-js/eslint-plugin-import) [![travis-ci](https://travis-ci.org/import-js/eslint-plugin-import.svg?branch=main)](https://travis-ci.org/import-js/eslint-plugin-import) [![coverage](https://codecov.io/gh/import-js/eslint-plugin-import/branch/main/graphs/badge.svg)](https://app.codecov.io/gh/import-js/eslint-plugin-import/) [![win32 build status](https://ci.appveyor.com/api/projects/status/3mw2fifalmjlqf56/branch/main?svg=true)](https://ci.appveyor.com/project/import-js/eslint-plugin-import/branch/main) [![npm](https://img.shields.io/npm/v/eslint-plugin-import.svg)](https://www.npmjs.com/package/eslint-plugin-import) [![npm downloads](https://img.shields.io/npm/dt/eslint-plugin-import.svg?maxAge=2592000)](https://www.npmtrends.com/eslint-plugin-import)

此插件旨在支持 ES2015+(ES6+) 导入/导出语法的林入,并预防文件路径和导入名称的误写出问题. ES2015+静态模块语法打算提供的所有善良,标记在你的编辑器上.

**如果你用这个与苏布里米**: 见 [下一节](https://npmcn.com/package/%40exodus/eslint-plugin-import/#readme-sublimelinter-eslint) 对于重要的信息.

## 规则

QQ 配置启用 .  
QQ 配置设置为警告 .  
QQ 配置已禁用 .  
设置在 `errors` 配置 .  
设置在 `recommended` 配置 .  
设置在 `typescript` 配置 .  
设置在 `warnings` 配置 .  
自动修复 [`--fix` CLI 选项](https://eslint.org/docs/user-guide/command-line-interface#--fix)。 。 。 .  
手动修复 [编辑器建议](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions)。 。 。 .  
❌被贬.

### 帮助警告

| 名称                       | 说明 | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | ❌ |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| [导出](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/export.md) | 禁止任何无效的出口,即同名再出口. | ❗ |  |  |  |  |  |
| [无折旧](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-deprecated.md) | 使用标记的被禁入名称 `@deprecated` 文档标记. |  |  |  |  |  |  |
| [无空名块](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-empty-named-blocks.md) | 禁用已命名的空导入块 . |  |  |  | 🔧 | 💡 |  |
| [无亲属关系](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-extraneous-dependencies.md) | 禁止使用外相包. |  |  |  |  |  |  |
| [不可移动出口](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-mutable-exports.md) | 禁止使用可变出口 `var` 或者说 `let`。 。 。 . |  |  |  |  |  |  |
| [无默认名称](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-named-as-default.md) | 禁止使用导出名称作为默认导出标识符 . |  | ☑️ |  |  |  |  |
| [无默认成员](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-named-as-default-member.md) | 禁止使用导出名称作为默认导出属性 . |  | ☑️ |  |  |  |  |
| [无未使用模块](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-unused-modules.md) | 不输出的禁用模块,或不匹配另一个模块中的导入的输出. |  |  |  |  |  |  |

### 模块系统

| 名称                     | 说明 | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | ❌ |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| [无](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-amd.md) | 无效 AMD `require` 财务报告和审定财务报表 `define` 打电话. |  |  |  |  |  |  |
| [无常识](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-commonjs.md) | 禁止常见JS `require` 电话和 `module.exports` 或者说 `exports.*`。 。 。 . |  |  |  |  |  |  |
| [无进口模块出口](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-import-module-exports.md) | 带有 commonJS 模块.exports 的禁止导入语句. |  |  |  | 🔧 |  |  |
| [无节点模块](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-nodejs-modules.md) | Forbid Node.js 内建模块. |  |  |  |  |  |  |
| [毫不含糊](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/unambiguous.md) | 无效可能含糊不清的目标`script` 文选. `module`) (中文(简体) ). |  |  |  |  |  |  |

### 静态分析

| 名称                       | 说明 | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | ❌ |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| [默认](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/default.md) | 确保默认导出存在, 因为默认导入 . | ❗ |  |  |  |  |  |
| [名称](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/named.md) | 确保命名的导入符合远程文件中的命名导出 . | ❗ |  | ⌨️ |  |  |  |
| [命名空间](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/namespace.md) | 确保导入的命名空间含有被引用的属性 . | ❗ |  |  |  |  |  |
| [无绝对的路径](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-absolute-path.md) | 使用绝对路径强制导入模块 . |  |  |  | 🔧 |  |  |
| [无循环](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-cycle.md) | 从导入带有依赖路径的模块返回到自身, 禁止模块 . |  |  |  |  |  |  |
| [无动力要求](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-dynamic-require.md) | 无效 `require()` 以表达方式打电话. |  |  |  |  |  |  |
| [无内部模块](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-internal-modules.md) | 强制导入其他模块的子模块 . |  |  |  |  |  |  |
| [无关系包](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-relative-packages.md) | 禁止通过相对路径导入软件包 . |  |  |  | 🔧 |  |  |
| [无亲属父母进口](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-relative-parent-imports.md) | 从父目录中导入禁用模块 . |  |  |  |  |  |  |
| [无限制路径](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-restricted-paths.md) | 强制在指定的文件夹中导入哪些文件 . |  |  |  |  |  |  |
| [无自输入](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-self-import.md) | 从导入中禁用模块 . |  |  |  |  |  |  |
| [无未解决](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-unresolved.md) | 确保导入指向能够解决的文件/模块 . | ❗ |  |  |  |  |  |
| [无用- 路径- 部分](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-useless-path-segments.md) | 导入中禁止不必要的路径段并需要语句 . |  |  |  | 🔧 |  |  |
| [无网包装填器语法](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-webpack-loader-syntax.md) | 进口时的frobid网络包装加载器语法. |  |  |  |  |  |  |

### 样式指南

| 名称                            | 说明 | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | ❌ |
| :-- | :-- | :-- | :-- | :-- | :-- | :-- | :-- |
| [一致类型-规格-样式](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/consistent-type-specifier-style.md) | 强制或禁止使用指定进口的内含型号标识. |  |  |  | 🔧 |  |  |
| [动态导入通称](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/dynamic-import-chunkname.md) | 用 WebpackChunkName 执行一个主要注释用于动态导入 . |  |  |  |  | 💡 |  |
| [最后出口额](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/exports-last.md) | 确保所有出口都出现在其他声明之后. |  |  |  |  |  |  |
| [扩展](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/extensions.md) | 确保在导入路径内一致使用文件扩展名 . |  |  |  |  |  |  |
| [第一个](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/first.md) | 确保所有进口物品都出现在其他报表之前. |  |  |  | 🔧 |  |  |
| [集团出口](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/group-exports.md) | 更倾向于在单一出口申报中将指定出口归类 |  |  |  |  |  |  |
| [进口-第一次](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/imports-first.md) | 改为: `import/first`。 。 。 . |  |  |  | 🔧 |  | ❌ |
| [最大依赖性](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/max-dependencies.md) | 执行模块的最大依赖数量. |  |  |  |  |  |  |
| [新线后导入](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/newline-after-import.md) | 导入语句后执行新行 . |  |  |  | 🔧 |  |  |
| [无匿名- 默认- 导出](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-anonymous-default-export.md) | 禁止匿名值作为默认导出 . |  |  |  |  |  |  |
| [无默认导出](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-default-export.md) | 强制默认出口 . |  |  |  |  |  |  |
| [无重复](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-duplicates.md) | 在多处禁止重复导入同一模块. |  | ☑️ |  | 🔧 |  |  |
| [无名- 默认](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-named-default.md) | 禁止指定默认输出 . |  |  |  |  |  |  |
| [无名出口](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-named-export.md) | 禁止命名出口. |  |  |  |  |  |  |
| [无名称空间](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-namespace.md) | 无效命名空间( a. k. a. "wildcard") `*`进口. |  |  |  | 🔧 |  |  |
| [无未签名进口](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-unassigned-import.md) | 禁止未指定进口 |  |  |  |  |  |  |
| [顺序](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/order.md) | 以模块导入顺序执行公约. |  |  |  | 🔧 |  |  |
| [偏好默认-导出](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/prefer-default-export.md) | 如果模块导出一个单一名称或多个名称,则倾向于默认导出 . |  |  |  |  |  |  |

## `eslint-plugin-import` 企业

作为Tidelift订阅的一部分提供.

维护者 `eslint-plugin-import` 和上千个其他的软件包 正在和Tidelift合作 提供商业支持和维护 你用来构建应用程序的开源依赖。 节省时间,降低风险,改善代码健康,同时向维护者支付使用的确切依赖性. [学多取.](https://tidelift.com/subscription/pkg/npm-eslint-plugin-import?utm_source=npm-eslint-plugin-import&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)

## 安装

```sh
# inside your project's working tree
npm install eslint-plugin-import --save-dev
```

### 配置 - 遗产( E)`.eslintrc`(中文(简体) )

所有规则默认取消。 然而,您可以扩展一个预设的配置,或者手动在您的 `.eslintrc.(yml|json|js)`。 。 。 .

-   扩展预设配置 :

```jsonc
{
  "extends": [
     "eslint:recommended",
     "plugin:import/recommended",
  ],
}
```

-   手动配置 :

```jsonc
{
  "rules": {
    "import/no-unresolved": ["error", { "commonjs": true, "amd": true }]
    "import/named": "error",
    "import/namespace": "error",
    "import/default": "error",
    "import/export": "error",
    // etc...
  },
},
```

### 配置 - 平面( E)`eslint.config.js`(中文(简体) )

所有规则默认取消。 然而,您可以在您的 `eslint.config.(js|cjs|mjs)`,或扩展一个预设配置:

```js
import importPlugin from 'eslint-plugin-import';
import js from '@eslint/js';

export default [
  js.configs.recommended,
  importPlugin.flatConfigs.recommended,
  {
    files: ['**/*.{js,mjs,cjs}'],
    languageOptions: {
      ecmaVersion: 'latest',
      sourceType: 'module',
    },
    rules: {
      'no-unused-vars': 'off',
      'import/no-dynamic-require': 'warn',
      'import/no-nodejs-modules': 'warn',
    },
  },
];
```

## 类型脚本

您可以使用下面描述的颗粒设置来使用以下片段或组装自己的配置 .

确定您已经安装 [`@typescript-eslint/parser`](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) 财务报告和审定财务报表 [`eslint-import-resolver-typescript`](https://github.com/import-js/eslint-import-resolver-typescript) 用于下列配置.

```jsonc
{
  "extends": [
    "eslint:recommended",
    "plugin:import/recommended",
// the following lines do the trick
    "plugin:import/typescript",
  ],
  "settings": {
    "import/resolver": {
      // You will also need to install and configure the TypeScript resolver
      // See also https://github.com/import-js/eslint-import-resolver-typescript#configuration
      "typescript": true,
      "node": true,
    },
  },
}
```

## 解析器

随着模块捆绑器的出现以及模块和模块的现状 语法规格, 并不总是很明显的 `import x from 'module'` 应该看 查找后面的文件 `module`。 。 。 .

通过 v0. 10ish , 此插件直接使用了子存储器 [`resolve`](https://www.npmjs.com/package/resolve) 插头, 它执行节点的导入行为。 这在多数情况下都相当有效.

然而, Webpack 允许导入模块源字符串中的一些事项 节点没有,例如加载器(`import 'file!./whatever'`)和若干项 替代计划,例如: [`externals`](https://webpack.github.io/docs/library-and-externals.html): 将模块 id 映射到全局名称 运行时间( 允许一些模块通过脚本标记更传统的包含) .

为了支持这两起事件,v0.11引入了解决者.

现 [节点](https://www.npmjs.com/package/eslint-import-resolver-node) 财务报告和审定财务报表 [网络软件包](https://www.npmjs.com/package/eslint-import-resolver-webpack) 决议已得到执行,但 解析器只是 npm 包,所以 [支持第三方软件包](https://github.com/import-js/eslint-plugin-import/wiki/Resolvers) (鼓励!).

您可以以多种方式( 按优先级排序) 参考解析器 :

-   作为常规 `eslint-import-resolver` 名称,比如 `eslint-import-resolver-foo`数字 :

```jsonc
// .eslintrc
{
 "settings": {
   // uses 'eslint-import-resolver-foo':
   "import/resolver": "foo",
 },
}
```

```yaml
# .eslintrc.yml
settings:
  # uses 'eslint-import-resolver-foo':
  import/resolver: foo
```

```js
// .eslintrc.js
module.exports = {
  settings: {
    'import/resolver': {
      foo: { someConfig: value }
    }
  }
}
```

-   带有完整的 npm 模块名称, 如 `my-awesome-npm-module`数字 :

```jsonc
// .eslintrc
{
  "settings": {
    "import/resolver": "my-awesome-npm-module",
  },
}
```

```yaml
# .eslintrc.yml
settings:
  import/resolver: 'my-awesome-npm-module'
```

```js
// .eslintrc.js
module.exports = {
  settings: {
    'import/resolver': {
      'my-awesome-npm-module': { someConfig: value }
    }
  }
}
```

-   ,在此示例中定义为 `computed property` 名称 :

```js
// .eslintrc.js
module.exports = {
  settings: {
    'import/resolver': {
      [path.resolve('../../../my-resolver')]: { someConfig: value }
    }
  }
}
```

相对路径将相对于源最近的路径解决 `package.json` 或者说 进程当前工作目录( 如果没有) `package.json` 已找到.

如果你在写解题时感兴趣,请看 [光谱](https://npmcn.com/package/%40exodus/eslint-plugin-import/resolvers/README.md) 更多细节.

## 设置

您可以在您的 `.eslintrc`数字 :

### `import/extensions`

将解析为模块并检查的文件扩展名列表 `export`编号.

此默认为 `['.js']`,除非您正在使用 `react` 共享配置, 此处指明为 `['.js', '.jsx']`尽管默认, 如果您正在使用 TypeScript (没有 `plugin:import/typescript` 配置 )您必须指定新的扩展(`.ts`,还有 `.tsx` 如果使用React).

```js
"settings": {
  "import/extensions": [
    ".js",
    ".jsx"
  ]
}
```

如果需要更多的颗粒扩展定义,可以使用:

```js
"settings": {
  "import/resolver": {
    "node": {
      "extensions": [
        ".js",
        ".jsx"
      ]
    }
  }
}
```

请注意,这不同于(并可能是一个子集)任何 `import/resolver` 扩展设置,其中可包括 `.json`, (中文(简体) ), `.coffee`等,将仍然 输入 `no-unresolved` 规则.

此外 `import/ignore` 模式将推翻此列表.

### `import/ignore`

Regex 字符串列表, 如果匹配到路径, 将会 如果没有,则不报告匹配模块 `export`已找到 s. 在实践中,这意味着除下列规则以外的规则: [`no-unresolved`](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-unresolved.md#ignore) 将不报告任何 `import`s 带有符合此模式的(绝对文件系统)路径.

`no-unresolved` 拥有自己的 [`ignore`](https://npmcn.com/package/%40exodus/eslint-plugin-import/docs/rules/no-unresolved.md#ignore) 设置.

```jsonc
{
  "settings": {
    "import/ignore": [
      "\.coffee$", // fraught with parse errors
      "\.(scss|less|css)$", // can't parse unprocessed CSS modules, either
    ],
  },
}
```

### `import/core-modules`

一系列额外的模块,可视为“核心”模块-模块 被视为已解决,但在文件系统中没有路径。 你的决断者 已经定义了其中一些( 例如, 节点解析器知道 `fs` 财务报告和审定财务报表 `path`),所以你不需要重新定义这些.

例如,Electron暴露了一种 `electron` 模块 :

```js
import 'electron'  // without extra config, will be flagged as unresolved!
```

否则将无法解决。 为了避免这种情况,你可以提供 `electron` 作为 核心模块 :

```jsonc
// .eslintrc
{
  "settings": {
    "import/core-modules": ["electron"],
  },
}
```

在Electron的具体案例中,有一个共同的配置命名 `electron` 指定这个给你.

欢迎更多此类共享配置为其他平台做出贡献!

### `import/external-module-folders`

一系列文件夹 。 仅从这些文件夹中解析出来的模块将被视为"外部". 默认 `["node_modules"]`。如果您已经配置了路径或网络软件包来以不同方式处理您的内部路径,并且想要考虑一些文件夹中的模块,例如 `bower_components` 或者说 `jspm_modules`,作为"外部".

此选项在 monrepo 设置中也是有用的 : 在此列出所有包含 monrepo 软件包的目录, 无论使用哪一个解析器, 它们都会被当作外部目录 .

使用时 `yarn` PnP 作为您的软件包管理器, 添加 `.yarn` 文件夹和您已安装的所有依赖关系将被视为 `external`,改为 `internal`。 。 。 .

此数组中的每个项目要么是一个文件夹的名称、它的子路径,要么是它的绝对前缀路径:

-   `jspm_modules` 将匹配任何命名的文件或文件夹 `jspm_modules` 或具有直接或非直接父母名称的 `jspm_modules`,比如说. `/home/me/project/jspm_modules` 或者说 `/home/me/project/jspm_modules/some-pkg/index.js`。 。 。 .
    
-   `packages/core` 将匹配包含这两个段的任何路径, 例如 `/home/me/project/packages/core/src/utils.js`。 。 。 .
    
-   `/home/me/project/packages` 将只匹配此目录内的文件和目录,以及目录本身.
    

请注意,此处不允许有不完整的名字 `components` 说不通 `bower_components` 财务报告和审定财务报表 `packages/ui` 说不通 `packages/ui-utils` (但将会匹配) `packages/ui/utils`) (中文(简体) ).

### `import/parsers`

从解析器到文件扩展数组的地图 。 如果一个文件扩展名匹配,则 依赖解析器需要并使用地图密钥作为解析器,而不是 配置了 ESLint 解析器 。 如果您与 TypeScript 进行对接, 此操作将有所帮助 直接使用网包,例如:

```jsonc
// .eslintrc
{
  "settings": {
    "import/parsers": {
      "@typescript-eslint/parser": [".ts", ".tsx"],
    },
  },
}
```

在这种情况下, [`@typescript-eslint/parser`](https://www.npmjs.com/package/@typescript-eslint/parser) 运行时必须安装和需要 `eslint` 模块的位置 (即作为ESLint的对等设备安装).

目前仅测试 `@typescript-eslint/parser` (及其前身, `typescript-eslint-parser`),但理论上应该与任何中度合作 符合ESTree的解析器.

很难说各种插件特性会得到多少支持, 要看兔子洞到底有多深 如果你觉得奇怪,就提出问题 越远越好,但用钢心 对抗关闭的可能结果 与 `wontfix`。 。 。 .

### `import/resolver`

见 [解析器](https://npmcn.com/package/%40exodus/eslint-plugin-import/#readme-resolvers)。 。 。 .

### `import/cache`

缓存行为的设置 。 在不同级别上使用纪念来避免大量 `fs.statSync`/模块解析正确报告错误所需的呼叫.

为了正常 `eslint` 控制台运行,缓存寿命无关紧要,因为我们可以强烈地假设文件不应该在linter进程期间发生改变(因此,内存中的缓存)

对于长久的过程,比如 [`eslint_d`](https://www.npmjs.com/package/eslint_d) 或者说 [`eslint-loader`](https://www.npmjs.com/package/eslint-loader)然而,重要的是要有某种固态的概念.

如果你从不使用 [`eslint_d`](https://www.npmjs.com/package/eslint_d) 或者说 [`eslint-loader`](https://www.npmjs.com/package/eslint-loader),您可将缓存寿命设定为 `Infinity` 一切都会好起来的:

```jsonc
// .eslintrc
{
  "settings": {
    "import/cache": {
      "lifetime": "∞", // or Infinity, in a JS config
    },
  },
}
```

否则, 设置一些整数, 缓存项会在数秒后被删除 :

```jsonc
// .eslintrc
{
  "settings": {
    "import/cache": {
      "lifetime": 5, // 30 is the default
    },
  },
}
```

### `import/internal-regex`

包件的正则ex应作为内部处理. 当您正在使用单列集设置或开发一套互相依赖的软件包时有用 .

默认情况下,任意引用的软件包 [`import/external-module-folders`](https://npmcn.com/package/%40exodus/eslint-plugin-import/#readme-importexternal-module-folders) 将被视为“外部”,包括像纱线工作空间或lerna环境这样的单列波中的包。 如果您想要将这些软件包标为“ 内部 ” , 这将很有用 .

例如,如果您在单列的软件包全部在 `@scope`,您可以配置 `import/internal-regex` 像这样

```jsonc
// .eslintrc
{
  "settings": {
    "import/internal-regex": "^@scope/",
  },
}
```

## 下层内衬

SublimeLinter-slint 引入了支持的更改 `.eslintignore` 文件 它改变了文件路径在编辑时向 ESLint 传递的方式. 此更改向文件发送相对路径而不是绝对路径( 如 ESLint) )),这会使此插件无法解决依赖性 在文件系统.

随着ESLint 2.0的发布,这一绕行就不再需要了 `.eslintignore` 将更新到更像一个 `.gitignore`,应当 支持正确忽略绝对路径通过 `--stdin-filename`。 。 。 .

在此期间,看 [roadhump/SublimeLinter-slint#58 (英语)](https://github.com/roadhump/SublimeLinter-eslint/issues/58) 更多细节和讨论,但基本上你可能会发现你需要添加以下内容: `SublimeLinter` 配置到您的 Sublime 工程文件 :

```json
{
    "folders":
    [
        {
            "path": "code"
        }
    ],
    "SublimeLinter":
    {
        "linters":
        {
            "eslint":
            {
                "chdir": "${project}/code"
            }
        }
    }
}
```

请注意: `${project}/code` 与 `code` 规定 `folders[0].path`。 。 。 .

目的 `chdir` 在此情况下,设置是设置工作目录 从中执行 ESLint 与 SublimeLinter- eslint 的目录相同 以它提供的相对路径为基础.

见 SublimeLinter 文档 [`chdir`](https://www.sublimelinter.com/en/latest/linter_settings.html#chdir) 需要更多信息,请查看infofinland上的项目.

如果你没有使用 `.eslintignore`,或者没有Sublime项目文件,您也可以 通过 `.sublimelinterrc` 您的祖先目录中的文件 代码 :

```json
{
  "linters": {
    "eslint": {
      "args": ["--stdin-filename", "@"]
    }
  }
}
```

我也发现我需要设置 `rc_search_limit` 改为 `null`,删除文件 查找目录树时等级搜索限制 `.sublimelinterrc`数字 :

在软件包设置/ sublimeLinter/ 用户设置中:

```json
{
  "user": {
    "rc_search_limit": null
  }
}
```

我相信这个默认 `3`,所以你可能不需要 改变它取决于你的 项目文件夹最大深度 .

## 常见问题

### @exodus/eslint-plugin-import 是什么？

以智入入\.

### 如何安装 @exodus/eslint-plugin-import？

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

### @exodus/eslint-plugin-import 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/exodus\_\_eslint-plugin-import 是否存在。

### @exodus/eslint-plugin-import 支持 ESM 还是 CommonJS？

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

### @exodus/eslint-plugin-import 需要什么版本的 Node\.js？

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

### @exodus/eslint-plugin-import 可以商用吗？

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

### @exodus/eslint-plugin-import 的下载量有多少？

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

### @exodus/eslint-plugin-import 还在维护吗？

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

