Skip to content

Commit a6dc46d

Browse files
hardfistCopilot
andauthored
chore: add json-schema (#190)
Co-authored-by: Copilot <[email protected]>
1 parent 22f41b1 commit a6dc46d

File tree

3 files changed

+339
-1
lines changed

3 files changed

+339
-1
lines changed

.vscode/settings.template.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
"files.associations": {
1313
"rslint.json": "jsonc"
1414
},
15+
"json.schemas": [
16+
{
17+
"fileMatch": [
18+
"rslint.json",
19+
"rslint.jsonc"
20+
],
21+
"url": "./rslint-schema.json"
22+
}
23+
],
1524
"cSpell.words": [
1625
"rslint"
1726
],

rslint-schema.json

Lines changed: 329 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,329 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "rslint-schema.json",
4+
"title": "Rslint Configuration",
5+
"description": "Configuration file for Rslint - a high-performance TypeScript/JavaScript linter",
6+
"type": "array",
7+
"minItems": 1,
8+
"items": {
9+
"$ref": "#/definitions/ConfigEntry"
10+
},
11+
"definitions": {
12+
"ConfigEntry": {
13+
"type": "object",
14+
"description": "A single configuration entry in the rslint.json array",
15+
"properties": {
16+
"language": {
17+
"type": "string",
18+
"description": "Programming language for this configuration entry",
19+
"enum": ["javascript"],
20+
"default": "javascript"
21+
},
22+
"files": {
23+
"type": "array",
24+
"description": "Additional files to include beyond those specified in tsconfig.json",
25+
"items": {
26+
"type": "string",
27+
"description": "File pattern (glob) to include"
28+
},
29+
"default": []
30+
},
31+
"ignores": {
32+
"type": "array",
33+
"description": "File patterns to ignore when linting",
34+
"items": {
35+
"type": "string",
36+
"description": "File pattern (glob) to ignore"
37+
},
38+
"examples": [["node_modules/**", "dist/**", "*.test.ts"]]
39+
},
40+
"languageOptions": {
41+
"$ref": "#/definitions/LanguageOptions",
42+
"description": "Language-specific configuration options"
43+
},
44+
"rules": {
45+
"$ref": "#/definitions/Rules",
46+
"description": "Linting rules configuration",
47+
"default": {}
48+
},
49+
"plugins": {
50+
"type": "array",
51+
"description": "List of plugin names to enable",
52+
"items": {
53+
"type": "string",
54+
"enum": ["@typescript-eslint"]
55+
},
56+
"uniqueItems": true,
57+
"examples": [["@typescript-eslint"]]
58+
}
59+
},
60+
"required": ["language"],
61+
"additionalProperties": false
62+
},
63+
"LanguageOptions": {
64+
"type": "object",
65+
"description": "Language-specific configuration options",
66+
"properties": {
67+
"parserOptions": {
68+
"$ref": "#/definitions/ParserOptions",
69+
"description": "Parser-specific configuration options"
70+
}
71+
},
72+
"additionalProperties": false
73+
},
74+
"ParserOptions": {
75+
"type": "object",
76+
"description": "Parser-specific configuration options",
77+
"properties": {
78+
"projectService": {
79+
"type": "boolean",
80+
"description": "Enable project service for typed linting (runs TypeScript language service behind the scene)",
81+
"default": false
82+
},
83+
"project": {
84+
"type": "array",
85+
"description": "TypeScript project configuration files to use for typed linting",
86+
"items": {
87+
"type": "string",
88+
"description": "Path to tsconfig.json file"
89+
},
90+
"examples": [
91+
["./tsconfig.json"],
92+
["./packages/*/tsconfig.json", "./tsconfig.base.json"]
93+
]
94+
}
95+
},
96+
"additionalProperties": false
97+
},
98+
"Rules": {
99+
"type": "object",
100+
"description": "Configuration for linting rules",
101+
"patternProperties": {
102+
"^@typescript-eslint/": {
103+
"$ref": "#/definitions/RuleValue"
104+
},
105+
"^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$": {
106+
"$ref": "#/definitions/RuleValue"
107+
},
108+
"^[a-zA-Z0-9_-]+$": {
109+
"$ref": "#/definitions/RuleValue"
110+
}
111+
},
112+
"properties": {
113+
"@typescript-eslint/adjacent-overload-signatures": {
114+
"$ref": "#/definitions/RuleValue"
115+
},
116+
"@typescript-eslint/array-type": {
117+
"$ref": "#/definitions/RuleValue"
118+
},
119+
"@typescript-eslint/await-thenable": {
120+
"$ref": "#/definitions/RuleValue"
121+
},
122+
"@typescript-eslint/class-literal-property-style": {
123+
"$ref": "#/definitions/RuleValue"
124+
},
125+
"@typescript-eslint/no-array-delete": {
126+
"$ref": "#/definitions/RuleValue"
127+
},
128+
"@typescript-eslint/no-base-to-string": {
129+
"$ref": "#/definitions/RuleValue"
130+
},
131+
"@typescript-eslint/no-confusing-void-expression": {
132+
"$ref": "#/definitions/RuleValue"
133+
},
134+
"@typescript-eslint/no-duplicate-type-constituents": {
135+
"$ref": "#/definitions/RuleValue"
136+
},
137+
"@typescript-eslint/no-floating-promises": {
138+
"$ref": "#/definitions/RuleValue"
139+
},
140+
"@typescript-eslint/no-for-in-array": {
141+
"$ref": "#/definitions/RuleValue"
142+
},
143+
"@typescript-eslint/no-implied-eval": {
144+
"$ref": "#/definitions/RuleValue"
145+
},
146+
"@typescript-eslint/no-meaningless-void-operator": {
147+
"$ref": "#/definitions/RuleValue"
148+
},
149+
"@typescript-eslint/no-misused-promises": {
150+
"$ref": "#/definitions/RuleValue"
151+
},
152+
"@typescript-eslint/no-misused-spread": {
153+
"$ref": "#/definitions/RuleValue"
154+
},
155+
"@typescript-eslint/no-mixed-enums": {
156+
"$ref": "#/definitions/RuleValue"
157+
},
158+
"@typescript-eslint/no-redundant-type-constituents": {
159+
"$ref": "#/definitions/RuleValue"
160+
},
161+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": {
162+
"$ref": "#/definitions/RuleValue"
163+
},
164+
"@typescript-eslint/no-unnecessary-template-expression": {
165+
"$ref": "#/definitions/RuleValue"
166+
},
167+
"@typescript-eslint/no-unnecessary-type-arguments": {
168+
"$ref": "#/definitions/RuleValue"
169+
},
170+
"@typescript-eslint/no-unnecessary-type-assertion": {
171+
"$ref": "#/definitions/RuleValue"
172+
},
173+
"@typescript-eslint/no-unsafe-argument": {
174+
"$ref": "#/definitions/RuleValue"
175+
},
176+
"@typescript-eslint/no-unsafe-assignment": {
177+
"$ref": "#/definitions/RuleValue"
178+
},
179+
"@typescript-eslint/no-unsafe-call": {
180+
"$ref": "#/definitions/RuleValue"
181+
},
182+
"@typescript-eslint/no-unsafe-enum-comparison": {
183+
"$ref": "#/definitions/RuleValue"
184+
},
185+
"@typescript-eslint/no-unsafe-member-access": {
186+
"$ref": "#/definitions/RuleValue"
187+
},
188+
"@typescript-eslint/no-unsafe-return": {
189+
"$ref": "#/definitions/RuleValue"
190+
},
191+
"@typescript-eslint/no-unsafe-type-assertion": {
192+
"$ref": "#/definitions/RuleValue"
193+
},
194+
"@typescript-eslint/no-unsafe-unary-minus": {
195+
"$ref": "#/definitions/RuleValue"
196+
},
197+
"@typescript-eslint/no-unused-vars": {
198+
"$ref": "#/definitions/RuleValue"
199+
},
200+
"@typescript-eslint/no-useless-empty-export": {
201+
"$ref": "#/definitions/RuleValue"
202+
},
203+
"@typescript-eslint/no-var-requires": {
204+
"$ref": "#/definitions/RuleValue"
205+
},
206+
"@typescript-eslint/non-nullable-type-assertion-style": {
207+
"$ref": "#/definitions/RuleValue"
208+
},
209+
"@typescript-eslint/only-throw-error": {
210+
"$ref": "#/definitions/RuleValue"
211+
},
212+
"@typescript-eslint/prefer-as-const": {
213+
"$ref": "#/definitions/RuleValue"
214+
},
215+
"@typescript-eslint/prefer-promise-reject-errors": {
216+
"$ref": "#/definitions/RuleValue"
217+
},
218+
"@typescript-eslint/prefer-reduce-type-parameter": {
219+
"$ref": "#/definitions/RuleValue"
220+
},
221+
"@typescript-eslint/prefer-return-this-type": {
222+
"$ref": "#/definitions/RuleValue"
223+
},
224+
"@typescript-eslint/promise-function-async": {
225+
"$ref": "#/definitions/RuleValue"
226+
},
227+
"@typescript-eslint/related-getter-setter-pairs": {
228+
"$ref": "#/definitions/RuleValue"
229+
},
230+
"@typescript-eslint/require-array-sort-compare": {
231+
"$ref": "#/definitions/RuleValue"
232+
},
233+
"@typescript-eslint/require-await": {
234+
"$ref": "#/definitions/RuleValue"
235+
},
236+
"@typescript-eslint/restrict-plus-operands": {
237+
"$ref": "#/definitions/RuleValue"
238+
},
239+
"@typescript-eslint/restrict-template-expressions": {
240+
"$ref": "#/definitions/RuleValue"
241+
},
242+
"@typescript-eslint/return-await": {
243+
"$ref": "#/definitions/RuleValue"
244+
},
245+
"@typescript-eslint/switch-exhaustiveness-check": {
246+
"$ref": "#/definitions/RuleValue"
247+
},
248+
"@typescript-eslint/unbound-method": {
249+
"$ref": "#/definitions/RuleValue"
250+
},
251+
"@typescript-eslint/use-unknown-in-catch-callback-variable": {
252+
"$ref": "#/definitions/RuleValue"
253+
}
254+
},
255+
"additionalProperties": {
256+
"$ref": "#/definitions/RuleValue"
257+
}
258+
},
259+
"RuleValue": {
260+
"description": "Rule configuration value",
261+
"oneOf": [
262+
{
263+
"type": "string",
264+
"enum": ["off", "warn", "error"],
265+
"description": "Simple rule severity level"
266+
},
267+
{
268+
"type": "array",
269+
"description": "Array format rule configuration [severity, options]",
270+
"minItems": 1,
271+
"maxItems": 2,
272+
"items": [
273+
{
274+
"type": "string",
275+
"enum": ["off", "warn", "error"],
276+
"description": "Rule severity level"
277+
},
278+
{
279+
"type": "object",
280+
"description": "Rule-specific options",
281+
"additionalProperties": true
282+
}
283+
]
284+
},
285+
{
286+
"type": "object",
287+
"description": "Object format rule configuration",
288+
"properties": {
289+
"level": {
290+
"type": "string",
291+
"enum": ["off", "warn", "error"],
292+
"description": "Rule severity level"
293+
},
294+
"options": {
295+
"type": "object",
296+
"description": "Rule-specific options",
297+
"additionalProperties": true
298+
}
299+
},
300+
"additionalProperties": false
301+
}
302+
]
303+
}
304+
},
305+
"examples": [
306+
[
307+
{
308+
"language": "javascript",
309+
"files": [],
310+
"ignores": ["node_modules/**", "dist/**", "*.test.ts"],
311+
"languageOptions": {
312+
"parserOptions": {
313+
"projectService": false,
314+
"project": ["./tsconfig.json"]
315+
}
316+
},
317+
"rules": {
318+
"@typescript-eslint/no-unsafe-member-access": "error",
319+
"@typescript-eslint/no-floating-promises": "warn",
320+
"@typescript-eslint/promise-function-async": [
321+
"warn",
322+
{ "allowAny": true }
323+
]
324+
},
325+
"plugins": ["@typescript-eslint"]
326+
}
327+
]
328+
]
329+
}

rslint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[
22
{
3-
"language": "javascript", // includes typescript & javascript, we may support register other language in the future
3+
"language": "javascript",
44
"files": [], // extra files out of tsconfig.json
55
"ignores": [
66
"node_modules/**",

0 commit comments

Comments
 (0)