Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
feat: use stylish formatter by default (#4872)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Goldberg authored and adidahiya committed Oct 7, 2019
1 parent a108465 commit bfaf3e2
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 13 deletions.
9 changes: 5 additions & 4 deletions docs/usage/cli/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Options:
--print-config print resolved configuration for a file
-r, --rules-dir [rules-dir] rules directory
-s, --formatters-dir [formatters-dir] formatters directory
-t, --format [format] output format (prose, json, stylish, verbose, pmd, msbuild, checkstyle, vso, fileslist, codeFrame)
-t, --format [format] output format (json, stylish, verbose, pmd, prose, msbuild, checkstyle, vso, fileslist, codeFrame)
-q, --quiet hide non "error" severity linting errors from output
--test test that tslint produces the correct output for the specified directory
-p, --project [project] tsconfig.json file
Expand Down Expand Up @@ -113,11 +113,12 @@ tslint accepts the following command-line options:
-t, --format:
The formatter to use to format the results of the linter before
outputting it to stdout or the file passed in --out. The core
formatters are prose (human readable), json (machine readable)
and verbose. prose is the default if this option is not used.
formatters are stylish (colored and human readable), json (machine
readable), and verbose (human readable).
stylish is the default if this option is not used.
Other built-in options include pmd, msbuild, checkstyle, and vso.
Additional formatters can be added and used if the --formatters-dir
option is set.
option is set.`,
-q, --quiet
Hide non "error" severity linting errors from output. This can be
Expand Down
3 changes: 1 addition & 2 deletions src/formatters/verboseFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export class Formatter extends AbstractFormatter {
public static metadata: IFormatterMetadata = {
formatterName: "verbose",
description: "The human-readable formatter which includes the rule name in messages.",
descriptionDetails:
"The output is the same as the prose formatter with the rule name included",
descriptionDetails: "Basic formatter which outputs simple human-readable messages",
sample: "ERROR: (semicolon) myFile.ts[1, 14]: Missing semicolon",
consumer: "human",
};
Expand Down
2 changes: 1 addition & 1 deletion src/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class Linter {
const failures = this.options.quiet ? errors : this.failures;

const formatterName =
this.options.formatter !== undefined ? this.options.formatter : "prose";
this.options.formatter !== undefined ? this.options.formatter : "stylish";
const Formatter = findFormatter(formatterName, this.options.formattersDirectory);
if (Formatter === undefined) {
throw new Error(`formatter '${String(formatterName)}' not found`);
Expand Down
2 changes: 1 addition & 1 deletion src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ async function doLinting(
formatter =
configFile && configFile.linterOptions && configFile.linterOptions.format
? configFile.linterOptions.format
: "prose";
: "stylish";
}

const linter = new Linter(
Expand Down
9 changes: 5 additions & 4 deletions src/tslintCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,14 @@ const options: Option[] = [
name: "format",
type: "string",
describe:
"output format (prose, json, stylish, verbose, pmd, msbuild, checkstyle, vso, fileslist, codeFrame)",
"output format (json, stylish, verbose, pmd, msbuild, checkstyle, vso, fileslist, codeFrame)",
description: dedent`
The formatter to use to format the results of the linter before
outputting it to stdout or the file passed in --out. The core
formatters are prose (human readable), json (machine readable)
and verbose. prose is the default if this option is not used.
Other built-in options include pmd, msbuild, checkstyle, and vso.
formatters are stylish (colored and human readable), json (machine
readable), and verbose (human readable).
stylish is the default if this option is not used.
Other built-in options include pmd, prose, msbuild, checkstyle, and vso.
Additional formatters can be added and used if the --formatters-dir
option is set.`,
},
Expand Down
2 changes: 1 addition & 1 deletion test/executable/executableTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ function execRunnerWithOutput(options: Partial<Options>) {

// tslint:disable-next-line:promise-function-async
function execRunner(options: Partial<Options>, logger: Logger = dummyLogger) {
return run({ exclude: [], files: [], ...options }, logger);
return run({ exclude: [], files: [], format: "prose", ...options }, logger);
}

// tslint:disable-next-line:ban-types
Expand Down
1 change: 1 addition & 0 deletions test/runner/runnerTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const customRulesOptions: Options = {
config: "./test/config/tslint-custom-rules.json",
exclude: [],
files: ["src/test.ts"],
format: "prose",
rulesDirectory: "./test/files/custom-rules",
};

Expand Down

0 comments on commit bfaf3e2

Please sign in to comment.