@charlie-labs/config

中文文档
0.0.17发布于 2025/11/22MITES Module构建来源已验证近 30 天下载 3752

Shared config for Charlie Lab's TypeScript projects

原始使用文档
文档目录8 节
  1. Usage
  2. 1. Add Dependency
  3. 2. Configure Prettier
  4. 3. Configure ESLint
  5. 4. Configure TypeScript
  6. 5. Add TypeScript Reset
  7. Releasing & publishing
  8. npm auth for the GitHub workflow

@charlie-labs/config

Standardized TypeScript, ESLint, and Prettier configuration for Charlie Lab's TypeScript projects.

Why does this exist?

  1. Consistent and familiar configuration across Charlie Labs projects
  2. Reduces configuration boilerplate in each project
  3. Reduces time spent keeping configuration updated and in sync

Usage

1. Add Dependency

Install @charlie-labs/config as a dev dependency.

2. Configure Prettier

Add the following line to your package.json:

  "prettier": "@charlie-labs/config/prettier",

3. Configure ESLint

Create a eslint.config.js file in the root of the project:

import { config } from '@charlie-labs/config/eslint';

/** @type {import("eslint").Linter.Config[]} */
export default [...config];

4. Configure TypeScript

Create a tsconfig.json file in the root that extends @charlie-labs/config/tsconfig-node or @charlie-labs/config/tsconfig-react. You will still need to specify includes and any compilerOptions you want to add or override.

{
  "extends": "@charlie-labs/config/tsconfig-node",
  "include": ["src"],
  "exclude": ["**/node_modules", "**/.*/"],
  "compilerOptions": {
    // Add or override compiler options here
  },
}

5. Add TypeScript Reset

This is just a convenient export of @total-typescript/ts-reset.

Releasing & publishing

This repo is set up to auto-publish to npm on merge to the default branch (currently master) via GitHub Actions. You only need to bump the version and merge a PR.

  1. Create a branch and bump the version in package.json without creating a git tag:

    # pick one: patch | minor | major | or an explicit version
    npm version patch --no-git-tag-version
    # or: npm version 0.0.13 --no-git-tag-version
    
  2. Commit the change and open a PR. Keep the PR limited to the version bump and any release notes you want in the description.

  3. When the PR is merged to the default branch, the workflow at .github/workflows/release.yml will:

    • run typecheck and ESLint
    • publish to npm if the version is new (requires NPM_TOKEN)
    • create a GitHub Release with generated notes

Notes:

  • Don’t push git tags manually; the workflow creates the tag during the GitHub Release step.
  • If no new version is present (i.e., package.json didn’t change), the publish step is skipped and no release is created.
  • The publish step skips npm lifecycle scripts; typecheck and lint run explicitly in the workflow.

npm auth for the GitHub workflow

To publish to npm from GitHub Actions, add an npm access token as a secret named NPM_TOKEN:

  1. Create an npm access token with at least “Publish” permission in your npm account settings.
  2. In this repository’s Settings → Secrets and variables → Actions, add a new Repository secret named NPM_TOKEN with that token’s value. An Organization secret works too.
  3. Nothing else is required—our release workflow already:
    • requests id-token: write for npm provenance support, and
    • uses actions/setup-node@v4 to provide a recent npm version during publish.

If your org enforces “Require provenance” on npm, the existing provenance: true input on the publish step satisfies it.

版本与发布记录

@charlie-labs/config 共发布 7 个版本,首次发布于 2025/09/19;过去 12 个月发布了 1 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.0.17latest2025/11/2211 个月前
0.0.162025/11/031 年前
0.0.152025/09/201.1 年前
0.0.142025/09/201.1 年前
0.0.132025/09/191.1 年前
0.0.122025/09/191.1 年前

关于 @charlie-labs/config 的常见问题

@charlie-labs/config 是什么?

Shared config for Charlie Lab's TypeScript projects

如何安装 @charlie-labs/config?

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

@charlie-labs/config 支持 TypeScript 吗?

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

@charlie-labs/config 支持 ESM 还是 CommonJS?

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

@charlie-labs/config 可以商用吗?

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

@charlie-labs/config 的下载量有多少?

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

@charlie-labs/config 还在维护吗?

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