@bitfactory/eslint-config

中文文档
14.0.3发布于 2026/09/08MITES Module零依赖近 30 天下载 4745

ESLint sharable config for NOBEARS (former Bitfactory NL) projects

原始使用文档
文档目录11 节
  1. Quick Start
  2. Contributing
  3. Installation
  4. Version support
  5. Configuration
  6. Vue 3 and Nuxt
  7. JSON
  8. Published packages
  9. Tailwind CSS
  10. CLI Usage
  11. Editor Integration

@bitfactory/eslint-config

Release MIT license ESLint NodeJS NPM package version

Shareable ESLint config for ESLint v9+ Flat Config (ESM). All rules and configurations are pre-configured. Rules can be overridden as needed.

[!IMPORTANT] This package is flat-config only (ESM) and requires ESLint ^9.38.0 || ^10.0.0. Upgrading from an older major? Start with the 14.0.0 Migration Guide, which is organised by project shape: which entrypoints your stack takes, which ignores go with it, and how to adopt the rule changes in stages. The Installation Guide lists every break in order, with a migration guide for each that has one.

[!WARNING] This config owns the import-x namespace, so the run can abort if your project registers a second eslint-plugin-import-x copy that does not dedupe with this one, for files both registrations cover. See Known issue: import plugin namespace collision for the remedies.

[!WARNING] On ESLint 9, pin @eslint/js to 9.38.0 or a newer 9.x. Left to resolve by range it selects an ESLint 10 build whose own peer excludes ESLint 9, and the install fails. See Known issue: @eslint/js resolves to an ESLint 10 build on ESLint 9 for the one-line remedy.

Quick Start

For a quick start guide with basic installation and configuration, see QUICKSTART.md.

Contributing

For information about contributing to this project, including publishing guidelines, local development setup, and debugging tips, see CONTRIBUTING.md in the repository. It is not published to npm.

Installation

For detailed installation instructions including peer dependencies and Vue/TypeScript setup, see Installation Guide.

Version support

The major line latest points at is the supported one, and every patch on it stays installable. A line is retired - deprecated as a whole, with no backports from then on - when its successor major publishes. What brings that major about is usually an end of life upstream: the oldest ESLint major the line's peer range admits, or the oldest Node line its engines.node declares, going out of support; see ESLint's version support and the Node.js release schedule for those dates.

An individual version is deprecated only when it is defective, and its message names the first version without the defect. npm view @bitfactory/eslint-config@<version> deprecated shows any version's message.

Configuration

For configuration examples (Vue, TypeScript) and advanced configuration options (custom plugins, ECMAScript version overrides), see Configuration Guide.

Vue 3 and Nuxt

For the opt-in /vue3 and /nuxt entrypoints, including usage recipes and peer requirements, see Vue 3 and Nuxt Guide.

JSON

Opt-in entrypoint for linting JSON files, built on eslint-plugin-jsonc and eslint-plugin-package-json. It is additive and not enabled by the base config:

pnpm add -D eslint-plugin-jsonc eslint-plugin-package-json
import bitfactory from '@bitfactory/eslint-config';
import json from '@bitfactory/eslint-config/json';

export default [
    ...bitfactory,
    ...json,
];

