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 all commits
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
29 changes: 23 additions & 6 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,19 +56,36 @@ npx eslint --format <Add formatter here> fullOfProblems.js
```

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

### <%= formatterName %>

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

Example output:
if (output.startsWith("\u003C?xml")) {
codeFormat = "xml";
}

<% if (formatterName !== "html") { -%>
```text
<%- formatterResults[formatterName].result %>
if (formatterName.includes("json")) {
codeFormat = "json";
output = JSON.stringify(JSON.parse(output), null, 4);
outputNote = "Example output (formatted for easier reading):";
}
%>
<%= outputNote %>

```<%= codeFormat %>
<%- output %>
```
<% } else {-%>
nzakas marked this conversation as resolved.
Show resolved Hide resolved

Example output:

<iframe src="html-formatter-example.html" width="100%" height="460px"></iframe>
<% } -%>
<% }) -%>