@cldmv/eslint-plugin-jsonv 1.0.12 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,17 +8,19 @@ ESLint plugin for validating `.jsonv` files using the [@cldmv/jsonv](https://git
8
8
 
9
9
  ## ✨ What's New
10
10
 
11
- ### Latest: v1.0.12 (September 2026)
11
+ ### Latest: v1.0.13 (September 2026)
12
12
 
13
- - **A real ESLint AST for `.jsonv` files** — the `jsonv/jsonv` language now builds a positioned AST from `@cldmv/jsonv`'s `parseToAst()` instead of an empty `Program`. Rules can select objects, arrays, properties, literals, references and templates; reports land on the node they target instead of `1:0`; and inline `eslint-disable` / `eslint-enable` / `eslint-disable-next-line` comments now work. Requires `@cldmv/jsonv` 1.1.0 or later (#26).
14
- - [View full v1.0.12 Changelog](https://github.com/CLDMV/jsonv-eslint-plugin-jsonv/blob/master/docs/changelog/v1/v1.0.12.md)
13
+ - **Published types describe a real ESLint plugin** — `dist/index.d.mts` typed the default export as a bare `Object`; it now types the plugin, the `jsonv/jsonv` language, `JsonvSourceCode` and every AST node against `@eslint/core`'s generics, checked in CI by a new `test:types` script, alongside a declared `engines.node` and `eslint` peer range that finally match what the runtime dependencies require (#30, #37, fixes #28, #32).
14
+ - **Three more language options** — `mode` (`"jsonv"`, `"json5"` or `"json"`), `strictOctal` and `allowInternalReferences` are now accepted, validated and forwarded to `@cldmv/jsonv`, matching what the README already documented (#39, fixes #34).
15
+ - **CLDMV lint/format tooling** — `lint`, `lint:fix`, `format` and `format:check` scripts, a pre-commit hook and the org's shared ESLint/Prettier config land, and the repository is reformatted repo-wide (#38, fixes #33).
16
+ - [View full v1.0.13 Changelog](https://github.com/CLDMV/jsonv-eslint-plugin-jsonv/blob/master/docs/changelog/v1/v1.0.13.md)
15
17
 
16
18
  ### Recent Releases
17
19
 
20
+ - **v1.0.12** (September 2026) — the `jsonv/jsonv` language builds a real ESLint AST from `@cldmv/jsonv`'s `parseToAst()`, so rules can select nodes and inline `eslint-disable` comments work (#26) ([Changelog](https://github.com/CLDMV/jsonv-eslint-plugin-jsonv/blob/master/docs/changelog/v1/v1.0.12.md))
18
21
  - **v1.0.11** (September 2026) — language options are validated, parse errors report at their real position, and the plugin gained a vitest suite with a CI coverage badge (#16, #17, #18, #23, #24) ([Changelog](https://github.com/CLDMV/jsonv-eslint-plugin-jsonv/blob/master/docs/changelog/v1/v1.0.11.md))
19
22
  - **v1.0.10** (September 2026) — the README links back to the jsonv repo (#15) ([Changelog](https://github.com/CLDMV/jsonv-eslint-plugin-jsonv/blob/master/docs/changelog/v1/v1.0.10.md))
20
23
  - **v1.0.9** (September 2026) — corrected package name, badge row and license badges (#12) ([Changelog](https://github.com/CLDMV/jsonv-eslint-plugin-jsonv/blob/master/docs/changelog/v1/v1.0.9.md))
21
- - **v1.0.8** (September 2026) — Node CI matrix updated for vitest 5 (max Node 26, min Node 22.12.0) (#10) ([Changelog](https://github.com/CLDMV/jsonv-eslint-plugin-jsonv/blob/master/docs/changelog/v1/v1.0.8.md))
22
24
 
23
25
  📚 **For complete version history, see [docs/changelog/](https://github.com/CLDMV/jsonv-eslint-plugin-jsonv/tree/master/docs/changelog/) and the [GitHub Releases](https://github.com/CLDMV/jsonv-eslint-plugin-jsonv/releases).**
24
26
 
@@ -29,7 +31,7 @@ ESLint plugin for validating `.jsonv` files using the [@cldmv/jsonv](https://git
29
31
  - **Internal References**: Validates bare identifiers, template interpolation, nested property access
30
32
  - **BigInt Support**: Validates BigInt literals and numeric separators
31
33
  - **Accurate Error Reporting**: Parse errors include line/column information
32
- - **Year-Based Features**: Configurable target ES year for feature detection
34
+ - **Configurable Parsing**: Target ES year, parse mode, strict BigInt and octal checks, and internal reference resolution
33
35
 
34
36
  ## Installation
35
37
 
@@ -37,6 +39,8 @@ ESLint plugin for validating `.jsonv` files using the [@cldmv/jsonv](https://git
37
39
  npm install --save-dev @cldmv/eslint-plugin-jsonv
38
40
  ```
39
41
 
42
+ **Requirements:** Node `^20.19.0 || ^22.13.0 || >=24` and ESLint `^9.13.0 || ^10.0.0` (the first ESLint release with `defaultLanguageOptions` support for plugin `languages`; the plugin's `@eslint/plugin-kit` and `@eslint/core` dependencies also need that Node floor).
43
+
40
44
  **Note:** This plugin requires `@cldmv/jsonv` as a peer dependency.
41
45
 
42
46
  ```bash
@@ -53,6 +57,7 @@ npm run build
53
57
  ```
54
58
 
55
59
  This will:
60
+
56
61
  1. Copy `index.mjs` into `dist/index.mjs`
57
62
  2. Generate type definitions into `dist/index.d.mts`
58
63
  3. Prepare the plugin for use
@@ -62,21 +67,21 @@ This will:
62
67
  ### ESLint Flat Config (eslint.config.mjs)
63
68
 
64
69
  ```javascript
65
- import jsonv from '@cldmv/eslint-plugin-jsonv';
70
+ import jsonv from "@cldmv/eslint-plugin-jsonv";
66
71
 
67
72
  export default [
68
- {
69
- files: ["**/*.jsonv"],
70
- plugins: { jsonv },
71
- language: "jsonv/jsonv",
72
- extends: ["jsonv/recommended"]
73
- }
73
+ {
74
+ files: ["**/*.jsonv"],
75
+ plugins: { jsonv },
76
+ language: "jsonv/jsonv",
77
+ extends: ["jsonv/recommended"]
78
+ }
74
79
  ];
75
80
  ```
76
81
 
77
82
  ### Configuration Options
78
83
 
79
- The parser supports the following options:
84
+ `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:
80
85
 
81
86
  ```javascript
82
87
  {
@@ -84,13 +89,31 @@ The parser supports the following options:
84
89
  plugins: { jsonv },
85
90
  language: "jsonv/jsonv",
86
91
  languageOptions: {
87
- year: 2025, // Target ES year (2011, 2015, 2020, 2021, 2022-2025)
88
- strictBigInt: false, // Require 'n' suffix for large integers
89
- mode: "jsonv" // Parse mode: "jsonv", "json5", "json"
92
+ year: 2025, // Target ES year: which jsonv features are allowed
93
+ mode: "jsonv", // Parse mode: "jsonv", "json5" or "json"
94
+ strictBigInt: false, // true: an unsafe integer needs the `n` suffix
95
+ strictOctal: false, // true: legacy `0755` octals are errors (use `0o755`)
96
+ allowInternalReferences: true // false: references are not resolved or checked
90
97
  }
91
98
  }
92
99
  ```
93
100
 
101
+ | Option | Type | Allowed values | Default | Meaning |
102
+ | ------------------------- | ------- | ---------------------------------------------------------------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
103
+ | `year` | number | `2011`, `2015`, `2016`, `2017`, `2018`, `2019`, `2020`, `2021`, `2022`, `2023`, `2024`, `2025` | `2025` | The 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. |
104
+ | `mode` | string | `"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. |
105
+ | `strictBigInt` | boolean | `true`, `false` | `false` | When `true`, an integer outside the safe range (±9007199254740991) without an `n` suffix is an error. When `false`, it is read as a BigInt. |
106
+ | `strictOctal` | boolean | `true`, `false` | `false` | When `true`, a legacy octal literal such as `0755` is an error; `0o755` is still allowed. |
107
+ | `allowInternalReferences` | boolean | `true`, `false` | `true` | When `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. |
108
+
109
+ Any other key, or a value outside the allowed ones, is a configuration error (a `TypeError` naming the option).
110
+
111
+ Three `@cldmv/jsonv` parse options are deliberately not accepted:
112
+
113
+ - `reviver`: a reviver only transforms the evaluated value, and linting does not use that value.
114
+ - `preserveComments`: the AST always carries the comments, so inline `eslint-disable` comments and rules can see them.
115
+ - `tolerant`: the plugin controls how parse errors are collected.
116
+
94
117
  ### Inline Configuration
95
118
 
96
119
  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.
@@ -99,17 +122,17 @@ The usual ESLint comments work inside `.jsonv` files: `// eslint-disable`, `/* e
99
122
 
100
123
  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:
101
124
 
102
- | Node type | Children | Notes |
103
- |---|---|---|
104
- | `Program` | `body` | The document; `body` is the root value. `comments` and `tokens` hang off it. |
105
- | `ObjectExpression` | `properties` | `{ ... }` |
106
- | `Property` | `key`, `value` | `key` is a `Literal` (quoted or numeric key) or an `Identifier` (unquoted key). |
107
- | `ArrayExpression` | `elements` | `[ ... ]` |
108
- | `Literal` | — | Strings, numbers, BigInt (`bigint` holds the digits), booleans, `null`, `Infinity`, `NaN`; `raw` is the source text. |
109
- | `Identifier` | — | An unquoted key, or an internal reference such as `backup: port`. |
110
- | `MemberExpression` | `object`, `property` | A dotted internal reference such as `server.port`. |
111
- | `TemplateLiteral` | `quasis`, `expressions` | A backtick string with `${...}` interpolation (a plain backtick string is a `Literal`). |
112
- | `TemplateElement` | — | A literal segment of a template. |
125
+ | Node type | Children | Notes |
126
+ | ------------------ | ----------------------- | -------------------------------------------------------------------------------------------------------------------- |
127
+ | `Program` | `body` | The document; `body` is the root value. `comments` and `tokens` hang off it. |
128
+ | `ObjectExpression` | `properties` | `{ ... }` |
129
+ | `Property` | `key`, `value` | `key` is a `Literal` (quoted or numeric key) or an `Identifier` (unquoted key). |
130
+ | `ArrayExpression` | `elements` | `[ ... ]` |
131
+ | `Literal` | — | Strings, numbers, BigInt (`bigint` holds the digits), booleans, `null`, `Infinity`, `NaN`; `raw` is the source text. |
132
+ | `Identifier` | — | An unquoted key, or an internal reference such as `backup: port`. |
133
+ | `MemberExpression` | `object`, `property` | A dotted internal reference such as `server.port`. |
134
+ | `TemplateLiteral` | `quasis`, `expressions` | A backtick string with `${...}` interpolation (a plain backtick string is a `Literal`). |
135
+ | `TemplateElement` | — | A literal segment of a template. |
113
136
 
114
137
  ```javascript
115
138
  // Report every string value containing "TODO", on the string itself
@@ -127,6 +150,7 @@ create(context) {
127
150
  ## Supported Features
128
151
 
129
152
  ### ES2011 (JSON5 Base)
153
+
130
154
  - Single-line (`//`) and multi-line (`/* */`) comments
131
155
  - Trailing commas in objects and arrays
132
156
  - Unquoted object keys
@@ -139,21 +163,27 @@ create(context) {
139
163
  - **Internal references via bare identifiers**: `{ port: 8080, backup: port }`
140
164
 
141
165
  ### ES2015 (ES6)
166
+
142
167
  - Binary literals (`0b1010`)
143
168
  - Octal literals (`0o755`, also legacy `0755`)
144
169
  - Template literals (backtick strings)
145
170
  - **Template interpolation for internal refs**: `` url: `http://${host}:${port}` ``
146
171
 
147
172
  ### ES2020
173
+
148
174
  - BigInt literals (`9007199254740992n`)
149
175
  - BigInt in hex/binary/octal formats
150
176
 
151
177
  ### ES2021
178
+
152
179
  - Numeric separators (`1_000_000`, `0xFF_AA`, `0b1111_0000`)
153
180
 
154
181
  ## Example
155
182
 
156
183
  **config.jsonv:**
184
+
185
+ <!-- @cldmv/prettier-plugin-jsonv 1.0.6 rewrites this block destructively (keys become "[object Object]", comments and numeric formats are lost), so prettier leaves it verbatim. -->
186
+ <!-- prettier-ignore -->
157
187
  ```jsonv
158
188
  {
159
189
  // Server configuration with internal references
package/dist/index.d.mts CHANGED
@@ -1,40 +1,427 @@
1
1
  /**
2
- * @fileoverview ESLint plugin for @cldmv/jsonv files
3
- * @module eslint-plugin-jsonv
4
- * @public
5
- *
6
- * @description
7
- * Custom ESLint plugin for validating .jsonv files using the @cldmv/jsonv parser.
8
- * Provides language definition, parser, and recommended rules for jsonv files.
9
2
  *
10
- * Features:
11
- * - Validates jsonv syntax using the actual jsonv parser
12
- * - Reports parse errors with accurate source locations
13
- * - Supports all ES2011-2025 features (JSON5, binary/octal literals, BigInt, numeric separators, etc.)
14
- * - Detects internal reference errors (circular refs, undefined refs)
15
- * - Configurable year-based feature detection
16
- * - Exposes a positioned AST (objects, arrays, properties, literals, references, templates),
17
- * comments and tokens, so rules can select nodes and inline `eslint-disable` comments work
3
+ * @Project: @cldmv/eslint-plugin-jsonv
4
+ * @Filename: /index.mjs
5
+ * @Date: 2026-01-18T20:55:56-08:00 (1768798556)
6
+ * @Author: Nate Corcoran <CLDMV>
7
+ * @Email: <Shinrai@users.noreply.github.com>
8
+ * -----
9
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
10
+ * @Last modified time: 2026-10-02T12:15:39-07:00 (1790968539)
11
+ * -----
12
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
18
13
  *
19
- * @example
20
- * // In eslint.config.mjs
21
- * import jsonv from 'eslint-plugin-jsonv';
14
+ */
15
+ import { Directive, TextSourceCodeBase, VisitNodeStep } from "@eslint/plugin-kit";
16
+ import type { FileProblem, Language, OkParseResult, ParseResult, RulesConfig, RuleVisitor, SourceLocation, SourceRange } from "@eslint/core";
17
+ import type { CustomRuleDefinitionType, CustomRuleTypeDefinitions, CustomRuleVisitorWithExit } from "@eslint/plugin-kit";
18
+ import type { TokenType } from "@cldmv/jsonv/parser";
19
+ export type JsonvYear = 2011 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025;
20
+ export type JsonvMode = "jsonv" | "json5" | "json";
21
+ export type JsonvLanguageOptions = {
22
+ /**
23
+ * The ES year whose jsonv features are allowed. Defaults to `2025`.
24
+ */
25
+ year?: JsonvYear;
26
+ /**
27
+ * The parse mode. Defaults to `"jsonv"`.
28
+ */
29
+ mode?: JsonvMode;
30
+ /**
31
+ * When `true`, an integer outside the safe range without an `n` suffix is an error instead of
32
+ * being converted to a BigInt. Defaults to `false`.
33
+ */
34
+ strictBigInt?: boolean;
35
+ /**
36
+ * When `true`, a legacy octal literal such as `0755` is an error (`0o755` is still allowed).
37
+ * Defaults to `false`.
38
+ */
39
+ strictOctal?: boolean;
40
+ /**
41
+ * When `false`, internal references are left unresolved, so an undefined or
42
+ * circular reference is no longer reported. Defaults to `true`.
43
+ */
44
+ allowInternalReferences?: boolean;
45
+ };
46
+ export type JsonvLiteral = {
47
+ /**
48
+ * The node type.
49
+ */
50
+ type: "Literal";
51
+ /**
52
+ * The evaluated value.
53
+ */
54
+ value: string | number | bigint | boolean | null;
55
+ /**
56
+ * The source text.
57
+ */
58
+ raw: string;
59
+ /**
60
+ * The BigInt digits, for a BigInt literal.
61
+ */
62
+ bigint?: string;
63
+ /**
64
+ * The location (1-based lines and columns).
65
+ */
66
+ loc: SourceLocation;
67
+ /**
68
+ * The `[start, end)` source offsets.
69
+ */
70
+ range: SourceRange;
71
+ };
72
+ export type JsonvIdentifier = {
73
+ /**
74
+ * The node type.
75
+ */
76
+ type: "Identifier";
77
+ /**
78
+ * The identifier text.
79
+ */
80
+ name: string;
81
+ /**
82
+ * The location (1-based lines and columns).
83
+ */
84
+ loc: SourceLocation;
85
+ /**
86
+ * The `[start, end)` source offsets.
87
+ */
88
+ range: SourceRange;
89
+ };
90
+ export type JsonvObjectExpression = {
91
+ /**
92
+ * The node type.
93
+ */
94
+ type: "ObjectExpression";
95
+ /**
96
+ * The properties, in source order.
97
+ */
98
+ properties: JsonvProperty[];
99
+ /**
100
+ * The location (1-based lines and columns).
101
+ */
102
+ loc: SourceLocation;
103
+ /**
104
+ * The `[start, end)` source offsets.
105
+ */
106
+ range: SourceRange;
107
+ };
108
+ export type JsonvProperty = {
109
+ /**
110
+ * The node type.
111
+ */
112
+ type: "Property";
113
+ /**
114
+ * The key.
115
+ */
116
+ key: JsonvLiteral | JsonvIdentifier;
117
+ /**
118
+ * The value.
119
+ */
120
+ value: JsonvExpression;
121
+ /**
122
+ * Always `false` in jsonv.
123
+ */
124
+ computed: boolean;
125
+ /**
126
+ * The location (1-based lines and columns).
127
+ */
128
+ loc: SourceLocation;
129
+ /**
130
+ * The `[start, end)` source offsets.
131
+ */
132
+ range: SourceRange;
133
+ };
134
+ export type JsonvArrayExpression = {
135
+ /**
136
+ * The node type.
137
+ */
138
+ type: "ArrayExpression";
139
+ /**
140
+ * The elements, in source order.
141
+ */
142
+ elements: JsonvExpression[];
143
+ /**
144
+ * The location (1-based lines and columns).
145
+ */
146
+ loc: SourceLocation;
147
+ /**
148
+ * The `[start, end)` source offsets.
149
+ */
150
+ range: SourceRange;
151
+ };
152
+ export type JsonvMemberExpression = {
153
+ /**
154
+ * The node type.
155
+ */
156
+ type: "MemberExpression";
157
+ /**
158
+ * The object being accessed.
159
+ */
160
+ object: JsonvExpression;
161
+ /**
162
+ * The accessed property.
163
+ */
164
+ property: JsonvIdentifier;
165
+ /**
166
+ * Always `false`.
167
+ */
168
+ computed: false;
169
+ /**
170
+ * The location (1-based lines and columns).
171
+ */
172
+ loc: SourceLocation;
173
+ /**
174
+ * The `[start, end)` source offsets.
175
+ */
176
+ range: SourceRange;
177
+ };
178
+ export type JsonvTemplateElement = {
179
+ /**
180
+ * The node type.
181
+ */
182
+ type: "TemplateElement";
183
+ /**
184
+ * The raw and cooked segment text.
185
+ */
186
+ value: {
187
+ raw: string;
188
+ cooked: string;
189
+ };
190
+ /**
191
+ * Whether this is the last segment.
192
+ */
193
+ tail: boolean;
194
+ /**
195
+ * The location (1-based lines and columns).
196
+ */
197
+ loc: SourceLocation;
198
+ /**
199
+ * The `[start, end)` source offsets.
200
+ */
201
+ range: SourceRange;
202
+ };
203
+ export type JsonvTemplateLiteral = {
204
+ /**
205
+ * The node type.
206
+ */
207
+ type: "TemplateLiteral";
208
+ /**
209
+ * The string segments.
210
+ */
211
+ quasis: JsonvTemplateElement[];
212
+ /**
213
+ * The interpolated expressions.
214
+ */
215
+ expressions: JsonvExpression[];
216
+ /**
217
+ * The location (1-based lines and columns).
218
+ */
219
+ loc: SourceLocation;
220
+ /**
221
+ * The `[start, end)` source offsets.
222
+ */
223
+ range: SourceRange;
224
+ };
225
+ export type JsonvExpression = JsonvLiteral | JsonvObjectExpression | JsonvArrayExpression | JsonvIdentifier | JsonvTemplateLiteral | JsonvMemberExpression;
226
+ export type JsonvComment = {
227
+ /**
228
+ * The comment kind.
229
+ */
230
+ type: "Line" | "Block";
231
+ /**
232
+ * The comment text without its delimiters.
233
+ */
234
+ value: string;
235
+ /**
236
+ * The location (1-based lines and columns).
237
+ */
238
+ loc: SourceLocation;
239
+ /**
240
+ * The `[start, end)` source offsets.
241
+ */
242
+ range: SourceRange;
243
+ };
244
+ export type JsonvToken = {
245
+ /**
246
+ * The token type, e.g. `"{"`, `"String"`, `"Identifier"`, `"TemplateHead"`.
247
+ */
248
+ type: `${TokenType}`;
249
+ /**
250
+ * The token's value.
251
+ */
252
+ value: string | number | bigint | boolean | null;
253
+ /**
254
+ * The source text.
255
+ */
256
+ raw: string;
257
+ /**
258
+ * The location (1-based lines and columns).
259
+ */
260
+ loc: SourceLocation;
261
+ /**
262
+ * The `[start, end)` source offsets.
263
+ */
264
+ range: SourceRange;
265
+ };
266
+ export type JsonvProgram = {
267
+ /**
268
+ * The node type.
269
+ */
270
+ type: "Program";
271
+ /**
272
+ * The root value.
273
+ */
274
+ body: JsonvExpression;
275
+ /**
276
+ * The comments.
277
+ */
278
+ comments: JsonvComment[];
279
+ /**
280
+ * The tokens, excluding comments.
281
+ */
282
+ tokens: JsonvToken[];
283
+ /**
284
+ * The location of the whole document (1-based lines and columns).
285
+ */
286
+ loc: SourceLocation;
287
+ /**
288
+ * The `[start, end)` source offsets of the whole document.
289
+ */
290
+ range: SourceRange;
291
+ };
292
+ export type JsonvNode = JsonvProgram | JsonvExpression | JsonvProperty | JsonvTemplateElement;
293
+ export type JsonvSyntaxElement = JsonvNode | JsonvToken | JsonvComment;
294
+ export type JsonvLanguage = Language<{
295
+ LangOptions: JsonvLanguageOptions;
296
+ Code: JsonvSourceCode;
297
+ RootNode: JsonvProgram;
298
+ Node: JsonvNode;
299
+ }>;
300
+ export type JsonvOkParseResult = OkParseResult<JsonvProgram>;
301
+ export type JsonvParseResult = ParseResult<JsonvProgram>;
302
+ export type JsonvRuleVisitor = RuleVisitor & CustomRuleVisitorWithExit<{
303
+ Program?: (node: JsonvProgram) => void;
304
+ ObjectExpression?: (node: JsonvObjectExpression, parent?: JsonvNode) => void;
305
+ Property?: (node: JsonvProperty, parent?: JsonvObjectExpression) => void;
306
+ ArrayExpression?: (node: JsonvArrayExpression, parent?: JsonvNode) => void;
307
+ Literal?: (node: JsonvLiteral, parent?: JsonvNode) => void;
308
+ Identifier?: (node: JsonvIdentifier, parent?: JsonvNode) => void;
309
+ MemberExpression?: (node: JsonvMemberExpression, parent?: JsonvNode) => void;
310
+ TemplateLiteral?: (node: JsonvTemplateLiteral, parent?: JsonvNode) => void;
311
+ TemplateElement?: (node: JsonvTemplateElement, parent?: JsonvTemplateLiteral) => void;
312
+ }>;
313
+ export type JsonvRuleDefinition<Options extends Partial<CustomRuleTypeDefinitions> = {}> = CustomRuleDefinitionType<{
314
+ LangOptions: JsonvLanguageOptions;
315
+ Code: JsonvSourceCode;
316
+ Visitor: JsonvRuleVisitor;
317
+ Node: JsonvNode;
318
+ }, Options>;
319
+ /**
320
+ * SourceCode for a parsed `.jsonv` file, modelled on @eslint/json's `JSONSourceCode`:
321
+ * positions, lines and text helpers come from `TextSourceCodeBase`; this class adds AST
322
+ * traversal, parent lookup and inline configuration (`eslint-disable*` / `eslint-enable`
323
+ * directives and `/* eslint rule: ... *\/` config comments).
22
324
  *
23
- * export default [
24
- * {
25
- * files: ["**\/*.jsonv"],
26
- * plugins: { jsonv },
27
- * language: "jsonv/jsonv",
28
- * extends: ["jsonv/recommended"]
29
- * }
30
- * ];
325
+ * @public
326
+ * @extends {TextSourceCodeBase<{LangOptions: JsonvLanguageOptions, RootNode: JsonvProgram, SyntaxElementWithLoc: JsonvSyntaxElement, ConfigNode: JsonvComment}>}
31
327
  */
328
+ declare class JsonvSourceCode extends TextSourceCodeBase<{
329
+ LangOptions: JsonvLanguageOptions;
330
+ RootNode: JsonvProgram;
331
+ SyntaxElementWithLoc: JsonvSyntaxElement;
332
+ ConfigNode: JsonvComment;
333
+ }> {
334
+ #private;
335
+ /** @type {JsonvComment[]} Comments in source order. */
336
+ comments: JsonvComment[];
337
+ /** @type {JsonvToken[]} Tokens in source order, excluding comments. */
338
+ tokens: JsonvToken[];
339
+ /** @type {boolean} Whether the text starts with a byte order mark. */
340
+ hasBOM: boolean;
341
+ /**
342
+ * Creates a SourceCode object.
343
+ * @param {Object} options - Options.
344
+ * @param {string} options.text - The source text.
345
+ * @param {JsonvProgram} options.ast - The `Program` node built by `jsonvLanguage#parse`.
346
+ */
347
+ constructor({ text, ast }: {
348
+ text: string;
349
+ ast: JsonvProgram;
350
+ });
351
+ /**
352
+ * Returns the source text split into lines (a fresh copy of `lines`).
353
+ * @public
354
+ * @returns {string[]} The lines.
355
+ */
356
+ getLines(): string[];
357
+ /**
358
+ * Returns the enter/exit visit steps for every node, depth first in source order.
359
+ * @public
360
+ * @returns {IterableIterator<VisitNodeStep>} The traversal steps.
361
+ */
362
+ traverse(): IterableIterator<VisitNodeStep>;
363
+ /**
364
+ * Returns the parent of a node, or `undefined` for the `Program` root.
365
+ * @public
366
+ * @param {JsonvSyntaxElement} node - An AST node.
367
+ * @returns {JsonvNode|undefined} The parent node.
368
+ */
369
+ getParent(node: JsonvSyntaxElement): JsonvNode | undefined;
370
+ /**
371
+ * Returns the comments that hold inline configuration (`eslint`, `eslint-enable`,
372
+ * `eslint-disable`, `eslint-disable-line`, `eslint-disable-next-line`).
373
+ * @public
374
+ * @returns {JsonvComment[]} The inline configuration comments.
375
+ */
376
+ getInlineConfigNodes(): JsonvComment[];
377
+ /**
378
+ * Returns the `eslint-disable*` / `eslint-enable` directives, plus problems for malformed
379
+ * ones (an `eslint-disable-line` spanning several lines).
380
+ * @public
381
+ * @returns {{problems: FileProblem[], directives: Directive[]}} Directives and problems.
382
+ */
383
+ getDisableDirectives(): {
384
+ problems: FileProblem[];
385
+ directives: Directive[];
386
+ };
387
+ /**
388
+ * Returns the rule configurations from `/* eslint rule: ... *\/` comments, plus problems for
389
+ * ones that fail to parse.
390
+ * @public
391
+ * @returns {{problems: FileProblem[], configs: Array<{config: {rules: RulesConfig}, loc: SourceLocation}>}} Configs and problems.
392
+ */
393
+ applyInlineConfig(): {
394
+ problems: FileProblem[];
395
+ configs: Array<{
396
+ config: {
397
+ rules: RulesConfig;
398
+ };
399
+ loc: SourceLocation;
400
+ }>;
401
+ };
402
+ }
32
403
  /**
33
- * ESLint plugin export
404
+ * ESLint plugin export. `@satisfies` checks it against @eslint/core's `Plugin` (which ESLint's
405
+ * own `ESLint.Plugin` is) while keeping its literal keys (`languages.jsonv`, `configs.recommended`).
34
406
  *
35
407
  * @public
36
- * @type {Object}
408
+ * @satisfies {Plugin}
37
409
  */
38
- declare const plugin: Object;
410
+ declare const plugin: {
411
+ meta: {
412
+ name: string;
413
+ version: string;
414
+ };
415
+ languages: {
416
+ jsonv: JsonvLanguage;
417
+ };
418
+ configs: {
419
+ recommended: {
420
+ rules: {};
421
+ };
422
+ };
423
+ rules: {};
424
+ };
39
425
  export default plugin;
426
+ export { JsonvSourceCode };
40
427
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../index.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAigBH;;;;;GAKG;AACH,QAAA,MAAM,MAAM,EAFF,MAkBT,CAAC;eAEa,MAAM"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../index.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAoCH,OAAO,EAAuB,SAAS,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAiBpG,OAAQ,KAAA,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