@cldmv/eslint-plugin-jsonv 1.0.0 → 1.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cldmv/eslint-plugin-jsonv",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "ESLint plugin for @cldmv/jsonv files",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -16,6 +16,9 @@
16
16
  "build:js": "node scripts/build.mjs",
17
17
  "build:types": "tsc -p .configs/tsconfig.types.json"
18
18
  },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
19
22
  "files": [
20
23
  "dist/**",
21
24
  "README.md"
package/dist/index.d.mts DELETED
@@ -1,9 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../index.mjs"],"names":[],"mappings":";AAuNA;;;;;GAKG;AACH,sBAFU,MAAM,CAqBd"}
package/dist/index.mjs DELETED
@@ -1,243 +0,0 @@
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;