@cldmv/eslint-plugin-jsonv

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

ESLint plugin for @cldmv/jsonv files

原始使用文档
文档目录20 节
  1. ✨ What's New
  2. Latest: v1.1.2 (November 2026)
  3. Recent Releases
  4. Features
  5. Installation
  6. Building the Plugin
  7. Running from source
  8. Usage
  9. ESLint Flat Config (eslint.config.mjs)
  10. ESLint Flat Config (eslint.config.cjs)
  11. Configuration Options
  12. Inline Configuration
  13. Writing Rules
  14. Supported Features
  15. ES2011 (JSON5 Base)
  16. ES2015 (ES6)
  17. ES2020
  18. ES2021
  19. Example
  20. License

@cldmv/eslint-plugin-jsonv

npm version npm downloads GitHub downloads Last commit npm last update

Contributors Sponsor shinrai

ESLint plugin for validating .jsonv files using the @cldmv/jsonv parser.

✨ What's New

Latest: v1.1.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 eslint-plugin-jsonv-dev export condition, and the type scripts are split into types:check and types:build (#92, #94). No rule, language or option changed.
  • View full v1.1.2 Changelog

Recent Releases

  • v1.1.1 (November 2026) — engines.node back to the runtime range ^20.19.0 || ^22.13.0 || >=24; the 22.22.0 development floor moves to devEngines (#88) (Changelog)
  • v1.1.0 (November 2026) — plugin moved into src/, built with tsup, with a require() entry and an eslint-plugin-jsonv-dev export condition; engines.node narrowed to >=22.22.0 (#82, #83) (Changelog)
  • v1.0.17 (October 2026) — development dependencies only: eslint 10.12.0, vitest 5.0.3 and @cldmv/vitest-runner 1.5.3; no plugin code changed (#59, #60, #62, #64) (Changelog)
  • v1.0.16 (October 2026) — header tooling on @cldmv/fix-headers 2.2.0 and @cldmv/configs 1.2.4; no plugin code or runtime dependency changed (#54, #57) (Changelog)

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

Features

  • Syntax Validation: Validates jsonv syntax using the actual jsonv parser
  • ES2011-2025 Support: All JSON5, ES2015, ES2020, ES2021 features supported
  • Internal References: Validates bare identifiers, template interpolation, nested property access
  • BigInt Support: Validates BigInt literals and numeric separators
  • Accurate Error Reporting: Parse errors include line/column information
  • Configurable Parsing: Target ES year, parse mode, strict BigInt and octal checks, and internal reference resolution

Installation

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

Requirements: Node ^20.19.0 || ^22.13.0 || >=24 (the range the plugin's @eslint/core and @eslint/plugin-kit dependencies support) and ESLint ^9.13.0 || ^10.0.0 (the first ESLint release with defaultLanguageOptions support for plugin languages). require() needs Node.js ^20.19.0 or >=22.13.0, which that range already covers.

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

Note: This plugin requires @cldmv/jsonv as a peer dependency.

npm install @cldmv/jsonv

Building the Plugin

The source lives in src/: src/index.mjs is the plugin and src/index.cjs is the CommonJS entry. To build it:

npm install
npm run build

This will:

  1. Bundle src/index.mjs into dist/index.mjs with tsup
  2. Copy src/index.cjs unchanged to dist/index.cjs
  3. Generate type definitions into dist/index.d.mts

dist/ is not committed; npm pack and npm publish rebuild it.

Running from source

The package's "." export has an eslint-plugin-jsonv-dev condition that points at src/ instead of dist/. In a checkout, import or require of @cldmv/eslint-plugin-jsonv loads dist/ (so build first) unless the condition is set:

node --conditions=eslint-plugin-jsonv-dev app.mjs
# or once per shell
export NODE_OPTIONS=--conditions=eslint-plugin-jsonv-dev

The test suite sets the condition itself, so npm test runs against src/, then npm run test:dist builds and checks dist/.

Usage

ESLint Flat Config (eslint.config.mjs)

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

export default [
    {
        files: ["**/*.jsonv"],
        plugins: { jsonv },
        language: "jsonv/jsonv",
        extends: ["jsonv/recommended"]
    }
];

ESLint Flat Config (eslint.config.cjs)

The package also has a CommonJS entry, so a CommonJS config can require() it. require() returns the plugin object itself, the same object as the ESM default export. This needs a Node.js release with require(esm) support (^20.19.0 or >=22.13.0), which the supported Node range already guarantees.

const jsonv = require("@cldmv/eslint-plugin-jsonv");

module.exports = [
    {
        files: ["**/*.jsonv"],
        plugins: { jsonv },
        language: "jsonv/jsonv",
        extends: ["jsonv/recommended"]
    }
];

Configuration Options

languageOptions are passed to the @cldmv/jsonv parser (both parseWithOptions(), which reports errors, and parseToAst(), which builds the AST rules see). Every option is optional; the values below are the defaults:

{
  files: ["**/*.jsonv"],
  plugins: { jsonv },
  language: "jsonv/jsonv",
  languageOptions: {
    year: 2025,                    // Target ES year: which jsonv features are allowed
    mode: "jsonv",                 // Parse mode: "jsonv", "json5" or "json"
    strictBigInt: false,           // true: an unsafe integer needs the `n` suffix
    strictOctal: false,            // true: legacy `0755` octals are errors (use `0o755`)
    allowInternalReferences: true  // false: references are not resolved or checked
  }
}
OptionTypeAllowed valuesDefaultMeaning
yearnumber2011, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 20252025The target ES year. A feature introduced after it is an error: binary/octal literals and template literals need 2015, BigInt needs 2020, numeric separators need 2021.
modestring"jsonv", "json5", "json""jsonv"The parse mode. "jsonv" allows every jsonv feature of the selected year, "json5" is meant for JSON5 only and "json" for strict JSON. The plugin passes the mode through unchanged, so it enforces exactly what @cldmv/jsonv enforces: in @cldmv/jsonv 1.1.0, "json" rejects comments, and the other JSON and JSON5 restrictions are not enforced yet.
strictBigIntbooleantrue, falsefalseWhen true, an integer outside the safe range (±9007199254740991) without an n suffix is an error. When false, it is read as a BigInt.
strictOctalbooleantrue, falsefalseWhen true, a legacy octal literal such as 0755 is an error; 0o755 is still allowed.
allowInternalReferencesbooleantrue, falsetrueWhen true, internal references (backup: port, server.port, `${host}`) are resolved, and an undefined or circular reference is an error. When false, they are left unresolved and are not reported.

Any other key, or a value outside the allowed ones, is a configuration error (a TypeError naming the option).

Three @cldmv/jsonv parse options are deliberately not accepted:

  • reviver: a reviver only transforms the evaluated value, and linting does not use that value.
  • preserveComments: the AST always carries the comments, so inline eslint-disable comments and rules can see them.
  • tolerant: the plugin controls how parse errors are collected.

Inline Configuration

The usual ESLint comments work inside .jsonv files: // eslint-disable, /* eslint-disable <rule> */, /* eslint-enable */, // eslint-disable-line, // eslint-disable-next-line, and /* eslint <rule>: "off" */ rule configuration.

Writing Rules

The jsonv/jsonv language exposes the document as an AST built from @cldmv/jsonv's parseToAst(). Every node has a loc (1-based lines and columns) and a range, so reports on a node land on that node, and rules can use node types and selectors:

Node typeChildrenNotes
ProgrambodyThe document; body is the root value. comments and tokens hang off it.
ObjectExpressionproperties{ ... }
Propertykey, valuekey is a Literal (quoted or numeric key) or an Identifier (unquoted key).
ArrayExpressionelements[ ... ]
Literal—Strings, numbers, BigInt (bigint holds the digits), booleans, null, Infinity, NaN; raw is the source text.
Identifier—An unquoted key, or an internal reference such as backup: port.
MemberExpressionobject, propertyA dotted internal reference such as server.port.
TemplateLiteralquasis, expressionsA backtick string with ${...} interpolation (a plain backtick string is a Literal).
TemplateElement—A literal segment of a template.
// Report every string value containing "TODO", on the string itself
create(context) {
  return {
    "Property > Literal.value"(node) {
      if (typeof node.value === "string" && node.value.includes("TODO")) {
        context.report({ node, message: "Unexpected TODO." });
      }
    }
  };
}

Supported Features

ES2011 (JSON5 Base)

  • Single-line (//) and multi-line (/* */) comments
  • Trailing commas in objects and arrays
  • Unquoted object keys
  • Single-quoted strings
  • Hexadecimal number literals (0xFF)
  • Leading/trailing decimal points (.5, 5.)
  • Explicit positive sign (+5)
  • Infinity, -Infinity, NaN
  • Multi-line strings with backslash continuation
  • Internal references via bare identifiers: { port: 8080, backup: port }

ES2015 (ES6)

  • Binary literals (0b1010)
  • Octal literals (0o755, also legacy 0755)
  • Template literals (backtick strings)
  • Template interpolation for internal refs: url: `http://${host}:${port}`

ES2020

  • BigInt literals (9007199254740992n)
  • BigInt in hex/binary/octal formats

ES2021

  • Numeric separators (1_000_000, 0xFF_AA, 0b1111_0000)

Example

config.jsonv:

{
  // Server configuration with internal references
  host: "localhost",
  port: 8080,
  
  // Template interpolation
  url: `http://${host}:${port}`,
  
  // ES2021 numeric separators
  maxConnections: 1_000_000,
  
  // ES2020 BigInt
  userId: 9007199254740993n,
  
  // ES2015 binary flags
  permissions: 0b1111_0000,
  
  // Nested reference
  monitoring: {
    healthCheck: url
  }
}

License

GitHub license npm license

Apache-2.0 © Shinrai / CLDMV

版本与发布记录

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

版本发布日期距今
1.1.2latest2026/11/072 天前
1.1.12026/11/027 天前
1.1.02026/11/028 天前
1.0.172026/10/1228 天前
1.0.162026/10/051 个月前
1.0.152026/10/031 个月前

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

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

ESLint plugin for @cldmv/jsonv files

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

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

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

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

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

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

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

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

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

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

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

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

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

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