@blgc/config

中文文档
0.1.2发布于 2026/08/08MITESM + CJS近 30 天下载 7307

Shared TypeScript, ESLint, Prettier, and Vitest configs for Builder Group projects

原始使用文档
文档目录16 节
  1. Install
  2. Usage
  3. Prettier
  4. ESLint
  5. TypeScript
  6. Vitest
  7. FAQ
  8. Do I need every peer tool installed?
  9. Can I override rules?
  10. Why does ESLint report warnings instead of failing?
  11. Why are the shared config files CommonJS?
  12. Why does the React ESLint config use jiti?
  13. Why does the library TypeScript config use module preserve?
  14. Why not enable every strict TypeScript flag?
  15. Why keep these configs in a package?
  16. Credits

@blgc/config banner

GitHub License NPM total downloads Join Discord

@blgc/config is Builder Group's shared config package for TypeScript projects. It keeps formatting, linting, type checking, and Node test defaults in one versioned dependency, so packages can share strict tool behavior without copying config files.

  • Format code, Markdown, imports, Tailwind classes, and package manifests with one Prettier config
  • Pick flat ESLint presets for libraries, React, Next.js, and TanStack projects
  • Extend TypeScript presets for bundled libraries, DOM libraries, Node 20, React, Next.js, and TanStack
  • Reuse a Vitest node preset with TypeScript path resolution and coverage reporters
// eslint.config.js
module.exports = [...require('@blgc/config/eslint/library')];
// tsconfig.json
{
  "extends": "@blgc/config/typescript/library",
  "include": ["src"]
}
{
  "prettier": "@blgc/config/prettier"
}

Migrating from 0.0.x? See MIGRATION.md.

Install

Install the config package:

npm install -D @blgc/config

Install the tool packages for the entrypoints your project uses:

# ESLint presets
npm install -D eslint typescript

# Prettier config
npm install -D prettier

# TypeScript configs
npm install -D typescript

# Vitest config
npm install -D vitest

The shared plugin dependencies resolve from @blgc/config, so projects only need to install the tool packages they run directly.

Usage

Use the entrypoint that matches the tool or project type:

EntrypointUse for
@blgc/config/prettierShared formatting and sorting rules
@blgc/config/eslint/baseShared ESLint foundation for custom presets
@blgc/config/eslint/libraryTypeScript libraries
@blgc/config/eslint/reactReact packages and Vite apps
@blgc/config/eslint/nextNext.js apps
@blgc/config/eslint/tanstackTanStack Router or TanStack Start apps
@blgc/config/typescript/baseShared strict TypeScript defaults
@blgc/config/typescript/libraryBundled libraries without DOM globals
@blgc/config/typescript/library-domBundled libraries that use DOM globals
@blgc/config/typescript/node20Node 20 packages and tools
@blgc/config/typescript/reactReact packages and Vite apps
@blgc/config/typescript/nextNext.js apps
@blgc/config/typescript/tanstackTanStack apps
@blgc/config/vitest/nodeNode test environments

Prettier

Reference the shared config from package.json:

{
  "prettier": "@blgc/config/prettier"
}

The config includes:

  • LF line endings, tabs for code files, two-space Markdown indentation, single quotes, semicolons, and printWidth: 100
  • import sorting through @ianvs/prettier-plugin-sort-imports
  • package.json ordering through prettier-plugin-packagejson
  • Tailwind class sorting through prettier-plugin-tailwindcss

The Prettier plugins resolve from @blgc/config, so consuming packages do not need to install those plugins directly.

Projects that need a Tailwind v4 stylesheet path or Tailwind v3 config path can extend the config locally:

module.exports = {
  ...require('@blgc/config/prettier'),
  tailwindStylesheet: './src/styles.css'
};

ESLint

Use flat config from eslint.config.js:

// CommonJS
module.exports = [
  ...require('@blgc/config/eslint/library'),
  {
    rules: {
      // local overrides
    }
  }
];
// ESM
import libraryConfig from '@blgc/config/eslint/library';

export default [
  ...libraryConfig,
  {
    rules: {
      // local overrides
    }
  }
];

Choose the preset by project type:

PresetAdds
@blgc/config/eslint/baseJavaScript, TypeScript, Turbo, warning mode, Prettier, ignores
@blgc/config/eslint/libraryThe base config for TypeScript package code
@blgc/config/eslint/reactBrowser globals, JSX parsing, ESLint React, React Hooks
@blgc/config/eslint/nextReact config, Next.js Core Web Vitals, Next.js build ignores
@blgc/config/eslint/tanstackReact config, TanStack build ignores, Vite env-var allowlisting

