refactor: sort usages

master
ikatyang 2017-09-07 13:39:39 +08:00
parent c337f9bb23
commit be22996fd3
2 changed files with 36 additions and 57 deletions

View File

@ -188,10 +188,12 @@ const options = {
}
};
const optionArray = Object.keys(options).reduce(
(current, name) => current.concat(Object.assign({ name }, options[name])),
[]
);
const optionArray = Object.keys(options)
.sort()
.reduce(
(current, name) => current.concat(Object.assign({ name }, options[name])),
[]
);
const booleanOptionNames = optionArray
.filter(option => option.isFormatOption && option.type === "boolean")
@ -241,33 +243,9 @@ Usage: prettier [opts] [filename ...]
Available options:
${indent(
[
"write",
"list-different",
"config",
"config-precedence",
"no-config",
"find-config-path",
"ignore-path",
"stdin",
"stdin-filepath",
"print-width",
"tab-width",
"use-tabs",
"no-semi",
"single-quote",
"no-bracket-spacing",
"jsx-bracket-same-line",
"trailing-comma",
"parser",
"cursor-offset",
"range-start",
"range-end",
"no-color",
"with-node-modules",
"version"
]
.map(name => createOptionUsage(name, options[name]))
optionArray
.filter(option => !option.isHidden)
.map(option => createOptionUsage(option.name, option))
.join("\n"),
2
)}

View File

@ -4,8 +4,6 @@ exports[`show usage with --help 1`] = `
"Usage: prettier [opts] [filename ...]
Available options:
--write Edit the file in-place. (Beware!)
--list-different or -l Print filenames of files that are different from Prettier formatting.
--config <path> Path to a prettier configuration file (.prettierrc, package.json, prettier.config.js).
--config-precedence <cli-override|file-override|prefer-file>
Defines how config file should be evaluated in combination of CLI options
@ -14,37 +12,40 @@ Available options:
prefer-file | default config => config file (if config file is found) or
default config => CLI options (if no config file is found)
Defaults to cli-override
--no-config Do not look for a configuration file.
--find-config-path <path>
Finds and prints the path to a configuration file for a given input file.
--ignore-path <path> Path to a file containing patterns that describe files to ignore.
Defaults to ./.prettierignore.
--stdin Read input from stdin.
--stdin-filepath <path> Path to the file used to read from stdin.
--print-width <int> Specify the length of line that the printer will wrap on. Defaults to 80.
--tab-width <int> Specify the number of spaces per indentation-level. Defaults to 2.
--use-tabs Indent lines with tabs instead of spaces.
--no-semi Do not print semicolons, except at the beginning of lines which may need them.
--single-quote Use single quotes instead of double quotes.
--no-bracket-spacing Do not print spaces between brackets.
--jsx-bracket-same-line Put > on the last line instead of at a new line.
--trailing-comma <none|es5|all>
Print trailing commas wherever possible when multi-line. Defaults to none.
--parser <flow|babylon|typescript|postcss|json|graphql>
Specify which parse to use. Defaults to babylon.
--cursor-offset <int> Print (to stderr) where a cursor at the given position would move to after formatting.
This option cannot be used with --range-start and --range-end
--range-start <int> Format code starting at a given character offset.
The range will extend backwards to the start of the first line containing the selected statement.
This option cannot be used with --cursor-offset.
Defaults to 0.
--find-config-path <path>
Finds and prints the path to a configuration file for a given input file.
--help or -h Show help
--ignore-path <path> Path to a file containing patterns that describe files to ignore.
Defaults to ./.prettierignore.
--jsx-bracket-same-line Put > on the last line instead of at a new line.
--list-different or -l Print filenames of files that are different from Prettier formatting.
--no-bracket-spacing Do not print spaces between brackets.
--no-color Do not colorize error messages.
--no-config Do not look for a configuration file.
--no-semi Do not print semicolons, except at the beginning of lines which may need them.
--parser <flow|babylon|typescript|postcss|json|graphql>
Specify which parse to use. Defaults to babylon.
--print-width <int> Specify the length of line that the printer will wrap on. Defaults to 80.
--range-end <int> Format code ending at a given character offset (exclusive).
The range will extend forwards to the end of the selected statement.
This option cannot be used with --cursor-offset.
Defaults to Infinity.
--no-color Do not colorize error messages.
--with-node-modules Process files inside 'node_modules' directory.
--range-start <int> Format code starting at a given character offset.
The range will extend backwards to the start of the first line containing the selected statement.
This option cannot be used with --cursor-offset.
Defaults to 0.
--single-quote Use single quotes instead of double quotes.
--stdin Read input from stdin.
--stdin-filepath <path> Path to the file used to read from stdin.
--tab-width <int> Specify the number of spaces per indentation-level. Defaults to 2.
--trailing-comma <none|es5|all>
Print trailing commas wherever possible when multi-line. Defaults to none.
--use-tabs Indent lines with tabs instead of spaces.
--version or -v Print Prettier version.
--with-node-modules Process files inside 'node_modules' directory.
--write Edit the file in-place. (Beware!)
"