Skip to content

Revisions for the new --help #44800

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

Merged
merged 14 commits into from
Aug 5, 2021
4 changes: 2 additions & 2 deletions scripts/eslint/rules/boolean-trivia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export = createRule({
const sourceCodeText = sourceCode.getText();

const isSetOrAssert = (name: string): boolean => name.startsWith("set") || name.startsWith("assert");
const isTrivia = (node: TSESTree.CallExpressionArgument): boolean => {
const isTrivia = (node: TSESTree.Node): boolean => {
if (node.type === AST_NODE_TYPES.Identifier) {
return node.name === "undefined";
}
Expand Down Expand Up @@ -69,7 +69,7 @@ export = createRule({
return false;
};

const checkArg = (node: TSESTree.CallExpressionArgument): void => {
const checkArg = (node: TSESTree.Node): void => {
if (!isTrivia(node)) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ namespace ts {
type: "boolean",
showInSimplifiedHelpView: true,
category: Diagnostics.Output_Formatting,
description: Diagnostics.Enable_color_and_formatting_in_output_to_make_compiler_errors_easier_to_read,
description: Diagnostics.Enable_color_and_formatting_in_the_output_to_make_compiler_errors_easier_to_read,
defaultValueDescription: "true"
},
{
Expand Down Expand Up @@ -553,7 +553,7 @@ namespace ts {
type: "boolean",
showInSimplifiedHelpView: true,
category: Diagnostics.Emit,
description: Diagnostics.Disable_emitting_file_from_a_compilation,
description: Diagnostics.Disable_emitting_files_from_a_compilation,
transpileOptionValue: undefined,
defaultValueDescription: "false"
},
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -5507,7 +5507,7 @@
"category": "Message",
"code": 6684
},
"Enable color and formatting in output to make compiler errors easier to read": {
"Enable color and formatting in the output to make compiler errors easier to read": {
"category": "Message",
"code": 6685
},
Expand Down Expand Up @@ -5736,7 +5736,7 @@
"category": "Message",
"code": 6923
},
"Ignoring tsconfig.json, compiles the specified files with default compiler options": {
"Ignoring tsconfig.json, compiles the specified files with default compiler options.": {
"category": "Message",
"code": 6924
},
Expand All @@ -5748,15 +5748,15 @@
"category": "Message",
"code": 6926
},
"Compiles the TypeScript project located at the specified path": {
"Compiles the TypeScript project located at the specified path.": {
"category": "Message",
"code": 6927
},
"An expanded version of this information, showing all possible compiler options": {
"category": "Message",
"code": 6928
},
"Compiles the current project, with additional settings": {
"Compiles the current project, with additional settings.": {
"category": "Message",
"code": 6929
},
Expand Down
21 changes: 17 additions & 4 deletions src/executeCommandLine/executeCommandLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ namespace ts {
}

function createColors(sys: System) {
// https://no-color.org
const supportsRicherColors = sys.getEnvironmentVariable("COLORTERM") === "truecolor" || sys.getEnvironmentVariable("TERM") === "xterm-256color"

const showColors = defaultIsPretty(sys);
if (!showColors) {
return {
Expand All @@ -104,10 +107,20 @@ namespace ts {
return `\x1b[1m${str}\x1b[22m`;
}
function blue(str: string) {
return `\x1b[34m${str}\x1b[39m`;
if (supportsRicherColors) {
return `\x1B[38;5;68m${str}\x1B[39;49m`;
}
else {
return `\x1b[94m${str}\x1b[39m`;
}
}
function blueBackground(str: string) {
return `\x1b[44m${str}\x1b[49m`;
if (supportsRicherColors) {
return `\x1B[48;5;68m${str}\x1B[39;49m`;
}
else {
return `\x1b[44m${str}\x1b[49m`;
}
}
function white(str: string) {
return `\x1b[37m${str}\x1b[39m`;
Expand Down Expand Up @@ -143,7 +156,7 @@ namespace ts {
const terminalWidth = sys.getWidthOfTerminal?.() ?? 0;

// Note: child_process might return `terminalWidth` as undefined.
if (terminalWidth >= 60) {
if (terminalWidth >= 80) {
let description = "";
if (option.description) {
description = getDiagnosticText(option.description);
Expand Down Expand Up @@ -340,7 +353,7 @@ namespace ts {
example("tsc app.ts util.ts", Diagnostics.Ignoring_tsconfig_json_compiles_the_specified_files_with_default_compiler_options);
example("tsc -b", Diagnostics.Build_a_composite_project_in_the_working_directory);
example("tsc --init", Diagnostics.Creates_a_tsconfig_json_with_the_recommended_settings_in_the_working_directory);
example("tsc -p .path/to/tsconfig.json", Diagnostics.Compiles_the_TypeScript_project_located_at_the_specified_path);
example("tsc -p ./path/to/tsconfig.json", Diagnostics.Compiles_the_TypeScript_project_located_at_the_specified_path);
example("tsc --help --all", Diagnostics.An_expanded_version_of_this_information_showing_all_possible_compiler_options);
example(["tsc --noEmit", "tsc --target esnext"], Diagnostics.Compiles_the_current_project_with_additional_settings);

Expand Down