@cldmv/prettier-plugin-jsonv

中文文档
1.2.2发布于 2026/11/07Apache-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 4831

Prettier plugin for @cldmv/jsonv files

原始使用文档
文档目录12 节
  1. ✨ What's New
  2. Latest: v1.2.2 (November 2026)
  3. Recent Releases
  4. Features
  5. Installation
  6. Usage
  7. Using .prettierrc.mjs or prettier.config.mjs :
  8. Using .prettierrc.cjs or prettier.config.cjs :
  9. Configuration Options
  10. Trailing commas
  11. Development
  12. License

@cldmv/prettier-plugin-jsonv

npm version npm downloads GitHub downloads Last commit npm last update

Contributors Sponsor shinrai

A Prettier plugin for formatting JSONV files.

✨ What's New

Latest: v1.2.2 (November 2026)

  • Tooling release, no plugin changes — the vitest config now uses devCondition() from @cldmv/configs, so tests really run against src/ through the prettier-plugin-jsonv-dev export condition, and the type scripts are split into types:check and types:build (#91, #93). Formatting is unchanged.
  • View full v1.2.2 Changelog

Recent Releases

  • v1.2.1 (November 2026) — engines.node back to >=18.0.0; the 22.22.0 development floor moves to devEngines (#88) (Changelog)
  • v1.2.0 (November 2026) — CommonJS entry, tsup build and a prettier-plugin-jsonv-dev export condition; engines.node raised to >=22.22.0; formatting unchanged (#84, #85) (Changelog)
  • v1.1.4 (October 2026) — dev tooling on @cldmv/fix-headers 2.2.0 and @cldmv/configs 1.2.4; no file was restamped and no runtime change (#51, #54) (Changelog)
  • v1.1.3 (October 2026) — the CI ✅ Required PR Check mirror job runs on every path instead of being skipped on in-repo PRs (#49) (Changelog)

📚 For complete version history, see docs/changelog/ and the GitHub Releases.

Features

  • Formats .jsonv files using the @cldmv/jsonv parser
  • Supports all ES2015-2025 features (JSON5, binary/octal literals, BigInt, numeric separators, etc.)
  • Configurable year-based feature detection
  • Proper handling of comments and whitespace
  • Integrates with Prettier's configuration system

Installation

npm install --save-dev @cldmv/prettier-plugin-jsonv prettier @cldmv/jsonv

Usage

The plugin needs Node.js 18.0.0 or later and Prettier 3. It ships an ES module entry and a CommonJS entry, so it loads from either kind of Prettier config; require() needs Node.js ^20.19.0 or >=22.13.0.

Developing this package needs Node.js 22.22.0 or later (devEngines).

Using .prettierrc.mjs or prettier.config.mjs:

import jsonv from "@cldmv/prettier-plugin-jsonv";

export default {
    plugins: [jsonv],
    overrides: [
        {
            files: "*.jsonv",
            options: {
                jsonvYear: 2025,
                strictBigInt: false
            }
        }
    ]
};

Using .prettierrc.cjs or prettier.config.cjs:

module.exports = {
    plugins: [require("@cldmv/prettier-plugin-jsonv")],
    overrides: [
        {
            files: "*.jsonv",
            options: {
                jsonvYear: 2025,
                strictBigInt: false
            }
        }
    ]
};

require("@cldmv/prettier-plugin-jsonv") returns the plugin object itself. In a JSON .prettierrc, list the plugin by name instead: "plugins": ["@cldmv/prettier-plugin-jsonv"].

Configuration Options

OptionTypeDefaultDescription
jsonvYearnumber2025The year to use for JSONV features (2015-2025)
strictBigIntbooleanfalseWhether to enforce strict BigInt parsing

Trailing commas

The plugin honours Prettier's trailingComma option the way Prettier's JavaScript printer does for object and array literals:

  • "all" (Prettier's default) and "es5" put a comma after the last entry of every object or array that breaks across lines. Non-empty objects and arrays are always printed one entry per line, so only empty ones ({ }, []) are printed on a single line, and they never get a comma.
  • "none" never adds one.

Trailing commas already in the source are not kept as written: the option normalizes them, adding or removing the comma after the last entry. Every jsonv year (2011-2025) allows trailing commas, so the comma never makes a document invalid, and it never changes the parsed value. Comments next to the last entry stay in place: a: 1, // note keeps the comment after the comma, a: 1 /* note */, keeps it before.

Development

The published package contains only the built dist/ (dist/index.mjs, and dist/index.cjs for require()) plus the generated types/. In a checkout, the prettier-plugin-jsonv-dev export condition points the package at src/ instead:

RunLoads
node app.mjsdist/index.mjs (run npm run build first)
node --conditions=prettier-plugin-jsonv-dev app.mjssrc/index.mjs
require() with --conditions=prettier-plugin-jsonv-devsrc/index.cjs, which loads src/index.mjs

Set it once per shell with export NODE_OPTIONS=--conditions=prettier-plugin-jsonv-dev. npm test runs the Vitest suite against src/ with the condition, then builds and checks the CommonJS entry in dist/ with node --test.

License

GitHub license npm license

Apache-2.0 © Shinrai / CLDMV

版本与发布记录

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

版本发布日期距今
1.2.2latest2026/11/072 天前
1.2.12026/11/027 天前
1.2.02026/11/028 天前
1.1.42026/10/051 个月前
1.1.32026/10/031 个月前
1.1.22026/10/031 个月前

关于 @cldmv/prettier-plugin-jsonv 的常见问题

@cldmv/prettier-plugin-jsonv 是什么?

Prettier plugin for @cldmv/jsonv files

如何安装 @cldmv/prettier-plugin-jsonv?

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

@cldmv/prettier-plugin-jsonv 支持 TypeScript 吗?

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

@cldmv/prettier-plugin-jsonv 支持 ESM 还是 CommonJS?

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

@cldmv/prettier-plugin-jsonv 需要什么版本的 Node.js?

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

@cldmv/prettier-plugin-jsonv 可以商用吗?

@cldmv/prettier-plugin-jsonv 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@cldmv/prettier-plugin-jsonv 的下载量有多少?

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

@cldmv/prettier-plugin-jsonv 还在维护吗?

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