refactor: put `no-option` after `option`
parent
0c3fe2bc9f
commit
1a4aac8f9b
|
@ -327,10 +327,10 @@ function formatFiles(argv) {
|
|||
function createUsage() {
|
||||
const options = constant.detailOptions.filter(option => !option.hidden);
|
||||
|
||||
const groupedUsages = options.reduce((current, option) => {
|
||||
const groupedOptions = options.reduce((current, option) => {
|
||||
const category = capitalize(option.category);
|
||||
const group = (current[category] = current[category] || []);
|
||||
group.push(createOptionUsage(option, 25));
|
||||
group.push(option);
|
||||
return current;
|
||||
}, {});
|
||||
|
||||
|
@ -338,17 +338,32 @@ function createUsage() {
|
|||
|
||||
const categoryOrder = ["Command", "Format", "Config", "Other"];
|
||||
|
||||
Object.keys(groupedUsages).forEach(category => {
|
||||
Object.keys(groupedOptions).forEach(category => {
|
||||
if (categoryOrder.indexOf(category) === -1) {
|
||||
// put unordered category before 'Other'
|
||||
categoryOrder.splice(-1, 0, category);
|
||||
}
|
||||
|
||||
groupedOptions[category].sort((a, b) => {
|
||||
const isNoA = a.name.startsWith("no-");
|
||||
const originalA = isNoA ? a.name.slice(3) : a.name;
|
||||
const isNoB = b.name.startsWith("no-");
|
||||
const originalB = isNoB ? b.name.slice(3) : b.name;
|
||||
|
||||
return originalA === originalB
|
||||
? // put `no-option` after `option`
|
||||
isNoA - isNoB
|
||||
: // treat `no-option` as `option`
|
||||
originalA.localeCompare(originalB);
|
||||
});
|
||||
});
|
||||
|
||||
usage += categoryOrder
|
||||
.map(category => {
|
||||
return `${category} options:\n\n${indent(
|
||||
groupedUsages[category].join("\n"),
|
||||
groupedOptions[category]
|
||||
.map(option => createOptionUsage(option, 25))
|
||||
.join("\n"),
|
||||
2
|
||||
)}`;
|
||||
})
|
||||
|
|
|
@ -14,9 +14,8 @@ Command options:
|
|||
|
||||
Format options:
|
||||
|
||||
--jsx-bracket-same-line Put > on the last line instead of at a new line.
|
||||
--no-bracket-spacing Do not print spaces between brackets.
|
||||
--no-semi Do not print semicolons, except at the beginning of lines which may need them.
|
||||
--jsx-bracket-same-line Put > on the last line instead of at a new line.
|
||||
--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.
|
||||
|
@ -28,6 +27,7 @@ Format options:
|
|||
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.
|
||||
--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.
|
||||
--tab-width <int> Specify the number of spaces per indentation-level. Defaults to 2.
|
||||
--trailing-comma <none|es5|all>
|
||||
|
@ -37,6 +37,7 @@ Format options:
|
|||
Config options:
|
||||
|
||||
--config <path> Path to a prettier configuration file (.prettierrc, package.json, prettier.config.js).
|
||||
--no-config Do not look for a configuration file.
|
||||
--config-precedence <cli-override|file-override|prefer-file>
|
||||
Defines how config file should be evaluated in combination of CLI options
|
||||
cli-override | default config => config file => CLI options
|
||||
|
@ -46,14 +47,13 @@ Config options:
|
|||
Defaults to cli-override
|
||||
--ignore-path <path> Path to a file containing patterns that describe files to ignore.
|
||||
Defaults to ./.prettierignore.
|
||||
--no-config Do not look for a configuration file.
|
||||
--with-node-modules Process files inside 'node_modules' directory.
|
||||
|
||||
Other options:
|
||||
|
||||
--no-color Do not colorize error messages.
|
||||
--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
|
||||
--no-color Do not colorize error messages.
|
||||
--stdin Read input from stdin.
|
||||
--stdin-filepath <path> Path to the file used to read from stdin.
|
||||
|
||||
|
@ -75,9 +75,8 @@ Command options:
|
|||
|
||||
Format options:
|
||||
|
||||
--jsx-bracket-same-line Put > on the last line instead of at a new line.
|
||||
--no-bracket-spacing Do not print spaces between brackets.
|
||||
--no-semi Do not print semicolons, except at the beginning of lines which may need them.
|
||||
--jsx-bracket-same-line Put > on the last line instead of at a new line.
|
||||
--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.
|
||||
|
@ -89,6 +88,7 @@ Format options:
|
|||
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.
|
||||
--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.
|
||||
--tab-width <int> Specify the number of spaces per indentation-level. Defaults to 2.
|
||||
--trailing-comma <none|es5|all>
|
||||
|
@ -98,6 +98,7 @@ Format options:
|
|||
Config options:
|
||||
|
||||
--config <path> Path to a prettier configuration file (.prettierrc, package.json, prettier.config.js).
|
||||
--no-config Do not look for a configuration file.
|
||||
--config-precedence <cli-override|file-override|prefer-file>
|
||||
Defines how config file should be evaluated in combination of CLI options
|
||||
cli-override | default config => config file => CLI options
|
||||
|
@ -107,14 +108,13 @@ Config options:
|
|||
Defaults to cli-override
|
||||
--ignore-path <path> Path to a file containing patterns that describe files to ignore.
|
||||
Defaults to ./.prettierignore.
|
||||
--no-config Do not look for a configuration file.
|
||||
--with-node-modules Process files inside 'node_modules' directory.
|
||||
|
||||
Other options:
|
||||
|
||||
--no-color Do not colorize error messages.
|
||||
--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
|
||||
--no-color Do not colorize error messages.
|
||||
--stdin Read input from stdin.
|
||||
--stdin-filepath <path> Path to the file used to read from stdin.
|
||||
|
||||
|
|
Loading…
Reference in New Issue