Skip to content

Commit d5465e0

Browse files
committed
example(eslint-json-with-metadata): add file under test and report
1 parent 6cbf0c4 commit d5465e0

File tree

2 files changed

+367
-0
lines changed

2 files changed

+367
-0
lines changed

example.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function addOne(i) {
2+
if (i != NaN) {
3+
return i ++
4+
} else {
5+
return
6+
}
7+
};

report.json

Lines changed: 360 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,360 @@
1+
{
2+
"results": [
3+
{
4+
"filePath": "/root/project/eslint/example.js",
5+
"messages": [
6+
{
7+
"ruleId": "no-unused-vars",
8+
"severity": 2,
9+
"message": "'addOne' is defined but never used.",
10+
"line": 1,
11+
"column": 10,
12+
"nodeType": "Identifier",
13+
"endLine": 1,
14+
"endColumn": 16
15+
},
16+
{
17+
"ruleId": "use-isnan",
18+
"severity": 2,
19+
"message": "Use the isNaN function to compare with NaN.",
20+
"line": 2,
21+
"column": 9,
22+
"nodeType": "BinaryExpression",
23+
"messageId": "useIsNaN",
24+
"endLine": 2,
25+
"endColumn": 17
26+
},
27+
{
28+
"ruleId": "space-unary-ops",
29+
"severity": 2,
30+
"message": "Unexpected space before unary operator '++'.",
31+
"line": 3,
32+
"column": 16,
33+
"nodeType": "UpdateExpression",
34+
"messageId": "unexpectedBefore",
35+
"endLine": 3,
36+
"endColumn": 20,
37+
"fix": {"range": [57, 58], "text": ""}
38+
},
39+
{
40+
"ruleId": "semi",
41+
"severity": 1,
42+
"message": "Missing semicolon.",
43+
"line": 3,
44+
"column": 20,
45+
"nodeType": "ReturnStatement",
46+
"fix": {"range": [60, 60], "text": ";"}
47+
},
48+
{
49+
"ruleId": "no-else-return",
50+
"severity": 1,
51+
"message": "Unnecessary 'else' after 'return'.",
52+
"line": 4,
53+
"column": 12,
54+
"nodeType": "BlockStatement",
55+
"messageId": "unexpected",
56+
"endLine": 6,
57+
"endColumn": 6,
58+
"fix": {
59+
"range": [0, 94],
60+
"text": "function addOne(i) {\n if (i != NaN) {\n return i ++\n } \n return\n \n}"
61+
}
62+
},
63+
{
64+
"ruleId": "indent",
65+
"severity": 1,
66+
"message": "Expected indentation of 8 spaces but found 6.",
67+
"line": 5,
68+
"column": 1,
69+
"nodeType": "Keyword",
70+
"messageId": "wrongIndentation",
71+
"endLine": 5,
72+
"endColumn": 7,
73+
"fix": {"range": [74, 80], "text": " "}
74+
},
75+
{
76+
"ruleId": "consistent-return",
77+
"severity": 2,
78+
"message": "Function 'addOne' expected a return value.",
79+
"line": 5,
80+
"column": 7,
81+
"nodeType": "ReturnStatement",
82+
"messageId": "missingReturnValue",
83+
"endLine": 5,
84+
"endColumn": 13
85+
},
86+
{
87+
"ruleId": "semi",
88+
"severity": 1,
89+
"message": "Missing semicolon.",
90+
"line": 5,
91+
"column": 13,
92+
"nodeType": "ReturnStatement",
93+
"fix": {"range": [86, 86], "text": ";"}
94+
},
95+
{
96+
"ruleId": "no-extra-semi",
97+
"severity": 2,
98+
"message": "Unnecessary semicolon.",
99+
"line": 7,
100+
"column": 2,
101+
"nodeType": "EmptyStatement",
102+
"messageId": "unexpected",
103+
"endLine": 7,
104+
"endColumn": 3,
105+
"fix": {"range": [93, 95], "text": "}"}
106+
}
107+
],
108+
"errorCount": 5,
109+
"warningCount": 4,
110+
"fixableErrorCount": 2,
111+
"fixableWarningCount": 4,
112+
"source": "function addOne(i) {\n if (i != NaN) {\n return i ++\n } else {\n return\n }\n};"
113+
}
114+
],
115+
"metadata": {
116+
"rulesMeta": {
117+
"no-else-return": {
118+
"type": "suggestion",
119+
"docs": {
120+
"description": "disallow `else` blocks after `return` statements in `if` statements",
121+
"category": "Best Practices",
122+
"recommended": false,
123+
"url": "https://eslint.org/docs/rules/no-else-return"
124+
},
125+
"schema": [
126+
{
127+
"type": "object",
128+
"properties": {"allowElseIf": {"type": "boolean", "default": true}},
129+
"additionalProperties": false
130+
}
131+
],
132+
"fixable": "code",
133+
"messages": {"unexpected": "Unnecessary 'else' after 'return'."}
134+
},
135+
"indent": {
136+
"type": "layout",
137+
"docs": {
138+
"description": "enforce consistent indentation",
139+
"category": "Stylistic Issues",
140+
"recommended": false,
141+
"url": "https://eslint.org/docs/rules/indent"
142+
},
143+
"fixable": "whitespace",
144+
"schema": [
145+
{"oneOf": [{"enum": ["tab"]}, {"type": "integer", "minimum": 0}]},
146+
{
147+
"type": "object",
148+
"properties": {
149+
"SwitchCase": {"type": "integer", "minimum": 0, "default": 0},
150+
"VariableDeclarator": {
151+
"oneOf": [
152+
{
153+
"oneOf": [
154+
{"type": "integer", "minimum": 0},
155+
{"enum": ["first", "off"]}
156+
]
157+
},
158+
{
159+
"type": "object",
160+
"properties": {
161+
"var": {
162+
"oneOf": [
163+
{"type": "integer", "minimum": 0},
164+
{"enum": ["first", "off"]}
165+
]
166+
},
167+
"let": {
168+
"oneOf": [
169+
{"type": "integer", "minimum": 0},
170+
{"enum": ["first", "off"]}
171+
]
172+
},
173+
"const": {
174+
"oneOf": [
175+
{"type": "integer", "minimum": 0},
176+
{"enum": ["first", "off"]}
177+
]
178+
}
179+
},
180+
"additionalProperties": false
181+
}
182+
]
183+
},
184+
"outerIIFEBody": {"type": "integer", "minimum": 0},
185+
"MemberExpression": {
186+
"oneOf": [{"type": "integer", "minimum": 0}, {"enum": ["off"]}]
187+
},
188+
"FunctionDeclaration": {
189+
"type": "object",
190+
"properties": {
191+
"parameters": {
192+
"oneOf": [
193+
{"type": "integer", "minimum": 0},
194+
{"enum": ["first", "off"]}
195+
]
196+
},
197+
"body": {"type": "integer", "minimum": 0}
198+
},
199+
"additionalProperties": false
200+
},
201+
"FunctionExpression": {
202+
"type": "object",
203+
"properties": {
204+
"parameters": {
205+
"oneOf": [
206+
{"type": "integer", "minimum": 0},
207+
{"enum": ["first", "off"]}
208+
]
209+
},
210+
"body": {"type": "integer", "minimum": 0}
211+
},
212+
"additionalProperties": false
213+
},
214+
"CallExpression": {
215+
"type": "object",
216+
"properties": {
217+
"arguments": {
218+
"oneOf": [
219+
{"type": "integer", "minimum": 0},
220+
{"enum": ["first", "off"]}
221+
]
222+
}
223+
},
224+
"additionalProperties": false
225+
},
226+
"ArrayExpression": {
227+
"oneOf": [
228+
{"type": "integer", "minimum": 0},
229+
{"enum": ["first", "off"]}
230+
]
231+
},
232+
"ObjectExpression": {
233+
"oneOf": [
234+
{"type": "integer", "minimum": 0},
235+
{"enum": ["first", "off"]}
236+
]
237+
},
238+
"ImportDeclaration": {
239+
"oneOf": [
240+
{"type": "integer", "minimum": 0},
241+
{"enum": ["first", "off"]}
242+
]
243+
},
244+
"flatTernaryExpressions": {"type": "boolean", "default": false},
245+
"ignoredNodes": {
246+
"type": "array",
247+
"items": {"type": "string", "not": {"pattern": ":exit$"}}
248+
},
249+
"ignoreComments": {"type": "boolean", "default": false}
250+
},
251+
"additionalProperties": false
252+
}
253+
],
254+
"messages": {"wrongIndentation": "Expected indentation of but found ."}
255+
},
256+
"space-unary-ops": {
257+
"type": "layout",
258+
"docs": {
259+
"description": "enforce consistent spacing before or after unary operators",
260+
"category": "Stylistic Issues",
261+
"recommended": false,
262+
"url": "https://eslint.org/docs/rules/space-unary-ops"
263+
},
264+
"fixable": "whitespace",
265+
"schema": [
266+
{
267+
"type": "object",
268+
"properties": {
269+
"words": {"type": "boolean", "default": true},
270+
"nonwords": {"type": "boolean", "default": false},
271+
"overrides": {
272+
"type": "object",
273+
"additionalProperties": {"type": "boolean"}
274+
}
275+
},
276+
"additionalProperties": false
277+
}
278+
],
279+
"messages": {
280+
"unexpectedBefore": "Unexpected space before unary operator ''.",
281+
"unexpectedAfter": "Unexpected space after unary operator ''.",
282+
"unexpectedAfterWord": "Unexpected space after unary word operator ''.",
283+
"wordOperator": "Unary word operator '' must be followed by whitespace.",
284+
"operator": "Unary operator '' must be followed by whitespace.",
285+
"beforeUnaryExpressions": "Space is required before unary expressions ''."
286+
}
287+
},
288+
"semi": {
289+
"type": "layout",
290+
"docs": {
291+
"description": "require or disallow semicolons instead of ASI",
292+
"category": "Stylistic Issues",
293+
"recommended": false,
294+
"url": "https://eslint.org/docs/rules/semi"
295+
},
296+
"fixable": "code",
297+
"schema": {
298+
"anyOf": [
299+
{
300+
"type": "array",
301+
"items": [
302+
{"enum": ["never"]},
303+
{
304+
"type": "object",
305+
"properties": {
306+
"beforeStatementContinuationChars": {
307+
"enum": ["always", "any", "never"]
308+
}
309+
},
310+
"additionalProperties": false
311+
}
312+
],
313+
"minItems": 0,
314+
"maxItems": 2
315+
},
316+
{
317+
"type": "array",
318+
"items": [
319+
{"enum": ["always"]},
320+
{
321+
"type": "object",
322+
"properties": {"omitLastInOneLineBlock": {"type": "boolean"}},
323+
"additionalProperties": false
324+
}
325+
],
326+
"minItems": 0,
327+
"maxItems": 2
328+
}
329+
]
330+
}
331+
},
332+
"consistent-return": {
333+
"type": "suggestion",
334+
"docs": {
335+
"description": "require `return` statements to either always or never specify values",
336+
"category": "Best Practices",
337+
"recommended": false,
338+
"url": "https://eslint.org/docs/rules/consistent-return"
339+
},
340+
"schema": [
341+
{
342+
"type": "object",
343+
"properties": {
344+
"treatUndefinedAsUnspecified": {
345+
"type": "boolean",
346+
"default": false
347+
}
348+
},
349+
"additionalProperties": false
350+
}
351+
],
352+
"messages": {
353+
"missingReturn": "Expected to return a value at the end of .",
354+
"missingReturnValue": " expected a return value.",
355+
"unexpectedReturnValue": " expected no return value."
356+
}
357+
}
358+
}
359+
}
360+
}

0 commit comments

Comments
 (0)