forked from eslint/eslint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformatter-examples.md.ejs
57 lines (46 loc) · 1.21 KB
/
formatter-examples.md.ejs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
title: Documentation
layout: doc
---
# ESLint Formatters
ESLint comes with several built-in formatters to control the appearance of the linting results, and supports third-party formatters as well.
The built-in formatter options are:
<% Object.keys(formatterResults).forEach(function(formatterName) { -%>
* [<%= formatterName %>](#<%= formatterName %>)
<% }) -%>
## Example Source
Examples of each formatter were created from linting `fullOfProblems.js` using the `.eslintrc` configuration shown below.
### `fullOfProblems.js`
```js
function addOne(i) {
if (i != NaN) {
return i ++
} else {
return
}
};
```
### `.eslintrc`:
```json
{
"extends": "eslint:recommended",
"rules": {
"consistent-return": 2,
"indent" : [1, 4],
"no-else-return" : 1,
"semi" : [1, "always"],
"space-unary-ops" : 2
}
}
```
## Output Examples
<% Object.keys(formatterResults).forEach(function(formatterName) { -%>
### <%= formatterName %>
<% if (formatterName !== "html") { -%>
```
<%- formatterResults[formatterName].result %>
```
<% } else {-%>
<iframe src="html-formatter-example.html" width="100%" height="460px"></iframe>
<% } -%>
<% }) -%>