Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

@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.4 (November 2026)

  • CI configuration only, no package changes — dependabot.yml takes the CLDMV/.github v4.47.0 groups, so the CLDMV dev tools arrive in one Dependabot PR (#111). The published package is the same as v1.2.3.
  • View full v1.2.4 Changelog

Recent Releases

  • v1.2.3 (November 2026) — the CommonJS entry is the generic CLDMV shim, with require() unchanged; the suite also runs against dist/; CI cancels superseded runs; dev toolchain on @cldmv/vitest-runner 1.11.3 (Changelog)
  • v1.2.2 (November 2026) — tooling release: tests run against src/ through the prettier-plugin-jsonv-dev condition via devCondition(), and the type scripts are split into types:check and types:build; formatting unchanged (Changelog)
  • 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)

📚 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

Option Type Default Description
jsonvYear number 2025 The year to use for JSONV features (2015-2025)
strictBigInt boolean false Whether 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:

Run Loads
node app.mjs dist/index.mjs (run npm run build first)
node --conditions=prettier-plugin-jsonv-dev app.mjs src/index.mjs
require() with --conditions=prettier-plugin-jsonv-dev src/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. npm run test:dist builds and runs the Vitest suite against dist/ instead.

License

GitHub license npm license

Apache-2.0 © Shinrai / CLDMV

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages