@eslint/json 0.9.1 → 0.11.0
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 +4 -3
- package/dist/cjs/index.cjs +334 -30
- package/dist/cjs/index.d.cts +39 -99
- package/dist/cjs/types.cts +138 -0
- package/dist/esm/index.d.ts +39 -99
- package/dist/esm/index.js +334 -30
- package/dist/esm/types.d.ts +91 -0
- package/dist/esm/types.ts +138 -0
- package/package.json +22 -12
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Additional types for this package.
|
|
3
|
+
* @author Nicholas C. Zakas
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
//------------------------------------------------------------------------------
|
|
7
|
+
// Imports
|
|
8
|
+
//------------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
import type {
|
|
11
|
+
RuleVisitor,
|
|
12
|
+
TextSourceCode,
|
|
13
|
+
Language,
|
|
14
|
+
LanguageOptions,
|
|
15
|
+
RuleDefinition,
|
|
16
|
+
} from "@eslint/core";
|
|
17
|
+
import {
|
|
18
|
+
DocumentNode,
|
|
19
|
+
MemberNode,
|
|
20
|
+
ElementNode,
|
|
21
|
+
ObjectNode,
|
|
22
|
+
ArrayNode,
|
|
23
|
+
StringNode,
|
|
24
|
+
NullNode,
|
|
25
|
+
NumberNode,
|
|
26
|
+
BooleanNode,
|
|
27
|
+
NaNNode,
|
|
28
|
+
InfinityNode,
|
|
29
|
+
IdentifierNode,
|
|
30
|
+
AnyNode,
|
|
31
|
+
Token,
|
|
32
|
+
} from "@humanwhocodes/momoa";
|
|
33
|
+
|
|
34
|
+
//------------------------------------------------------------------------------
|
|
35
|
+
// Types
|
|
36
|
+
//------------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
type ValueNodeParent = DocumentNode | MemberNode | ElementNode;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A JSON syntax element, including nodes and tokens.
|
|
42
|
+
*/
|
|
43
|
+
export type JSONSyntaxElement = Token | AnyNode;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Language options provided for JSON files.
|
|
47
|
+
*/
|
|
48
|
+
export interface JSONLanguageOptions extends LanguageOptions {
|
|
49
|
+
/**
|
|
50
|
+
* Whether to allow trailing commas. Only valid in JSONC.
|
|
51
|
+
*/
|
|
52
|
+
allowTrailingCommas?: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The visitor format returned from rules in this package.
|
|
57
|
+
*/
|
|
58
|
+
export interface JSONRuleVisitor extends RuleVisitor {
|
|
59
|
+
Document?(node: DocumentNode): void;
|
|
60
|
+
Member?(node: MemberNode, parent?: ObjectNode): void;
|
|
61
|
+
Element?(node: ElementNode, parent?: ArrayNode): void;
|
|
62
|
+
Object?(node: ObjectNode, parent?: ValueNodeParent): void;
|
|
63
|
+
Array?(node: ArrayNode, parent?: ValueNodeParent): void;
|
|
64
|
+
String?(node: StringNode, parent?: ValueNodeParent): void;
|
|
65
|
+
Null?(node: NullNode, parent?: ValueNodeParent): void;
|
|
66
|
+
Number?(node: NumberNode, parent?: ValueNodeParent): void;
|
|
67
|
+
Boolean?(node: BooleanNode, parent?: ValueNodeParent): void;
|
|
68
|
+
NaN?(node: NaNNode, parent?: ValueNodeParent): void;
|
|
69
|
+
Infinity?(node: InfinityNode, parent?: ValueNodeParent): void;
|
|
70
|
+
Identifier?(node: IdentifierNode, parent?: ValueNodeParent): void;
|
|
71
|
+
|
|
72
|
+
"Document:exit"?(node: DocumentNode): void;
|
|
73
|
+
"Member:exit"?(node: MemberNode, parent?: ObjectNode): void;
|
|
74
|
+
"Element:exit"?(node: ElementNode, parent?: ArrayNode): void;
|
|
75
|
+
"Object:exit"?(node: ObjectNode, parent?: ValueNodeParent): void;
|
|
76
|
+
"Array:exit"?(node: ArrayNode, parent?: ValueNodeParent): void;
|
|
77
|
+
"String:exit"?(node: StringNode, parent?: ValueNodeParent): void;
|
|
78
|
+
"Null:exit"?(node: NullNode, parent?: ValueNodeParent): void;
|
|
79
|
+
"Number:exit"?(node: NumberNode, parent?: ValueNodeParent): void;
|
|
80
|
+
"Boolean:exit"?(node: BooleanNode, parent?: ValueNodeParent): void;
|
|
81
|
+
"NaN:exit"?(node: NaNNode, parent?: ValueNodeParent): void;
|
|
82
|
+
"Infinity:exit"?(node: InfinityNode, parent?: ValueNodeParent): void;
|
|
83
|
+
"Identifier:exit"?(node: IdentifierNode, parent?: ValueNodeParent): void;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The `SourceCode` implementation for JSON files.
|
|
88
|
+
*/
|
|
89
|
+
export interface IJSONSourceCode
|
|
90
|
+
extends TextSourceCode<{
|
|
91
|
+
LangOptions: JSONLanguageOptions;
|
|
92
|
+
RootNode: DocumentNode;
|
|
93
|
+
SyntaxElementWithLoc: JSONSyntaxElement;
|
|
94
|
+
ConfigNode: Token;
|
|
95
|
+
}> {
|
|
96
|
+
/**
|
|
97
|
+
* Get the text of a syntax element.
|
|
98
|
+
* @param syntaxElement The syntax element to get the text of.
|
|
99
|
+
* @param beforeCount The number of characters to include before the syntax element.
|
|
100
|
+
* @param afterCount The number of characters to include after the syntax element.
|
|
101
|
+
* @returns The text of the syntax element.
|
|
102
|
+
*/
|
|
103
|
+
getText(
|
|
104
|
+
syntaxElement: JSONSyntaxElement,
|
|
105
|
+
beforeCount?: number,
|
|
106
|
+
afterCount?: number,
|
|
107
|
+
): string;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Any comments found in a JSONC or JSON5 file.
|
|
111
|
+
*/
|
|
112
|
+
comments: Array<Token> | undefined;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The lines of text found in the file.
|
|
116
|
+
*/
|
|
117
|
+
lines: Array<string>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export type IJSONLanguage = Language<{
|
|
121
|
+
LangOptions: JSONLanguageOptions;
|
|
122
|
+
Code: IJSONSourceCode;
|
|
123
|
+
RootNode: DocumentNode;
|
|
124
|
+
Node: AnyNode;
|
|
125
|
+
}>;
|
|
126
|
+
|
|
127
|
+
export type JSONRuleDefinition<
|
|
128
|
+
JSONRuleOptions extends unknown[],
|
|
129
|
+
JSONRuleMessageIds extends string = "",
|
|
130
|
+
> = RuleDefinition<{
|
|
131
|
+
LangOptions: JSONLanguageOptions;
|
|
132
|
+
Code: IJSONSourceCode;
|
|
133
|
+
RuleOptions: JSONRuleOptions;
|
|
134
|
+
Visitor: JSONRuleVisitor;
|
|
135
|
+
Node: AnyNode;
|
|
136
|
+
MessageIds: JSONRuleMessageIds;
|
|
137
|
+
ExtRuleDocs: {};
|
|
138
|
+
}>;
|
package/package.json
CHANGED
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint/json",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "JSON linting plugin for ESLint",
|
|
5
5
|
"author": "Nicholas C. Zakas",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/esm/index.js",
|
|
8
8
|
"types": "dist/esm/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
10
|
+
".": {
|
|
11
|
+
"require": {
|
|
12
|
+
"types": "./dist/cjs/index.d.cts",
|
|
13
|
+
"default": "./dist/cjs/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"import": {
|
|
16
|
+
"types": "./dist/esm/index.d.ts",
|
|
17
|
+
"default": "./dist/esm/index.js"
|
|
18
|
+
}
|
|
13
19
|
},
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
20
|
+
"./types": {
|
|
21
|
+
"require": {
|
|
22
|
+
"types": "./dist/cjs/types.cts"
|
|
23
|
+
},
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./dist/esm/types.d.ts"
|
|
26
|
+
}
|
|
17
27
|
}
|
|
18
28
|
},
|
|
19
29
|
"files": [
|
|
@@ -42,7 +52,7 @@
|
|
|
42
52
|
"homepage": "https://github.com/eslint/json#readme",
|
|
43
53
|
"scripts": {
|
|
44
54
|
"build:dedupe-types": "node tools/dedupe-types.js dist/cjs/index.cjs dist/esm/index.js",
|
|
45
|
-
"build:cts": "node -
|
|
55
|
+
"build:cts": "node tools/build-cts.js",
|
|
46
56
|
"build": "rollup -c && npm run build:dedupe-types && tsc -p tsconfig.esm.json && npm run build:cts",
|
|
47
57
|
"build:readme": "node tools/update-readme.js",
|
|
48
58
|
"test:jsr": "npx jsr@latest publish --dry-run",
|
|
@@ -63,12 +73,12 @@
|
|
|
63
73
|
],
|
|
64
74
|
"license": "Apache-2.0",
|
|
65
75
|
"dependencies": {
|
|
66
|
-
"@eslint/core": "^0.
|
|
67
|
-
"@eslint/plugin-kit": "^0.2.
|
|
68
|
-
"@humanwhocodes/momoa": "^3.3.4"
|
|
76
|
+
"@eslint/core": "^0.12.0",
|
|
77
|
+
"@eslint/plugin-kit": "^0.2.7",
|
|
78
|
+
"@humanwhocodes/momoa": "^3.3.4",
|
|
79
|
+
"natural-compare": "^1.4.0"
|
|
69
80
|
},
|
|
70
81
|
"devDependencies": {
|
|
71
|
-
"@types/eslint": "^8.56.10",
|
|
72
82
|
"c8": "^9.1.0",
|
|
73
83
|
"dedent": "^1.5.3",
|
|
74
84
|
"eslint": "^9.11.1",
|