Skip to content
Permalink
Browse files
Breaking: Drop codeframe and table formatters (#14316)
* Drop `codeframe` formatter

* Drop `table` formatter

* Inform user of removal

Easy upgrades FTW

* Fix suggestion

* Fix test name
  • Loading branch information
fregante committed Aug 5, 2021
1 parent f3cb320 commit 86bb63b370e0ff350e988a5fa228a8234abe800c
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 1,114 deletions.
@@ -1081,14 +1081,12 @@ const isIgnored = cli.isPathIgnored("foo/bar.js");
Retrieves a formatter, which you can then use to format a report object. The argument is either the name of a built-in formatter:

* "[checkstyle](../user-guide/formatters#checkstyle)"
* "[codeframe](../user-guide/formatters#codeframe)"
* "[compact](../user-guide/formatters#compact)"
* "[html](../user-guide/formatters#html)"
* "[jslint-xml](../user-guide/formatters#jslint-xml)"
* "[json](../user-guide/formatters#json)"
* "[junit](../user-guide/formatters#junit)"
* "[stylish](../user-guide/formatters#stylish)" (the default)
* "[table](../user-guide/formatters#table)"
* "[tap](../user-guide/formatters#tap)"
* "[unix](../user-guide/formatters#unix)"
* "[visualstudio](../user-guide/formatters#visualstudio)"
@@ -338,14 +338,12 @@ When specified, the given format is output into the provided file name.
This option specifies the output format for the console. Possible formats are:

* [checkstyle](formatters.md/#checkstyle)
* [codeframe](formatters.md/#codeframe)
* [compact](formatters.md/#compact)
* [html](formatters.md/#html)
* [jslint-xml](formatters.md/#jslint-xml)
* [json](formatters.md/#json)
* [junit](formatters.md/#junit)
* [stylish](formatters.md/#stylish) (the default)
* [table](formatters.md/#table)
* [tap](formatters.md/#tap)
* [unix](formatters.md/#unix)
* [visualstudio](formatters.md/#visualstudio)
@@ -1019,7 +1019,11 @@ class CLIEngine {
try {
return require(formatterPath);
} catch (ex) {
ex.message = `There was a problem loading formatter: ${formatterPath}\nError: ${ex.message}`;
if (format === "table" || format === "codeframe") {
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}`;
}
throw ex;
}

This file was deleted.

This file was deleted.

@@ -43,7 +43,6 @@
"homepage": "https://eslint.org",
"bugs": "https://github.com/eslint/eslint/issues/",
"dependencies": {
"@babel/code-frame": "7.12.11",
"@eslint/eslintrc": "^0.4.3",
"@humanwhocodes/config-array": "^0.5.0",
"ajv": "^6.10.0",
@@ -80,7 +79,6 @@
"semver": "^7.2.1",
"strip-ansi": "^6.0.0",
"strip-json-comments": "^3.1.0",
"table": "^6.0.9",
"text-table": "^0.2.0",
"v8-compile-cache": "^2.0.3"
},
@@ -6,7 +6,7 @@ layout: doc

ESLint comes with several built-in formatters to control the appearance of the linting results, and supports third-party formatters as well.

You can specify a formatter using the `--format` or `-f` flag on the command line. For example, `--format codeframe` uses the `codeframe` formatter.
You can specify a formatter using the `--format` or `-f` flag on the command line. For example, `--format json` uses the `json` formatter.

The built-in formatter options are:

@@ -4643,7 +4643,7 @@ describe("CLIEngine", () => {
assert.isFunction(formatter);
});

it("should return null when a customer formatter doesn't exist", () => {
it("should return null when a custom formatter doesn't exist", () => {
const engine = new CLIEngine(),
formatterPath = getFixturePath("formatters", "doesntexist.js"),
fullFormatterPath = path.resolve(formatterPath);
@@ -4662,6 +4662,18 @@ describe("CLIEngine", () => {
}, `There was a problem loading formatter: ${fullFormatterPath}\nError: Cannot find module '${fullFormatterPath}'`);
});

it("should throw when a built-in formatter no longer exists", () => {
const engine = new CLIEngine();

assert.throws(() => {
engine.getFormatter("table");
}, "The table formatter is no longer part of core ESLint. Install it manually with `npm install -D eslint-formatter-table`");

assert.throws(() => {
engine.getFormatter("codeframe");
}, "The codeframe formatter is no longer part of core ESLint. Install it manually with `npm install -D eslint-formatter-codeframe`");
});

it("should throw if the required formatter exists but has an error", () => {
const engine = new CLIEngine(),
formatterPath = getFixturePath("formatters", "broken.js");

0 comments on commit 86bb63b

Please sign in to comment.