The base preset uses @eslint/js recommended rules, typescript-eslint strict rules, Turbo env-var warnings, generated/build artifact ignores, Node globals for config files, and Prettier compatibility. Shared rule findings report as warnings through eslint-plugin-only-warn; use eslint --max-warnings=0 in CI when a project is ready to enforce a clean result.

TypeScript

Extend the closest TypeScript config:

{
  "extends": "@blgc/config/typescript/library",
  "compilerOptions": {
    "outDir": "./dist",
    "rootDir": "./src",
    "declarationDir": "./dist/types"
  },
  "include": ["src"]
}

Available configs:

ConfigUse for
@blgc/config/typescript/baseShared strict base settings
@blgc/config/typescript/libraryBundled libraries without DOM APIs
@blgc/config/typescript/library-domLibraries that use DOM globals
@blgc/config/typescript/node20Node 20 packages and tools
@blgc/config/typescript/reactReact packages and Vite apps
@blgc/config/typescript/nextNext.js apps
@blgc/config/typescript/tanstackTanStack apps

Defaults to know: the base config uses ES2022, module: preserve, bundler module resolution, forced module detection, declaration output, declaration maps, skipLibCheck, and strict type checking. TypeScript unused checks stay off because ESLint owns unused diagnostics.

Use @blgc/config/typescript/library when a package emits JavaScript through a bundler and uses TypeScript for declaration emit. Use @blgc/config/typescript/node20 for Node packages or tools that emit JavaScript with tsc.

Vitest

Merge the shared Vitest node config when you want the default test setup:

import { nodeConfig } from '@blgc/config/vitest/node';
import { defineConfig, mergeConfig } from 'vitest/config';

export default mergeConfig(
  nodeConfig,
  defineConfig({
    test: {
      // project-specific test options
    }
  })
);

The node config sets the Node test environment, enables TypeScript path resolution, and uses text, JSON, and HTML coverage reporters.

FAQ

Do I need every peer tool installed?

No. Install the tools your project runs. For example, a package that only extends TypeScript config does not need ESLint, Prettier, or Vitest installed.

Can I override rules?

Yes. Add another config object after the shared config in eslint.config.js, add compilerOptions in tsconfig.json, or pass project-specific options to mergeConfig for Vitest.

Why does ESLint report warnings instead of failing?

The shared ESLint config is a guideline first. Rule findings report as warnings so humans and agents can see what to improve without blocking local work.

Use eslint --max-warnings=0 in CI or a package script when a project is ready to enforce a clean lint result.

Why are the shared config files CommonJS?

CommonJS keeps the config package usable from both CommonJS and ESM project configs. ESM projects can import CommonJS presets, but CommonJS projects cannot synchronously require() ESM presets.

Why does the React ESLint config use jiti?

@eslint-react/eslint-plugin is ESM-only. jiti lets the CommonJS ESLint presets load that plugin without forcing every consumer to migrate its eslint.config.js to ESM.

Why does the library TypeScript config use module preserve?

Most Builder Group packages let Rollup or esbuild emit JavaScript and let TypeScript emit declarations. module: preserve keeps TypeScript's import resolution closer to what those bundlers see. Node packages that emit JavaScript with tsc should use the Node preset or override compilerOptions.module.

Why not enable every strict TypeScript flag?

Flags like exactOptionalPropertyTypes, verbatimModuleSyntax, and erasableSyntaxOnly are useful migration targets, but they require source-level cleanup or disallow current enum patterns. Enable them locally once a project is ready for that stricter contract.

Why keep these configs in a package?

A package keeps defaults versioned, reviewable, and reusable. Projects can update one dependency instead of copying config changes by hand.

Credits

  • turbo-basic: base configuration patterns from Vercel's starter template
  • tsconfig/bases: TypeScript configuration references

版本与发布记录

@blgc/config 共发布 31 个版本,首次发布于 2024/08/02;过去 12 个月发布了 6 个版本。

版本发布日期距今
0.1.2latest2026/08/083 个月前
0.1.12026/07/283 个月前
0.1.02026/05/275 个月前
0.0.422026/05/046 个月前
0.0.412026/04/087 个月前
0.0.402026/01/159 个月前

关于 @blgc/config 的常见问题

@blgc/config 是什么?

Shared TypeScript, ESLint, Prettier, and Vitest configs for Builder Group projects

如何安装 @blgc/config?

在项目目录运行 npm install @blgc/config,或使用 pnpm add / yarn add / bun add。

@blgc/config 支持 TypeScript 吗?

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

@blgc/config 支持 ESM 还是 CommonJS?

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

@blgc/config 可以商用吗?

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

@blgc/config 的下载量有多少?

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

@blgc/config 还在维护吗?

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