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

feat!: remove formatters except html, json(-with-metadata), and stylish #17531

Merged
merged 11 commits into from
Dec 20, 2023
8 changes: 4 additions & 4 deletions docs/src/use/command-line-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,16 +502,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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.