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

Breaking: Drop codeframe and table formatters #14316

Merged
merged 8 commits into from Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 0 additions & 2 deletions docs/developer-guide/nodejs-api.md
Expand Up @@ -1059,14 +1059,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)"
Expand Down
2 changes: 0 additions & 2 deletions docs/user-guide/command-line-interface.md
Expand Up @@ -337,14 +337,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)
Expand Down
6 changes: 5 additions & 1 deletion lib/cli-engine/cli-engine.js
Expand Up @@ -1013,7 +1013,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;
}

Expand Down
138 changes: 0 additions & 138 deletions lib/cli-engine/formatters/codeframe.js

This file was deleted.

159 changes: 0 additions & 159 deletions lib/cli-engine/formatters/table.js

This file was deleted.

2 changes: 0 additions & 2 deletions package.json
Expand Up @@ -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.1",
"ajv": "^6.10.0",
"chalk": "^4.0.0",
Expand Down Expand Up @@ -79,7 +78,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"
},
Expand Down
2 changes: 1 addition & 1 deletion templates/formatter-examples.md.ejs
Expand Up @@ -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:

Expand Down
14 changes: 13 additions & 1 deletion tests/lib/cli-engine/cli-engine.js
Expand Up @@ -4628,7 +4628,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);
Expand All @@ -4647,6 +4647,18 @@ describe("CLIEngine", () => {
}, `There was a problem loading formatter: ${fullFormatterPath}\nError: Cannot find module '${fullFormatterPath}'`);
});

it("should return null when a built-in formatter no longer exists", () => {
fregante marked this conversation as resolved.
Show resolved Hide resolved
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");
Expand Down