@cruk/eslint-config

中文文档
6.0.1发布于 2026/06/11MITES Module零依赖近 30 天下载 3874

eslint rules for cruk typescript projects

原始使用文档
文档目录8 节
  1. What it does
  2. Compatability
  3. Installation
  4. NPM
  5. Monorepo installation
  6. Configuration
  7. Example
  8. Releases

ESLint config

These are settings for ESLint

What it does

This setup lints your JavaScript and TypeScript code based on the current recommended best practices.

Compatability

  • Node 22
  • Node 24

Installation

NPM

npm i -D @cruk/eslint-config

Monorepo installation

If you are using a monorepo tool like NX with nx run many -t=eslint then you need to install dependencies for eslint in the root. If you are using a monorepo tool like npm workspaces with npm run eslint --ws --if-present then you will need to install the eslint dependencies in each package

Configuration

Create (or update) an eslint.config.mjs file in the root of your repo or if you have a mono repo in the root of each package. This is especially recommended if you have a large monorepo with many packages because running eslint on all packages at the same time could exceed JS heap size limits.

Example

Kitchen sink expample where older configs are also included using some compatability tools:

import { FlatCompat } from "@eslint/eslintrc";
import tsParser from "@typescript-eslint/parser";
import path from "path";
import { fileURLToPath } from "url";
import { fixupConfigRules } from "@eslint/compat";

import { config as crukConfig } from "@cruk/eslint-config";

const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
const __dirname = path.dirname(__filename); // get the name of the directory
const compat = new FlatCompat({
  // import.meta.dirname is available after Node.js v20.11.0
  baseDirectory: import.meta.dirname,
});

const config = [
  ...crukConfig,
  ...compat.config({
    extends: ["next"],
    settings: {
      next: {
        rootDir: ".",
      },
    },
  }),
  {
    languageOptions: {
      parser: tsParser,
      parserOptions: {
        tsconfigRootDir: __dirname,
        project: ["./tsconfig.json"],
      },
    },
    rules: {
      "@next/next/no-img-element": "off",
    },
    files: ["src/**/*.ts", "src/**/*.tsx", "playwright/**/*.ts"],
    ignores: [".next", ".swc", "test-results", "node_modules"],
  },
];

export default fixupConfigRules(config);

You can test your setup is correct by running

npx eslint --fix-dry-run .

Releases

Pre-release

  1. Please update the version number in the package.json and follow the semver standards for version numbers.
  2. Run nvm use to make sure that you are on the correct version of node.
  3. Run npm i to make sure that the correct version in the lockfile.
  4. Update the CHANGELOG.md which should list the changes for the release, instructions are at the bottom of the file.
  5. These changes need to be merged into master.

Releasing

  1. Make sure that you have the correct permissions for the @cruk org on NPM.
  2. Run the release script with npm run release

This should use release-it to allow you to select the same version number as stated in the package JSON and it should take care of the rest:

  • it runs npm ci
  • it does the build
  • it makes and pushes the tag
  • it releases the build lib to NPM
  • it requests if you want to document the release on github and autogenerates the release notes.
  1. Agree to all these steps release-it walks through and when Github opens up with the release click on the Publish button. If anything goes wrong release-it should roll back.
  2. When it opens up github to create the release/tag, use auto generate to create the release notes.

版本与发布记录

@cruk/eslint-config 共发布 23 个版本,首次发布于 2021/09/27;过去 12 个月发布了 3 个版本。

版本发布日期距今
6.0.1latest2026/06/114 个月前
6.0.02026/06/114 个月前
5.0.02025/12/0811 个月前
4.0.02025/01/221.8 年前
3.1.12024/09/242 年前
3.0.12024/04/292 年前

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

@cruk/eslint-config 是什么?

eslint rules for cruk typescript projects

如何安装 @cruk/eslint-config?

在项目目录运行 npm install @cruk/eslint-config,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@eslint/js(^10)、@types/node(^24)、eslint(^10)、eslint-config-prettier(^10.0.1)、eslint-plugin-prettier(^5.2.2)、eslint-plugin-promise(^7.3.0)、prettier(^3)、typescript-eslint(^8.61.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cruk/eslint-config 支持 TypeScript 吗?

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

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

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

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

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

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

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

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

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