Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Enable pretty code formatter output #17635

Merged
merged 4 commits into from Oct 11, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 17 additions & 4 deletions templates/formatter-examples.md.ejs
Expand Up @@ -14,7 +14,7 @@ You can specify a formatter using the `--format` or `-f` flag in the CLI. For ex

The built-in formatter options are:

<% Object.keys(formatterResults).forEach(function(formatterName) { -%>
<% Object.keys(formatterResults).forEach(formatterName => { -%>
* [<%= formatterName %>](#<%= formatterName %>)
<% }) -%>

Expand Down Expand Up @@ -56,7 +56,7 @@ npx eslint --format <Add formatter here> fullOfProblems.js
```

## Built-In Formatter Options
<% Object.keys(formatterResults).forEach(function(formatterName) { -%>
<% Object.keys(formatterResults).forEach(formatterName => { -%>

### <%= formatterName %>

Expand All @@ -65,8 +65,21 @@ npx eslint --format <Add formatter here> fullOfProblems.js
Example output:

<% if (formatterName !== "html") { -%>
```text
<%- formatterResults[formatterName].result %>
<%
let codeFormat = "text";
let output = formatterResults[formatterName].result;

if (formatterName.includes("xml")) {
nzakas marked this conversation as resolved.
Show resolved Hide resolved
codeFormat = "xml";
}

if (formatterName.includes("json")) {
codeFormat = "json";
output = JSON.stringify(JSON.parse(output), null, 4);
}
%>
```<%= codeFormat %>
<%- output %>
```
<% } else {-%>
nzakas marked this conversation as resolved.
Show resolved Hide resolved
<iframe src="html-formatter-example.html" width="100%" height="460px"></iframe>
Expand Down