@climatiq/oxc-presets

中文文档
2.1.0发布于 2026/10/22MITTypeScriptES Module构建来源已验证近 30 天下载 1736

Oxc onfiguration (oxlint, oxfmt) for Climatiq projects

原始使用文档
文档目录9 节
  1. Installation
  2. Usage
  3. Oxlint
  4. Oxfmt
  5. What's Included
  6. Oxlint
  7. Oxfmt
  8. License
  9. Release process

Climatiq Oxc Config Presets

This package provides Climatiq's oxlint & oxfmt configuration as a base config for any project in Climatiq. It includes configurations for React, Next.js, TypeScript, etc.

Installation

npm install --save-dev @climatiq/oxc-presets

or with yarn:

yarn add --dev @climatiq/oxc-presets

or with pnpm:

pnpm add -D @climatiq/oxc-presets

Usage

Oxlint

Install Oxlint alongside this package (it is listed in peerDependencies), as well as oxlint-tsgolint for type-aware linting.

The clsx/cn rules ship with this package as an Oxlint JS plugin, so there is nothing else to install for them — see lint-rules/.

Create an .oxlintrc.json file in your project root with the following content:

{
    "$schema": "./node_modules/oxlint/configuration_schema.json",
    "extends": ["./node_modules/@climatiq/oxc-presets/oxlint-config.json"],
}

If you want to opt-out of type-aware linting, don't install oxlint-tsgolint and add the following to your oxlint config:

{
    "$schema": "./node_modules/oxlint/configuration_schema.json",
    "extends": ["./node_modules/@climatiq/oxc-presets/oxlint-config.json"],
    "options": {
        "typeAware": false,
    },
}

Oxfmt

Install Oxfmt alongside this package (it is listed in peerDependencies).

The @climatiq/oxc-presets/oxfmt entry resolves to a plain .js preset (this package uses "type": "module") so Node does not need to strip TypeScript from files under node_modules when you extend it.

Create an oxfmt.config.ts file in your project root:

import { defineConfig } from 'oxfmt';
import climatiqOxfmt from '@climatiq/oxc-presets/oxfmt';

export default defineConfig({
    ...climatiqOxfmt,
    printWidth: 100,
    // or any other overrides
});

Oxfmt does not have an extends field; spreading the preset and setting any top-level option afterward is how you override it (same idea for ignorePatterns: spread climatiqOxfmt.ignorePatterns and append paths).

What's Included

Oxlint

The Oxlint config includes:

  • Next.js rules
  • React rules
  • TypeScript rules
  • clsx/cn rules, bundled as an Oxlint JS plugin — see lint-rules/
  • Unused imports detection and auto-removal
  • Sensible defaults for TypeScript projects

clsx/cn rules

The clsx/* rules are copied from eslint-plugin-clsx (MIT) and converted to Oxlint's JS plugin API, so consumers do not need eslint-plugin-clsx installed. Which modules count as clsx is configured through settings.clsxOptions; this preset ships with:

{
    "settings": {
        "clsxOptions": {
            "clsx": ["default", "clsx"],
            "classnames": ["default"],
            "@/src/lib/utils": ["cn"],
        },
    },
}

Oxlint does not currently inherit settings through extends, so the same map is also the plugin's built-in default: clsx, classnames and cn are covered out of the box, with no configuration on your side. Add your own settings.clsxOptions block only if your cn helper lives somewhere else — note that it replaces the default rather than extending it, so re-list clsx and classnames if you still want them covered.

Full rule documentation is in lint-rules/index.md.

Oxfmt

The Oxfmt config includes:

  • 1 Indentation = 4 spaces
  • single-quotes
  • semis
  • trailing commas
  • Sorting for Tailwind classes enabled

License

MIT

Release process

To publish a new release, just create a new Release on the GitHub Repo Releases page with the new version.

The GitHub Actions workflow release.yaml will tag the new version and publish it to npm.

Therefore, the version in the package.json does not necessarily reflect the current version of the package.

版本与发布记录

@climatiq/oxc-presets 共发布 4 个版本,首次发布于 2026/08/04;过去 12 个月发布了 4 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.1.0latest2026/10/2218 天前
2.0.02026/09/072 个月前
1.0.02026/08/043 个月前
0.1.02026/08/043 个月前

关于 @climatiq/oxc-presets 的常见问题

@climatiq/oxc-presets 是什么?

Oxc onfiguration (oxlint, oxfmt) for Climatiq projects

如何安装 @climatiq/oxc-presets?

在项目目录运行 npm install @climatiq/oxc-presets,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:oxfmt(>=0.45.0 <1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@climatiq/oxc-presets 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@climatiq/oxc-presets 支持 ESM 还是 CommonJS?

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

@climatiq/oxc-presets 需要什么版本的 Node.js?

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

@climatiq/oxc-presets 可以商用吗?

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

@climatiq/oxc-presets 的下载量有多少?

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

@climatiq/oxc-presets 还在维护吗?

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