@cabify/eslint-config

中文文档
3.0.3发布于 2026/05/22Apache-2.0ESM + CJS构建来源已验证近 30 天下载 6220

Cabify Javascript 项目的 ESLint 配置

中文使用文档
文档目录6 节
  1. 安装
  2. 使用量
  3. 格式化
  4. 类型脚本的设置
  5. 发布新版本
  6. 贡献者

@ cabify/eslint- config

npm (scoped)

All Contributors

TS和JS的ESLint配置, Cabify方式.

安装

npm i -D @cabify/eslint-config eslint prettier

或者说

yarn add --dev @cabify/eslint-config eslint prettier

使用量

  1. 创建一个 .eslint.config.js 在工程根处的文件 :
import recommended from '@cabify/eslint-config';
/* Define an object for local configuration. 
/ You can add your custom configuration and override existing rules here before exporting it.
const localConfig = {};
export default [...recommended, localConfig];
*/
export default [...recommended];
  1. 将线性任务添加到您的 package.json数字 :
...
"scripts": {
  ...
  "lint:fix": "eslint ./ --fix",
  "lint": "eslint ./",
  ...
}
  1. 添加一个 .globalIgnores 在你身边 eslint.config.js 以避免检查不想要的文件 :
// https://eslint.org/docs/latest/use/configure/configuration-files#globally-ignoring-files-with-ignores
const globalIgnores = {
  ignores: [
    'dist',
    'node_modules/*',
    'storybook-static/*',
    'test/*',
    'build',
    'scripts',
    'webpack',
  ],
};
export default [...recommended, globalIgnores];

格式化

重新推荐的配置不包括格式化规则,因为使用Prettier二进制会更快,带来更多的好处. 要格式化您的应用程序 a 中的文件, 并检查它们是否正确格式化, 您可以在您的应用程序中添加以下脚本 package.json 文件 :

...
"scripts": {
  ...
  "format": "prettier --write .",
  "format:check": "prettier --check .",
  ...
}

类型脚本的设置

const localConfigs = {
  languageOptions: {
    parserOptions: {
      project: './tsconfig.json',
      ecmaVersion: 2020,
    },
  },
  settings: {
    'import/resolver': {
      typescript: {
        alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
        project: '<root>/tsconfig.json',
      },
    },
  },
};

export default [...recommended, localConfigs];
  1. 添加一个 ./tsconfig.eslint.json 到您的项目根部. 注意:重要的是,你 tsconfig.eslint.json 文件包含 同样的文件,你要去涂入, 否则它会失败 并让林入如此缓慢.
{
  "extends": "./tsconfig.json",
  "include": ["src/**/*", "test/**/*"] // remember to import also your test files if you want to lint them
}

关于技术服务项目业绩的说明

还有一个已知的问题可能会影响与TS合作的项目的起伏时间. 如果你注意到你的 消磨时间是无法接受的, 有很多工作来改进它, 但它意味着禁用 一些规则。 如果你能活着没有他们, 就做这些改变你的 .eslintrc 配置 :

{
  ...
  // remove the "project" field (if you don't have any other parserOptions you can remove the full section)
  "parserOptions": {},
  "rules": {
    // this rules depend on project field, so they must be disabled to make linting much faster
    "@typescript-eslint/await-thenable": "off",
    "@typescript-eslint/no-misused-promises": "off",
    "@typescript-eslint/no-unnecessary-type-assertion": "off",
    "@typescript-eslint/prefer-includes": "off",
    "@typescript-eslint/prefer-regexp-exec": "off",
    "@typescript-eslint/prefer-string-starts-ends-with": "off",
    "@typescript-eslint/require-await": "off",
    "@typescript-eslint/unbound-method": "off"
  }
}

发布新版本

  • 更新 变化 具有新特性, 断开更改等
  • 检查你英寸 main 分支和一切是最新的.
  • 运行 yarn publish:<major|minor|patch> 或者说 yarn publish:canary 为金丝雀版本.
  • 运行 git push && git push --tags
  • 请检查access-date=中的日期值 (帮助) 上次推后触发的所有测试动作均为QQ.
  • 转到 创建新发行,选择先前所推动的标签并写入标题.
  • 请检查date=中的日期值 (帮助) Npm 发布动作已成功完成 .
  • 检查 npm 包网页,该版本已在 latest 标签.

这将触发 Github 的工作流程, 它最终会发布到 npm .

贡献者

感谢这些伟大的人emoji 密钥:


阿龙·加西亚·埃尔瓦斯

💻

亚历杭德罗

💻

亚历杭德罗·加利亚多·埃斯科瓦尔

💻

亚历杭德罗·莱昂

💻

亚历克斯·特米纳

💻

亚利安·扎尔加兰

💻

卡洛斯·卡斯蒂略

💻

基督教徒

💻

克里斯姆格语Name

💻

戴维·阿森西奥·卡尼亚斯

💻

弗朗西斯科·桑切斯

💻

哈维尔·洛佩斯

💻

杰苏斯·梅里诺·帕拉

💻

莱尔·里科

💻

里卡多·博卢达

💻

罗德里戈

💻

塞尔吉奥·拉米雷斯

💻

瓦伦丁·柏林

💻

亚戈·基尼奥伊·洛巴里尼亚斯

💻

阿列扬德罗莫雷罗

💻

本项目遵循 全部贡献者 规格。 任何捐款都欢迎!

版本与发布记录

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

版本发布日期距今
3.0.3latest2026/05/225 个月前
3.0.22026/05/135 个月前
3.0.12025/02/251.7 年前
3.0.1-beta-37beta2025/02/251.7 年前
3.0.1-beta-362025/02/251.7 年前
3.0.1-beta-352025/02/171.7 年前

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

@cabify/eslint-config 是什么?

Cabify Javascript 项目的 ESLint 配置

如何安装 @cabify/eslint-config?

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

@cabify/eslint-config 支持 TypeScript 吗?

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

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

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

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

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

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

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

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

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