@basenative/eslint-config

中文文档
3.0.0发布于 2026/10/31Apache-2.0ES Module构建来源已验证

为DuganLabs项目共享ESLint平面配置-安全,卫生,零噪音默认值

中文使用文档
文档目录6 节
  1. 安装
  2. 使用
  3. 组成
  4. 里面有什么?
  5. 链接
  6. 许可证

@basenative / eslint-config

共享ESLint平面配置预设DuganLabs项目。一个观点,一个来源。

安装

pnpm add -D eslint @basenative/eslint-config

使用

选择与运行时匹配的预设。在 eslint.config.js:

// SPA / browser
import config from "@basenative/eslint-config/browser";
export default config;

// Node / scripts
import config from "@basenative/eslint-config/node";
export default config;

// Cloudflare Workers / Pages Functions
import config from "@basenative/eslint-config/worker";
export default config;

// React
import config from "@basenative/eslint-config/react";
export default config;

组成

预设导出一个数组-扩展它:

import base from "@basenative/eslint-config/browser";

export default [
  ...base,
  {
    rules: {
      "no-console": "warn",
    },
  },
];

里面有什么?

  • @eslint/js 推荐设置
  • 下划线前缀免除未使用的变量/参数/捕获的错误
  • no-eval / no-implied-eval / no-new-func (安全基线)
  • eqeqeq 聪明, no-var, prefer-const
  • Worker预设块(仅限节点的全局变量)process, Buffer, __dirname, __filename)
  • 更美观的兼容性-禁用格式化规则

许可证

apache - 2.0

版本与发布记录

@basenative/eslint-config 共发布 11 个版本,首次发布于 2026/10/18;过去 12 个月发布了 11 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.0.0latest2026/10/312 天前
2.4.02026/10/268 天前
2.3.22026/10/2212 天前
2.3.12026/10/2212 天前
2.3.02026/10/2212 天前
2.2.02026/10/2113 天前

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

@basenative/eslint-config 是什么?

为DuganLabs项目共享ESLint平面配置-安全,卫生,零噪音默认值

如何安装 @basenative/eslint-config?

在项目目录运行 npm install @basenative/eslint-config,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:eslint(>=9.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@basenative/eslint-config 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/basenative__eslint-config 是否存在。

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

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

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

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

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

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