@coderize/config

中文文档
0.2.0发布于 2026/10/11UNLICENSEDES Module近 30 天下载 9776

Shared ESLint and Prettier config for CoderizeDEV repos

原始使用文档
文档目录5 节
  1. Prettier
  2. ESLint
  3. Astro <script> blocks and TypeScript
  4. Repo-specific rules
  5. Versions

@coderize/config

ESLint and Prettier config shared by the CoderizeDEV repos. One dependency replaces the plugins each repo used to carry, and one place to change the rules replaces 44 hand-edited copies.

pnpm add -D @coderize/config eslint prettier

Prettier

.prettierrc.json is one line:

"@coderize/config/prettier"

Two-space indent, single quotes, no semicolons, no trailing commas, 120 columns, LF. The Astro and Tailwind plugins are included and resolved from this package, so the repo does not install them.

ESLint

eslint.config.js spreads the config that matches the package:

import { astro } from '@coderize/config/eslint'

export default [...astro]
ExportForGlobals
astroAstro sites: .astro, .js, .mjsbrowser; Node for config files, scripts/, tests
reactVite + React apps, React islandsbrowser and Node
nodeFastify APIs, Lambdas, toolingNode

An Astro site with React islands uses both: export default [...astro, ...react].

Every config ignores dist, .astro, .turbo and infra/cloudfront* (CloudFront functions run in a restricted runtime that house style does not apply to). Every config lets _-prefixed variables, arguments and caught errors go unused.

Astro <script> blocks and TypeScript

astro lints frontmatter, markup and every <script> block. eslint-plugin-astro hands each script block to ESLint as a virtual file: Page.astro/1_1.js, or Page.astro/1_1.ts once it can resolve @typescript-eslint/parser or typescript-eslint from the directory ESLint runs in. Both are covered.

If a package's .astro files hold TypeScript (interface Props, el as HTMLElement), install the parser itself, with TypeScript held below 6.1, the newest version typescript-eslint supports:

pnpm add -D @typescript-eslint/parser typescript@~6.0.3

Install @typescript-eslint/parser, not only typescript-eslint. eslint-plugin-astro also uses that package to read define:vars. Without it, shorthand keys (define:vars={{ gtmId }}) are reported as no-undef; longhand keys (define:vars={{ gtmId: gtmId }}) avoid that.

The parser is picked up when ESLint runs in the package directory, as pnpm lint and turbo do. For an editor or a run from a monorepo root, wire it after the spread:

import tsParser from '@typescript-eslint/parser'
import { astro } from '@coderize/config/eslint'

export default [
  ...astro,
  {
    files: ['**/*.astro'],
    processor: 'astro/client-side-ts',
    languageOptions: { parserOptions: { parser: tsParser, extraFileExtensions: ['.astro'] } }
  },
  { files: ['**/*.astro/*.ts'], languageOptions: { parser: tsParser } }
]

Repo-specific rules

Add them after the spread. Flat config applies later blocks last, so they win:

import { astro, globals } from '@coderize/config/eslint'

export default [
  ...astro,
  // src/lib/site.js reads SITE_URL at build time
  { files: ['src/lib/site.js'], languageOptions: { globals: globals.node } }
]

Keep these for genuine one-offs. A rule that two repos want belongs in this package.

Versions

Semver from what a consuming repo feels: a patch changes nothing it can see, a minor relaxes a rule or adds an export, and a major can turn its CI red (a new error-level rule, a removed export). Renovate merges minors and patches by itself and holds majors for review.

Every release is staged on npm and goes live only once a maintainer approves it with 2FA, because Renovate carries it into every fleet repo.

版本与发布记录

@coderize/config 共发布 4 个版本,首次发布于 2026/10/10;过去 12 个月发布了 4 个版本。

版本发布日期距今
0.2.0latest2026/10/1130 天前
0.1.12026/10/101 个月前
0.1.02026/10/101 个月前
0.0.0-stage2026/10/101 个月前

关于 @coderize/config 的常见问题

@coderize/config 是什么?

Shared ESLint and Prettier config for CoderizeDEV repos

如何安装 @coderize/config?

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

@coderize/config 支持 TypeScript 吗?

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

@coderize/config 支持 ESM 还是 CommonJS?

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

@coderize/config 需要什么版本的 Node.js?

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

@coderize/config 可以商用吗?

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

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

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

@coderize/config 还在维护吗?

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