@cksource-cs/eslint-config-cs-module

中文文档
11.1.0发布于 2026/09/03UNLICENSEDES Module近 30 天下载 3.6万

Cloud Services ESLint config.

原始使用文档
文档目录6 节
  1. tsconfig
  2. Migration to 6.x
  3. Notable linter changes
  4. Dependencies requirements
  5. Migration to 3.x
  6. Updating linter rules

ESLint/Typescript Dev Config Module

This is the module with configuration for ESlint and Typescript used in every module in CS.

tsconfig

This module ships two base TypeScript configurations - they differ only in type-checking strictness.

  • tsconfig.strict.json (recommended):

The recommended base config for all new and newly-migrated packages. Aligns with TypeScript 6.x defaults.

{
  "extends": "@cksource-cs/eslint-config-cs-module/tsconfig.strict.json"
}
  • tsconfig.common.json (legacy):

The original, non-strict base config. Use it only for packages that have not yet been migrated to the strict preset. New packages should not extend this config.

{
  "extends": "@cksource-cs/eslint-config-cs-module/tsconfig.common.json"
}

Migration to 6.x

Version 6.0 enforces a new eslint.config.js, meaning that the flat config is now the default configuration format for ESLint. .eslintrc is officially deprecated and it should not be used, as the support for it will be removed in the upcoming major ESLint version.

We highly recommend to use JS modules (*.mjs) for defining configs:

import { defineConfig, globalIgnores } from 'eslint/config';
import csConfig from '@cksource-cs/eslint-config-cs-module';

export default defineConfig(
    csConfig,
    globalIgnores( [
        '**/coverage',
        '**/dist',
        '**/dist-tests'
    ] )
);

NOTE! The newest version does not export anymore the /typescript sub path. All format rules are exposed via one entrypoint.

Notable linter changes

  • The new rule @typescript-eslint/consistent-type-imports encourages to specify a type keyword on imports to indicate that the export exists only in the type system, not at runtime. This allows transpilers to drop imports without knowing the types of the dependencies. This rule only output a warn message as it influences a major code style change in all existing imports.

  • Due to the underlying breaking changes that happened in the eslint, some rules has been removed and moved to the third-party plugins. Notable rule changes include:

    • max-len -> @stylistic/max-len
    • indent -> @stylistic/indent
    • no-multi-spaces -> @stylistic/no-multi-spaces
    • no-path-concat -> node/no-path-concat
    • no-new-require -> node/no-new-require
  • This new major version also started to properly lint test files, so you can notice more linter errors.

  • Directives - in case of browser-environment scripts: /* eslint-env browser */ -> /* global window */

Dependencies requirements

  • eslint: "9.37.x"
  • typescript: "5.9.x"

The migrations process should contain steps similar as previously.

Migration to 3.x

Version 3.0.0 introduces some lint rules that can require some manual fixes (everything based on comments during the code review process) and introduce config for Typescript > 4.

From version 3.0.0 this module requires specific dependencies:

  • eslint: "8.6.0"
  • eslint-import-resolver-node: "0.3.6"
  • typescript: "5.4.5"

Note: it may be a situation when @types/node module is not updated. The best option update this module to 20.11.1.

So, the migrations process should contain similar steps:

  1. Update devDependencies (eslint, Typescript, etc.) in project.
  2. Update @cksource-cs/eslint-config-cs-module to version > 3.0.0
  3. Run pnpm cli build [package_name] or npm run build
  4. Run npm run lint:fix
  5. Fix manually all lint problems.
  6. Run npm run lint
  7. Run all tests.
  8. Fix tests.

Note: it can be a problem with ts-node in Mocha tests so recommendation is to remove ts-node and use approach with dist-tests. More information about migrating from Mocha to AVA can be found here: https://www.notion.so/Migrating-from-Mocha-to-AVA-48bd10bf8be141349c4a8d302d5f957d .

Updating linter rules

If you believe we need to change the ESLint rules, make sure to discuss it with the team first. Once you get the go-ahead, follow the steps below to update the package across the whole CS:

  1. Update eslintrc.js as needed (with generic ESLint rules) and/or typescript.js (TS-specific rules only).
  2. Bump the version of this module (eslint-config-cs-module) in package.json.
  3. To estimate how much work will be needed to update the linter module in other packages, create local links and try applying auto-fixes:
csli link --min-version=3.0.0 eslint-config-cs-module && \
csli run lint:fix
  1. If you're happy with the changes, proceed with a PR and release the new version of the ESLint module.
  2. Once the PR has been merged, switch to master. Go to the CS repository root and run the following command to upgrade the ESLint module in all client packages. The command will also attempt to auto-fix any errors, similarly to what we did in step 2.
pnpm -r install --dev && \
csli run deps:check --command-options="-u,-f @cksource-cs/eslint-config-cs-module" && \
pnpm -r install --dev && \
csli run lint:fix
  1. Apply manual fixes if needed, commit the changes to a feature branch and create a PR.

版本与发布记录

@cksource-cs/eslint-config-cs-module 共发布 65 个版本,首次发布于 2019/08/05;过去 12 个月发布了 17 个版本。

版本发布日期距今
11.1.0latest2026/09/032 个月前
11.0.02026/08/202 个月前
10.2.12026/07/293 个月前
10.2.02026/07/213 个月前
10.1.02026/07/203 个月前
10.0.02026/06/174 个月前

关于 @cksource-cs/eslint-config-cs-module 的常见问题

@cksource-cs/eslint-config-cs-module 是什么?

Cloud Services ESLint config.

如何安装 @cksource-cs/eslint-config-cs-module?

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

@cksource-cs/eslint-config-cs-module 支持 TypeScript 吗?

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

@cksource-cs/eslint-config-cs-module 支持 ESM 还是 CommonJS?

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

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

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

@cksource-cs/eslint-config-cs-module 可以商用吗?

@cksource-cs/eslint-config-cs-module 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@cksource-cs/eslint-config-cs-module 的下载量有多少?

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

@cksource-cs/eslint-config-cs-module 还在维护吗?

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