@cabify/eslint-config

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

ESLint config for Cabify Javascript projects

原始使用文档
文档目录6 节
  1. Installation
  2. Usage
  3. Formatting
  4. Setup for TypeScript
  5. Publish a new version
  6. Contributors ✨

@cabify/eslint-config

npm (scoped)

All Contributors

ESLint config for both TS and JS, Cabify way.

Installation

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

or

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

Usage

  1. Create a .eslint.config.js file at the root of your project:
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. Add the lint task into your package.json:
...
"scripts": {
  ...
  "lint:fix": "eslint ./ --fix",
  "lint": "eslint ./",
  ...
}
  1. Add a .globalIgnores in your eslint.config.js to avoid checking unwanted files:
// 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];

Formatting

The recomended configuration does not include formatting rules, as using the Prettier binary is quicker and brings more benefits. To format the files from your app a and checking them are properly formatted you can add the following scripts to your package.json file:

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

Setup for TypeScript

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. Add a ./tsconfig.eslint.json to the root of your project. NOTE: it is important that your tsconfig.eslint.json file includes the same files that you are going to lint, or it will fail and make linting so slow.
{
  "extends": "./tsconfig.json",
  "include": ["src/**/*", "test/**/*"] // remember to import also your test files if you want to lint them
}

A note on performance in TS projects

There is an known issue that may affect linting times in projects with TS. If you note that your linting time is not acceptable, there is a workaround to improve it a lot, but it implies to disable some rules. If you can live without them, just make these changes in your .eslintrc config:

{
  ...
  // 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"
  }
}

Publish a new version

  • Update CHANGELOG with new features, breaking changes, etc
  • Check you're in main branch and everything is up-to-date.
  • Run yarn publish:<major|minor|patch> or yarn publish:canary for canary versions.
  • Run git push && git push --tags
  • Check all test actions triggered after previous push are ✔️.
  • Go to create a new release, select previously pushed tag and write a Title.
  • Check the action for publish the npm has finished with success.
  • Check on npm package webpage, the version has been published successfully under latest tag.

This will trigger a workflow on Github which will publish to npm eventually.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Aarón García Hervás

💻

Alejandro

💻

Alejandro Gallardo Escobar

💻

Alejandro León

💻

Alex Temina

💻

Arian Zargaran

💻

Carlos Castillo

💻

Christian

💻

Crismmgg

💻

David Asensio Cañas

💻

Francisco Sánchez

💻

Javier López

💻

Jesús Merino Parra

💻

Leire Rico

💻

Ricardo Boluda

💻

Rodrigo

💻

Sergio Ramirez

💻

Valentin Berlin

💻

Yago Quiñoy Lobariñas

💻

alejandromolero

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

版本与发布记录

@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 是什么?

ESLint config for Cabify Javascript projects

如何安装 @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 和提交记录判断。