]> git.proxmox.com Git - pve-eslint.git/blob - eslint/templates/formatter-examples.md.ejs
import 8.3.0 source
[pve-eslint.git] / eslint / templates / formatter-examples.md.ejs
1 ---
2 title: Documentation
3 layout: doc
4 ---
5 # ESLint Formatters
6
7 ESLint comes with several built-in formatters to control the appearance of the linting results, and supports third-party formatters as well.
8
9 You can specify a formatter using the `--format` or `-f` flag on the command line. For example, `--format json` uses the `json` formatter.
10
11 The built-in formatter options are:
12
13 <% Object.keys(formatterResults).forEach(function(formatterName) { -%>
14 * [<%= formatterName %>](#<%= formatterName %>)
15 <% }) -%>
16
17 ## Example Source
18
19 Examples of each formatter were created from linting `fullOfProblems.js` using the `.eslintrc` configuration shown below.
20
21 ### `fullOfProblems.js`
22
23 ```js
24 function addOne(i) {
25 if (i != NaN) {
26 return i ++
27 } else {
28 return
29 }
30 };
31 ```
32
33 ### `.eslintrc`:
34
35 ```json
36 {
37 "extends": "eslint:recommended",
38 "rules": {
39 "consistent-return": 2,
40 "indent" : [1, 4],
41 "no-else-return" : 1,
42 "semi" : [1, "always"],
43 "space-unary-ops" : 2
44 }
45 }
46 ```
47
48 ## Output Examples
49 <% Object.keys(formatterResults).forEach(function(formatterName) { -%>
50
51 ### <%= formatterName %>
52 <% if (formatterName !== "html") { -%>
53 ```
54 <%- formatterResults[formatterName].result %>
55 ```
56 <% } else {-%>
57 <iframe src="html-formatter-example.html" width="100%" height="460px"></iframe>
58 <% } -%>
59 <% }) -%>