The /json entrypoint lints .json, .json5, and .jsonc files, sorting keys and enforcing a two-space indent. Array values are sorted only in tsconfig*.json and jsconfig.json, and only the arrays there that are sets. Comments belong to the .jsonc and .json5 grammars, and are allowed in tsconfig*.json, jsconfig.json, and .vscode/*.json as well.

package.json is ordered instead by eslint-plugin-package-json, so a repository running sort-package-json as a separate step can drop it. It also checks that whichever fields the manifest declares are well formed, and that no dependency is declared twice.

Markdown is not linted here. Use markdownlint directly: it covers roughly fifty rules where the entrypoint this replaces covered seventeen, nine of them duplicating markdownlint already.

Published packages

/package-json is /json plus the requirement that a published package actually declares those fields - attribution (author or contributors), exports, engines, keywords, and the rest - and that no dependency resolves to a local path. Use it in place of /json when the project is published to a registry. An application keeps /json, which never requires a field it has no reason to declare.

import bitfactory from '@bitfactory/eslint-config';
import packageJson from '@bitfactory/eslint-config/package-json';

export default [
    ...bitfactory,
    ...packageJson,
];

Tailwind CSS

Opt-in entrypoint for linting Tailwind CSS class usage, built on eslint-plugin-tailwindcss. It is additive and not enabled by the base config, and it supports both Tailwind majors. Both exports bring the parser their globs need beyond ESLint's default, so both import @typescript-eslint/parser, and /tailwind-vue also imports vue-eslint-parser. Install the plugin version matching your Tailwind major, plus whichever parsers your project does not already have; your project's existing tailwindcss install provides the rest:

# Tailwind 4
pnpm add -D eslint-plugin-tailwindcss@4

# Tailwind 3
pnpm add -D eslint-plugin-tailwindcss@3
import bitfactory from '@bitfactory/eslint-config';
import tailwind from '@bitfactory/eslint-config/tailwind';

export default [
    ...bitfactory,
    ...tailwind,
];

The plugin supplies no parser of its own, so an entrypoint that claims .vue has to bring one. A Vue project's class names live in templates, so /tailwind-vue carries the same rules for .vue and supplies vue-eslint-parser:

import bitfactoryVue3 from '@bitfactory/eslint-config/vue3';
import tailwind from '@bitfactory/eslint-config/tailwind';
import tailwindVue from '@bitfactory/eslint-config/tailwind-vue';

export default [
    ...bitfactoryVue3,
    ...tailwind,
    ...tailwindVue,
];

The plugin needs your project's own Tailwind entry point, which no shared configuration can supply, and each major reads a different key for it. Plugin v4 takes a stylesheet from cssConfigPath, defaulting to src/style.css, and aborts the whole run with ENOENT when that file is missing:

{
    settings: {
        tailwindcss: {
            cssConfigPath: 'resources/css/app.css',
        },
    },
},

Plugin v3 has no cssConfigPath. It reads config, which names your tailwind.config.js rather than a stylesheet, and when it cannot load that file it falls back to Tailwind's default theme without warning, so class names are judged against a theme that is not yours.

Both entrypoints enable tailwindcss/classnames-order at warn, and it is auto-fixable, so the editor setup in the integration guide sorts on save. It reaches only the extensions each entrypoint claims - .js, .jsx, .ts, .tsx and .vue - so a formatter plugin still covers .mjs, .cjs, .mts and .cts. Set the entry point above before removing the other plugin.

Both apply no house rule set of their own: each carries the Tailwind plugin's rules for the files it names, and each parses those files, so each works alone. Both need the entry point set above. The entrypoints adapt to whichever plugin major is installed (v3's flat/recommended array or v4's recommended config).

CLI Usage

For CLI usage instructions and command examples, see CLI Usage Guide.

Editor Integration

For editor integration instructions (Visual Studio Code, PhpStorm), see Editor Integration Guide.

版本与发布记录

@bitfactory/eslint-config 共发布 128 个版本,首次发布于 2020/04/17;过去 12 个月发布了 69 个版本。

版本发布日期距今
14.0.3latest2026/09/082 个月前
14.0.22026/09/032 个月前
14.0.12026/08/312 个月前
14.0.02026/08/312 个月前
13.1.32026/08/212 个月前
8.4.7release-82026/08/212 个月前

其他发布通道:release-10 → 10.0.8,release-12 → 12.0.9,release-11 → 11.0.9,release-9 → 9.0.5,release-8 → 8.4.7。

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

@bitfactory/eslint-config 是什么?

ESLint sharable config for NOBEARS (former Bitfactory NL) projects

如何安装 @bitfactory/eslint-config?

在项目目录运行 npm install @bitfactory/eslint-config,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:eslint(^9.38.0 || ^10.0.0)、globals(>=16.0.0)、@eslint/js(^9.38.0 || ^10.0.0)、eslint-plugin-jsdoc(>=62.7.0 <65.0.0)、eslint-plugin-unicorn(>=62.0.0 <66.0.0)、eslint-plugin-import-x(^4.17.0)、@stylistic/eslint-plugin(>=5.9.0)、eslint-plugin-perfectionist(>=4.15.0)、eslint-config-flat-gitignore(>=2.2.1 <3.0.0)、eslint-plugin-sort-destructure-keys(>=3.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bitfactory/eslint-config 支持 TypeScript 吗?

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

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

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

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

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

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

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

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

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

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

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