@cldmv/eslint-plugin-jsonv 1.0.2 → 1.0.10

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
@@ -1,6 +1,10 @@
1
- # eslint-plugin-jsonv
1
+ # @cldmv/eslint-plugin-jsonv
2
2
 
3
- ESLint plugin for validating `.jsonv` files using the @cldmv/jsonv parser.
3
+ [![npm version]][npm_version_url] [![npm downloads]][npm_downloads_url] [![GitHub downloads]][github_downloads_url] [![Last commit]][last_commit_url] [![npm last update]][npm_last_update_url]
4
+
5
+ [![Contributors]][contributors_url] [![Sponsor shinrai]][sponsor_url]
6
+
7
+ ESLint plugin for validating `.jsonv` files using the [@cldmv/jsonv](https://github.com/CLDMV/jsonv) parser.
4
8
 
5
9
  ## Features
6
10
 
@@ -14,7 +18,7 @@ ESLint plugin for validating `.jsonv` files using the @cldmv/jsonv parser.
14
18
  ## Installation
15
19
 
16
20
  ```bash
17
- npm install --save-dev eslint-plugin-jsonv
21
+ npm install --save-dev @cldmv/eslint-plugin-jsonv
18
22
  ```
19
23
 
20
24
  **Note:** This plugin requires `@cldmv/jsonv` as a peer dependency.
@@ -42,7 +46,7 @@ This will:
42
46
  ### ESLint Flat Config (eslint.config.mjs)
43
47
 
44
48
  ```javascript
45
- import jsonv from 'eslint-plugin-jsonv';
49
+ import jsonv from '@cldmv/eslint-plugin-jsonv';
46
50
 
47
51
  export default [
48
52
  {
@@ -128,4 +132,25 @@ The parser supports the following options:
128
132
 
129
133
  ## License
130
134
 
131
- Apache-2.0. See [LICENSE](LICENSE).
135
+ [![GitHub license]][github_license_url] [![npm license]][npm_license_url]
136
+
137
+ Apache-2.0 © Shinrai / CLDMV
138
+
139
+ [npm version]: https://img.shields.io/npm/v/%40cldmv%2Feslint-plugin-jsonv.svg?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837
140
+ [npm_version_url]: https://www.npmjs.com/package/@cldmv/eslint-plugin-jsonv
141
+ [npm downloads]: https://img.shields.io/npm/dm/%40cldmv%2Feslint-plugin-jsonv.svg?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837
142
+ [npm_downloads_url]: https://www.npmjs.com/package/@cldmv/eslint-plugin-jsonv
143
+ [npm last update]: https://img.shields.io/npm/last-update/%40cldmv%2Feslint-plugin-jsonv?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837
144
+ [npm_last_update_url]: https://www.npmjs.com/package/@cldmv/eslint-plugin-jsonv
145
+ [npm license]: https://img.shields.io/npm/l/%40cldmv%2Feslint-plugin-jsonv.svg?style=for-the-badge&logo=npm&logoColor=white&labelColor=CB3837
146
+ [npm_license_url]: https://www.npmjs.com/package/@cldmv/eslint-plugin-jsonv
147
+ [github downloads]: https://img.shields.io/github/downloads/CLDMV/jsonv-eslint-plugin-jsonv/total?style=for-the-badge&logo=github&logoColor=white&labelColor=181717
148
+ [github_downloads_url]: https://github.com/CLDMV/jsonv-eslint-plugin-jsonv/releases
149
+ [last commit]: https://img.shields.io/github/last-commit/CLDMV/jsonv-eslint-plugin-jsonv?style=for-the-badge&logo=github&logoColor=white&labelColor=181717
150
+ [last_commit_url]: https://github.com/CLDMV/jsonv-eslint-plugin-jsonv/commits
151
+ [github license]: https://img.shields.io/github/license/CLDMV/jsonv-eslint-plugin-jsonv.svg?style=for-the-badge&logo=github&logoColor=white&labelColor=181717
152
+ [github_license_url]: https://github.com/CLDMV/jsonv-eslint-plugin-jsonv/blob/HEAD/LICENSE
153
+ [contributors]: https://img.shields.io/github/contributors/CLDMV/jsonv-eslint-plugin-jsonv.svg?style=for-the-badge&logo=github&logoColor=white&labelColor=181717
154
+ [contributors_url]: https://github.com/CLDMV/jsonv-eslint-plugin-jsonv/graphs/contributors
155
+ [sponsor shinrai]: https://img.shields.io/github/sponsors/shinrai?style=for-the-badge&logo=githubsponsors&logoColor=white&labelColor=EA4AAA&label=Sponsor
156
+ [sponsor_url]: https://github.com/sponsors/shinrai
@@ -0,0 +1,9 @@
1
+ export default plugin;
2
+ /**
3
+ * ESLint plugin export
4
+ *
5
+ * @public
6
+ * @type {Object}
7
+ */
8
+ declare const plugin: Object;
9
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../index.mjs"],"names":[],"mappings":";AAuNA;;;;;GAKG;AACH,sBAFU,MAAM,CAqBd"}
package/dist/index.mjs ADDED
@@ -0,0 +1,243 @@
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
+ *
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
+ *
17
+ * @example
18
+ * // In eslint.config.mjs
19
+ * import jsonv from 'eslint-plugin-jsonv';
20
+ *
21
+ * export default [
22
+ * {
23
+ * files: ["**\/*.jsonv"],
24
+ * plugins: { jsonv },
25
+ * language: "jsonv/jsonv",
26
+ * extends: ["jsonv/recommended"]
27
+ * }
28
+ * ];
29
+ */
30
+
31
+ // Use proper package import - package is copied to node_modules during build
32
+ import { parseWithOptions } from "@cldmv/jsonv/parser";
33
+
34
+ /**
35
+ * Language definition for jsonv files
36
+ *
37
+ * @public
38
+ * @type {Object}
39
+ */
40
+ const jsonvLanguage = {
41
+ /** File type - must be "text" for text-based languages */
42
+ fileType: "text",
43
+ /** Line numbering starts at 1 */
44
+ lineStart: 1,
45
+ /** Column numbering starts at 1 */
46
+ columnStart: 1,
47
+ /** Property name for node types */
48
+ nodeTypeKey: "type",
49
+
50
+ /**
51
+ * Parse jsonv source code - ESLint 9 Language API
52
+ * @param {Object} file - File object with body property containing source text
53
+ * @param {Object} context - Context with languageOptions
54
+ * @returns {Object} Parse result {ok, ast, jsonvValue} or {ok: false, errors}
55
+ */
56
+ parse(file, context) {
57
+ const text = file.body;
58
+ const options = context.languageOptions || {};
59
+
60
+ try {
61
+ // Parse with all features enabled (ES2025) and strict mode off by default
62
+ const result = parseWithOptions(text, {
63
+ year: options.year || 2025,
64
+ strictBigInt: options.strictBigInt !== undefined ? options.strictBigInt : false,
65
+ mode: "jsonv",
66
+ preserveComments: true,
67
+ tolerant: false
68
+ });
69
+
70
+ // Return parse result with minimal ESTree-compatible AST
71
+ return {
72
+ ok: true,
73
+ ast: {
74
+ type: "Program",
75
+ body: [],
76
+ sourceType: "module",
77
+ comments: [],
78
+ tokens: []
79
+ },
80
+ // Store the parsed jsonv value for potential use by rules
81
+ jsonvValue: result
82
+ };
83
+ } catch (error) {
84
+ // Return error result
85
+ return {
86
+ ok: false,
87
+ errors: [
88
+ {
89
+ message: error.message,
90
+ line: error.line || 1,
91
+ column: error.column || 1
92
+ }
93
+ ]
94
+ };
95
+ }
96
+ },
97
+
98
+ /**
99
+ * Create source code object
100
+ * Required by ESLint 9 language API
101
+ *
102
+ * @public
103
+ * @param {Object} file - The file object
104
+ * @param {Object} parseResult - The result from parse()
105
+ * @param {Object} context - Context object
106
+ * @returns {Object} SourceCode object
107
+ */
108
+ createSourceCode(file, parseResult, context) {
109
+ const text = typeof file.body === "string" ? file.body : String(file.body || "");
110
+ const ast = parseResult.ast;
111
+
112
+ return {
113
+ text,
114
+ ast,
115
+ lines: text.split(/\r\n|[\r\n\u2028\u2029]/g),
116
+ hasBOM: text.charCodeAt(0) === 0xfeff,
117
+
118
+ // Required methods
119
+ getLoc(node) {
120
+ return node.loc || { start: { line: 1, column: 0 }, end: { line: 1, column: 0 } };
121
+ },
122
+
123
+ getRange(node) {
124
+ return node.range || [0, 0];
125
+ },
126
+
127
+ traverse() {
128
+ // ESLint expects: { kind: 1 (VISIT), target: node, phase: 1|2, args: [] }
129
+ // kind: 1 = STEP_KIND_VISIT
130
+ // phase: 1 = enter, 2 = exit
131
+ return [
132
+ {
133
+ kind: 1,
134
+ target: ast,
135
+ phase: 1,
136
+ args: [ast]
137
+ },
138
+ {
139
+ kind: 1,
140
+ target: ast,
141
+ phase: 2,
142
+ args: [ast]
143
+ }
144
+ ].values();
145
+ },
146
+
147
+ // Optional helper methods
148
+ getText(node, beforeCount, afterCount) {
149
+ if (node && node.range) {
150
+ const [start, end] = node.range;
151
+ return text.slice(Math.max(0, start - (beforeCount || 0)), Math.min(text.length, end + (afterCount || 0)));
152
+ }
153
+ return text;
154
+ },
155
+
156
+ getLines() {
157
+ return text.split(/\r\n|[\r\n\u2028\u2029]/g);
158
+ }
159
+ };
160
+ },
161
+
162
+ /**
163
+ * Validate language options
164
+ * Required by ESLint 9 language API
165
+ *
166
+ * @public
167
+ * @param {Object} languageOptions - The language options to validate
168
+ * @returns {void}
169
+ */
170
+ validateLanguageOptions(___languageOptions) {
171
+ // No validation needed - all options are optional
172
+ // year, strictBigInt, mode, preserveComments, tolerant
173
+ },
174
+
175
+ /**
176
+ * Validate language options
177
+ * Required by ESLint 9 language API
178
+ *
179
+ * @public
180
+ * @param {Object} languageOptions - The language options to validate
181
+ * @returns {void}
182
+ */
183
+ validateLanguageOptions(___languageOptions) {
184
+ // No validation needed - all options are optional
185
+ // year, strictBigInt, mode, preserveComments, tolerant
186
+ },
187
+
188
+ /** * Default parser options
189
+ *
190
+ * @public
191
+ * @type {Object}
192
+ */
193
+ defaultParserOptions: {
194
+ year: 2025,
195
+ strictBigInt: false,
196
+ mode: "jsonv"
197
+ }
198
+ };
199
+
200
+ /**
201
+ * Recommended configuration for jsonv files
202
+ *
203
+ * @public
204
+ * @type {Object}
205
+ */
206
+ const recommendedConfig = {
207
+ languageOptions: {
208
+ parser: jsonvLanguage
209
+ },
210
+ rules: {
211
+ // Add custom jsonv rules here in the future
212
+ // For now, parsing validation is enough
213
+ }
214
+ };
215
+
216
+ /**
217
+ * ESLint plugin export
218
+ *
219
+ * @public
220
+ * @type {Object}
221
+ */
222
+ const plugin = {
223
+ meta: {
224
+ name: "eslint-plugin-jsonv",
225
+ version: "0.1.0"
226
+ },
227
+ languages: {
228
+ jsonv: jsonvLanguage
229
+ },
230
+ configs: {
231
+ recommended: recommendedConfig
232
+ },
233
+ rules: {
234
+ // Future: Add custom rules for jsonv-specific validations
235
+ // Examples:
236
+ // - "no-circular-references": enforce no circular internal refs
237
+ // - "require-bigint-suffix": enforce 'n' suffix for large integers
238
+ // - "prefer-template-interpolation": prefer ${} over string concat
239
+ // - "no-duplicate-keys": enforce unique object keys
240
+ }
241
+ };
242
+
243
+ export default plugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cldmv/eslint-plugin-jsonv",
3
- "version": "1.0.2",
3
+ "version": "1.0.10",
4
4
  "description": "ESLint plugin for @cldmv/jsonv files",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -24,10 +24,10 @@
24
24
  "README.md"
25
25
  ],
26
26
  "peerDependencies": {
27
- "@cldmv/jsonv": "^1.0.1"
27
+ "@cldmv/jsonv": "^1.0.2"
28
28
  },
29
29
  "devDependencies": {
30
- "@cldmv/jsonv": "^1.0.1",
30
+ "@cldmv/jsonv": "^1.0.2",
31
31
  "typescript": "^5.9.3"
32
32
  },
33
33
  "keywords": [