Skip to content

Commit

Permalink
feat!: remove formatters except html, json(-with-metadata), and styli…
Browse files Browse the repository at this point in the history
…sh (#17531)

* feat!: remove formatters other than json(-with-metadata) and stylish

* Add back html

* Reset formatters-meta order, and add removedFormatters Set

* Apply suggestions from code review

Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>

* Consolidated removed formatters set

* chore: undo formatters/index.md changes

* Moved back to per-file sets

---------

Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
  • Loading branch information
JoshuaKGoldberg and mdjermanovic committed Dec 20, 2023
1 parent e1e827f commit 5304da0
Show file tree
Hide file tree
Showing 24 changed files with 40 additions and 1,744 deletions.
8 changes: 4 additions & 4 deletions docs/src/use/command-line-interface.md
Expand Up @@ -503,16 +503,16 @@ An npm-installed formatter is resolved with or without `eslint-formatter-` prefi
When specified, the given format is output to the console. If you'd like to save that output into a file, you can do so on the command line like so:

```shell
# Saves the output into the `results.txt` file.
npx eslint -f compact file.js > results.txt
# Saves the output into the `results.json` file.
npx eslint -f json file.js > results.json
```

##### `-f`, `--format` example

Use the built-in `compact` formatter:
Use the built-in `json` formatter:

```shell
npx eslint --format compact file.js
npx eslint --format json file.js
```

Use a local custom formatter:
Expand Down
13 changes: 12 additions & 1 deletion lib/cli-engine/cli-engine.js
Expand Up @@ -41,6 +41,17 @@ const hash = require("./hash");
const LintResultCache = require("./lint-result-cache");

const debug = require("debug")("eslint:cli-engine");
const removedFormatters = new Set([
"checkstyle",
"codeframe",
"compact",
"jslint-xml",
"junit",
"table",
"tap",
"unix",
"visualstudio"
]);
const validFixTypes = new Set(["directive", "problem", "suggestion", "layout"]);

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -1047,7 +1058,7 @@ class CLIEngine {
try {
return require(formatterPath);
} catch (ex) {
if (format === "table" || format === "codeframe") {
if (removedFormatters.has(format)) {
ex.message = `The ${format} formatter is no longer part of core ESLint. Install it manually with \`npm install -D eslint-formatter-${format}\``;
} else {
ex.message = `There was a problem loading formatter: ${formatterPath}\nError: ${ex.message}`;
Expand Down
60 changes: 0 additions & 60 deletions lib/cli-engine/formatters/checkstyle.js

This file was deleted.

60 changes: 0 additions & 60 deletions lib/cli-engine/formatters/compact.js

This file was deleted.

30 changes: 1 addition & 29 deletions lib/cli-engine/formatters/formatters-meta.json
@@ -1,20 +1,8 @@
[
{
"name": "checkstyle",
"description": "Outputs results to the [Checkstyle](https://checkstyle.sourceforge.io/) format."
},
{
"name": "compact",
"description": "Human-readable output format. Mimics the default output of JSHint."
},
{
"name": "html",
"description": "Outputs results to HTML. The `html` formatter is useful for visual presentation in the browser."
},
{
"name": "jslint-xml",
"description": "Outputs results to format compatible with the [JSLint Jenkins plugin](https://plugins.jenkins.io/jslint/)."
},
{
"name": "json-with-metadata",
"description": "Outputs JSON-serialized results. The `json-with-metadata` provides the same linting results as the [`json`](#json) formatter with additional metadata about the rules applied. The linting results are included in the `results` property and the rules metadata is included in the `metadata` property.\n\nAlternatively, you can use the [ESLint Node.js API](../../integrate/nodejs-api) to programmatically use ESLint."
Expand All @@ -23,24 +11,8 @@
"name": "json",
"description": "Outputs JSON-serialized results. The `json` formatter is useful when you want to programmatically work with the CLI's linting results.\n\nAlternatively, you can use the [ESLint Node.js API](../../integrate/nodejs-api) to programmatically use ESLint."
},
{
"name": "junit",
"description": "Outputs results to format compatible with the [JUnit Jenkins plugin](https://plugins.jenkins.io/junit/)."
},
{
"name": "stylish",
"description": "Human-readable output format. This is the default formatter."
},
{
"name": "tap",
"description": "Outputs results to the [Test Anything Protocol (TAP)](https://testanything.org/) specification format."
},
{
"name": "unix",
"description": "Outputs results to a format similar to many commands in UNIX-like systems. Parsable with tools such as [grep](https://www.gnu.org/software/grep/manual/grep.html), [sed](https://www.gnu.org/software/sed/manual/sed.html), and [awk](https://www.gnu.org/software/gawk/manual/gawk.html)."
},
{
"name": "visualstudio",
"description": "Outputs results to format compatible with the integrated terminal of the [Visual Studio](https://visualstudio.microsoft.com/) IDE. When using Visual Studio, you can click on the linting results in the integrated terminal to go to the issue in the source code."
}
]
]
41 changes: 0 additions & 41 deletions lib/cli-engine/formatters/jslint-xml.js

This file was deleted.

82 changes: 0 additions & 82 deletions lib/cli-engine/formatters/junit.js

This file was deleted.

0 comments on commit 5304da0

Please sign in to comment.