File tree Expand file tree Collapse file tree 1 file changed +23
-6
lines changed Expand file tree Collapse file tree 1 file changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ You can specify a formatter using the `--format` or `-f` flag in the CLI. For ex
14
14
15
15
The built-in formatter options are:
16
16
17
- <% Object .keys (formatterResults).forEach (function ( formatterName ) { -% >
17
+ <% Object .keys (formatterResults).forEach (formatterName => { -% >
18
18
* [< %= formatterName % > ](#< %= formatterName % > )
19
19
< % }) - %>
20
20
@@ -56,19 +56,36 @@ npx eslint --format <Add formatter here> fullOfProblems.js
56
56
```
57
57
58
58
## Built-In Formatter Options
59
- <% Object .keys (formatterResults).forEach (function ( formatterName ) { -% >
59
+ <% Object .keys (formatterResults).forEach (formatterName => { -% >
60
60
61
61
### < %= formatterName % >
62
62
63
63
< %= formatterResults[formatterName].description % >
64
+ < % if (formatterName !== " html" ) { -% >
65
+ < %
66
+ let codeFormat = " text" ;
67
+ let output = formatterResults[formatterName].result ;
68
+ let outputNote = " Example output:" ;
64
69
65
- Example output:
70
+ if (output .startsWith (" \u003C ?xml" )) {
71
+ codeFormat = " xml" ;
72
+ }
66
73
67
- < % if (formatterName !== " html" ) { -% >
68
- ` ` ` text
69
- <%- formatterResults[formatterName].result %>
74
+ if (formatterName .includes (" json" )) {
75
+ codeFormat = " json" ;
76
+ output = JSON .stringify (JSON .parse (output), null , 4 );
77
+ outputNote = " Example output (formatted for easier reading):" ;
78
+ }
79
+ % >
80
+ < %= outputNote % >
81
+
82
+ ` ` ` <%= codeFormat %>
83
+ <%- output %>
70
84
` ` `
71
85
< % } else {-% >
86
+
87
+ Example output:
88
+
72
89
< iframe src= " html-formatter-example.html" width= " 100%" height= " 460px" >< / iframe>
73
90
< % } -% >
74
91
< % }) - %>
You can’t perform that action at this time.
0 commit comments