@eslint/json 0.11.0 → 0.13.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 +72 -33
- package/dist/cjs/index.cjs +295 -139
- package/dist/cjs/index.d.cts +117 -77
- package/dist/cjs/types.cts +22 -68
- package/dist/esm/index.d.ts +117 -77
- package/dist/esm/index.js +295 -139
- package/dist/esm/types.d.ts +11 -49
- package/dist/esm/types.ts +22 -68
- package/package.json +23 -11
package/dist/esm/types.d.ts
CHANGED
|
@@ -2,22 +2,14 @@
|
|
|
2
2
|
* @fileoverview Additional types for this package.
|
|
3
3
|
* @author Nicholas C. Zakas
|
|
4
4
|
*/
|
|
5
|
-
import type { RuleVisitor,
|
|
6
|
-
import { DocumentNode, MemberNode, ElementNode, ObjectNode, ArrayNode, StringNode, NullNode, NumberNode, BooleanNode, NaNNode, InfinityNode, IdentifierNode, AnyNode, Token } from "@humanwhocodes/momoa";
|
|
5
|
+
import type { RuleVisitor, RuleDefinition } from "@eslint/core";
|
|
6
|
+
import type { DocumentNode, MemberNode, ElementNode, ObjectNode, ArrayNode, StringNode, NullNode, NumberNode, BooleanNode, NaNNode, InfinityNode, IdentifierNode, AnyNode, Token } from "@humanwhocodes/momoa";
|
|
7
|
+
import type { JSONLanguageOptions, JSONSourceCode } from "./index.js";
|
|
7
8
|
type ValueNodeParent = DocumentNode | MemberNode | ElementNode;
|
|
8
9
|
/**
|
|
9
10
|
* A JSON syntax element, including nodes and tokens.
|
|
10
11
|
*/
|
|
11
12
|
export type JSONSyntaxElement = Token | AnyNode;
|
|
12
|
-
/**
|
|
13
|
-
* Language options provided for JSON files.
|
|
14
|
-
*/
|
|
15
|
-
export interface JSONLanguageOptions extends LanguageOptions {
|
|
16
|
-
/**
|
|
17
|
-
* Whether to allow trailing commas. Only valid in JSONC.
|
|
18
|
-
*/
|
|
19
|
-
allowTrailingCommas?: boolean;
|
|
20
|
-
}
|
|
21
13
|
/**
|
|
22
14
|
* The visitor format returned from rules in this package.
|
|
23
15
|
*/
|
|
@@ -47,45 +39,15 @@ export interface JSONRuleVisitor extends RuleVisitor {
|
|
|
47
39
|
"Infinity:exit"?(node: InfinityNode, parent?: ValueNodeParent): void;
|
|
48
40
|
"Identifier:exit"?(node: IdentifierNode, parent?: ValueNodeParent): void;
|
|
49
41
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
SyntaxElementWithLoc: JSONSyntaxElement;
|
|
57
|
-
ConfigNode: Token;
|
|
58
|
-
}> {
|
|
59
|
-
/**
|
|
60
|
-
* Get the text of a syntax element.
|
|
61
|
-
* @param syntaxElement The syntax element to get the text of.
|
|
62
|
-
* @param beforeCount The number of characters to include before the syntax element.
|
|
63
|
-
* @param afterCount The number of characters to include after the syntax element.
|
|
64
|
-
* @returns The text of the syntax element.
|
|
65
|
-
*/
|
|
66
|
-
getText(syntaxElement: JSONSyntaxElement, beforeCount?: number, afterCount?: number): string;
|
|
67
|
-
/**
|
|
68
|
-
* Any comments found in a JSONC or JSON5 file.
|
|
69
|
-
*/
|
|
70
|
-
comments: Array<Token> | undefined;
|
|
71
|
-
/**
|
|
72
|
-
* The lines of text found in the file.
|
|
73
|
-
*/
|
|
74
|
-
lines: Array<string>;
|
|
75
|
-
}
|
|
76
|
-
export type IJSONLanguage = Language<{
|
|
77
|
-
LangOptions: JSONLanguageOptions;
|
|
78
|
-
Code: IJSONSourceCode;
|
|
79
|
-
RootNode: DocumentNode;
|
|
80
|
-
Node: AnyNode;
|
|
81
|
-
}>;
|
|
82
|
-
export type JSONRuleDefinition<JSONRuleOptions extends unknown[], JSONRuleMessageIds extends string = ""> = RuleDefinition<{
|
|
42
|
+
export type JSONRuleDefinitionTypeOptions = {
|
|
43
|
+
RuleOptions: unknown[];
|
|
44
|
+
MessageIds: string;
|
|
45
|
+
ExtRuleDocs: Record<string, unknown>;
|
|
46
|
+
};
|
|
47
|
+
export type JSONRuleDefinition<Options extends Partial<JSONRuleDefinitionTypeOptions> = {}> = RuleDefinition<{
|
|
83
48
|
LangOptions: JSONLanguageOptions;
|
|
84
|
-
Code:
|
|
85
|
-
RuleOptions: JSONRuleOptions;
|
|
49
|
+
Code: JSONSourceCode;
|
|
86
50
|
Visitor: JSONRuleVisitor;
|
|
87
51
|
Node: AnyNode;
|
|
88
|
-
|
|
89
|
-
ExtRuleDocs: {};
|
|
90
|
-
}>;
|
|
52
|
+
} & Required<Options & Omit<JSONRuleDefinitionTypeOptions, keyof Options>>>;
|
|
91
53
|
export {};
|
package/dist/esm/types.ts
CHANGED
|
@@ -7,14 +7,8 @@
|
|
|
7
7
|
// Imports
|
|
8
8
|
//------------------------------------------------------------------------------
|
|
9
9
|
|
|
10
|
+
import type { RuleVisitor, RuleDefinition } from "@eslint/core";
|
|
10
11
|
import type {
|
|
11
|
-
RuleVisitor,
|
|
12
|
-
TextSourceCode,
|
|
13
|
-
Language,
|
|
14
|
-
LanguageOptions,
|
|
15
|
-
RuleDefinition,
|
|
16
|
-
} from "@eslint/core";
|
|
17
|
-
import {
|
|
18
12
|
DocumentNode,
|
|
19
13
|
MemberNode,
|
|
20
14
|
ElementNode,
|
|
@@ -30,6 +24,7 @@ import {
|
|
|
30
24
|
AnyNode,
|
|
31
25
|
Token,
|
|
32
26
|
} from "@humanwhocodes/momoa";
|
|
27
|
+
import type { JSONLanguageOptions, JSONSourceCode } from "./index.js";
|
|
33
28
|
|
|
34
29
|
//------------------------------------------------------------------------------
|
|
35
30
|
// Types
|
|
@@ -42,16 +37,6 @@ type ValueNodeParent = DocumentNode | MemberNode | ElementNode;
|
|
|
42
37
|
*/
|
|
43
38
|
export type JSONSyntaxElement = Token | AnyNode;
|
|
44
39
|
|
|
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
40
|
/**
|
|
56
41
|
* The visitor format returned from rules in this package.
|
|
57
42
|
*/
|
|
@@ -83,56 +68,25 @@ export interface JSONRuleVisitor extends RuleVisitor {
|
|
|
83
68
|
"Identifier:exit"?(node: IdentifierNode, parent?: ValueNodeParent): void;
|
|
84
69
|
}
|
|
85
70
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
}>;
|
|
71
|
+
export type JSONRuleDefinitionTypeOptions = {
|
|
72
|
+
RuleOptions: unknown[];
|
|
73
|
+
MessageIds: string;
|
|
74
|
+
ExtRuleDocs: Record<string, unknown>;
|
|
75
|
+
};
|
|
126
76
|
|
|
127
77
|
export type JSONRuleDefinition<
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
78
|
+
Options extends Partial<JSONRuleDefinitionTypeOptions> = {},
|
|
79
|
+
> = RuleDefinition<
|
|
80
|
+
// Language specific type options (non-configurable)
|
|
81
|
+
{
|
|
82
|
+
LangOptions: JSONLanguageOptions;
|
|
83
|
+
Code: JSONSourceCode;
|
|
84
|
+
Visitor: JSONRuleVisitor;
|
|
85
|
+
Node: AnyNode;
|
|
86
|
+
} & Required<
|
|
87
|
+
// Rule specific type options (custom)
|
|
88
|
+
Options &
|
|
89
|
+
// Rule specific type options (defaults)
|
|
90
|
+
Omit<JSONRuleDefinitionTypeOptions, keyof Options>
|
|
91
|
+
>
|
|
92
|
+
>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint/json",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "JSON linting plugin for ESLint",
|
|
5
5
|
"author": "Nicholas C. Zakas",
|
|
6
6
|
"type": "module",
|
|
@@ -40,7 +40,14 @@
|
|
|
40
40
|
"eslint --fix",
|
|
41
41
|
"prettier --write"
|
|
42
42
|
],
|
|
43
|
-
"!(*.js)": "prettier --write --ignore-unknown"
|
|
43
|
+
"!(*.js)": "prettier --write --ignore-unknown",
|
|
44
|
+
"README.md": [
|
|
45
|
+
"npm run build:update-rules-docs"
|
|
46
|
+
],
|
|
47
|
+
"{src/rules/*.js,tools/update-rules-docs.js}": [
|
|
48
|
+
"npm run build:update-rules-docs",
|
|
49
|
+
"git add README.md"
|
|
50
|
+
]
|
|
44
51
|
},
|
|
45
52
|
"repository": {
|
|
46
53
|
"type": "git",
|
|
@@ -53,14 +60,17 @@
|
|
|
53
60
|
"scripts": {
|
|
54
61
|
"build:dedupe-types": "node tools/dedupe-types.js dist/cjs/index.cjs dist/esm/index.js",
|
|
55
62
|
"build:cts": "node tools/build-cts.js",
|
|
56
|
-
"build": "
|
|
63
|
+
"build:rules": "node tools/build-rules.js",
|
|
64
|
+
"build": "npm run build:rules && rollup -c && npm run build:dedupe-types && tsc -p tsconfig.esm.json && npm run build:cts",
|
|
57
65
|
"build:readme": "node tools/update-readme.js",
|
|
58
|
-
"
|
|
66
|
+
"build:update-rules-docs": "node tools/update-rules-docs.js",
|
|
67
|
+
"prepare": "npm run build",
|
|
59
68
|
"pretest": "npm run build",
|
|
60
69
|
"lint": "eslint",
|
|
61
70
|
"fmt": "prettier --write .",
|
|
62
71
|
"fmt:check": "prettier --check .",
|
|
63
72
|
"test": "mocha tests/**/*.js",
|
|
73
|
+
"test:jsr": "npx jsr@latest publish --dry-run",
|
|
64
74
|
"test:coverage": "c8 npm test",
|
|
65
75
|
"test:types": "tsc -p tests/types/tsconfig.json"
|
|
66
76
|
},
|
|
@@ -73,24 +83,26 @@
|
|
|
73
83
|
],
|
|
74
84
|
"license": "Apache-2.0",
|
|
75
85
|
"dependencies": {
|
|
76
|
-
"@eslint/core": "^0.
|
|
77
|
-
"@eslint/plugin-kit": "^0.
|
|
86
|
+
"@eslint/core": "^0.14.0",
|
|
87
|
+
"@eslint/plugin-kit": "^0.3.1",
|
|
78
88
|
"@humanwhocodes/momoa": "^3.3.4",
|
|
79
89
|
"natural-compare": "^1.4.0"
|
|
80
90
|
},
|
|
81
91
|
"devDependencies": {
|
|
82
|
-
"c8": "^
|
|
92
|
+
"c8": "^10.1.3",
|
|
83
93
|
"dedent": "^1.5.3",
|
|
84
|
-
"eslint": "^9.
|
|
94
|
+
"eslint": "^9.25.1",
|
|
85
95
|
"eslint-config-eslint": "^11.0.0",
|
|
86
96
|
"eslint-plugin-eslint-plugin": "^6.3.2",
|
|
87
97
|
"got": "^14.4.2",
|
|
88
98
|
"lint-staged": "^15.2.7",
|
|
89
|
-
"
|
|
99
|
+
"mdast-util-from-markdown": "^2.0.2",
|
|
100
|
+
"mocha": "^11.3.0",
|
|
90
101
|
"prettier": "^3.4.1",
|
|
91
|
-
"rollup": "^4.
|
|
102
|
+
"rollup": "^4.41.0",
|
|
92
103
|
"rollup-plugin-copy": "^3.5.0",
|
|
93
|
-
"
|
|
104
|
+
"rollup-plugin-delete": "^3.0.1",
|
|
105
|
+
"typescript": "^5.8.3",
|
|
94
106
|
"yorkie": "^2.0.0"
|
|
95
107
|
},
|
|
96
108
|
"engines": {
|