From 6abdd2c6b77d46d9b645d93dd85b95847c26933d Mon Sep 17 00:00:00 2001 From: Suchipi Izumi Date: Mon, 27 Nov 2017 21:52:49 -0700 Subject: [PATCH] PR feedback --- docs/options.md | 8 ++++---- src/cli-constant.js | 2 +- src/options.js | 2 +- src/printer.js | 5 +++-- tests/arrow-call/jsfmt.spec.js | 2 +- tests/arrows/jsfmt.spec.js | 4 ++-- tests/test_declarations/jsfmt.spec.js | 2 +- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/options.md b/docs/options.md index b3d83cfd..3f6ca94b 100644 --- a/docs/options.md +++ b/docs/options.md @@ -96,7 +96,7 @@ Put the `>` of a multi-line JSX element at the end of the last line instead of b | ------- | ------------------------- | ---------------------------- | | `false` | `--jsx-bracket-same-line` | `jsxBracketSameLine: ` | -# Arrow Function Parentheses +## Arrow Function Parentheses Include parentheses around a sole arrow function parameter. @@ -105,9 +105,9 @@ Valid options: * `"avoid"` - Omit parens when possible. Example: `x => x` * `"always"` - Always include parens. Example: `(x) => x` -| Default | CLI Override | API Override | -| --------- | --------------------------------------------------------- | ------------------------------------------------------- | -| `"avoid"` | --arrow-function-parens | arrowFunctionParentheses: "" | +| Default | CLI Override | API Override | +| --------- | ----------------------------------------------- | ----------------------------------------------- | +| `"avoid"` | --arrow-parens | arrowParens: "" | ## Range diff --git a/src/cli-constant.js b/src/cli-constant.js index 376c718b..01854069 100644 --- a/src/cli-constant.js +++ b/src/cli-constant.js @@ -77,7 +77,7 @@ const categoryOrder = [ * Note: The options below are sorted alphabetically. */ const detailedOptions = normalizeDetailedOptions({ - "arrow-function-parentheses": { + "arrow-parens": { type: "choice", category: CATEGORY_FORMAT, forwardToApi: true, diff --git a/src/options.js b/src/options.js index 87ba3402..f0d96315 100644 --- a/src/options.js +++ b/src/options.js @@ -22,7 +22,7 @@ const defaults = { requirePragma: false, semi: true, proseWrap: true, - arrowFunctionParentheses: "avoid" + arrowParens: "avoid" }; const exampleConfig = Object.assign({}, defaults, { diff --git a/src/printer.js b/src/printer.js index 1a95b3fc..3ac29dfa 100644 --- a/src/printer.js +++ b/src/printer.js @@ -3262,15 +3262,16 @@ function printFunctionParams(path, print, options, expandArg, printTypeParams) { } function shouldPrintParamsWithoutParens(path, options) { - if (options.arrowFunctionParentheses === "always") { + if (options.arrowParens === "always") { return false; } - if (options.arrowFunctionParentheses === "avoid") { + if (options.arrowParens === "avoid") { const node = path.getValue(); return canPrintParamsWithoutParens(node); } + // Fallback default; should be unreachable return false; } diff --git a/tests/arrow-call/jsfmt.spec.js b/tests/arrow-call/jsfmt.spec.js index db45d986..d2d553f6 100644 --- a/tests/arrow-call/jsfmt.spec.js +++ b/tests/arrow-call/jsfmt.spec.js @@ -1,3 +1,3 @@ run_spec(__dirname, null, ["typescript"]); run_spec(__dirname, { trailingComma: "all" }, ["typescript"]); -run_spec(__dirname, { arrowFunctionParentheses: "always" }, ["typescript"]); +run_spec(__dirname, { arrowParens: "always" }, ["typescript"]); diff --git a/tests/arrows/jsfmt.spec.js b/tests/arrows/jsfmt.spec.js index 5db62db6..460cdeae 100644 --- a/tests/arrows/jsfmt.spec.js +++ b/tests/arrows/jsfmt.spec.js @@ -1,6 +1,6 @@ -run_spec(__dirname, { parser: "babylon", arrowFunctionParentheses: "avoid" }, [ +run_spec(__dirname, { parser: "babylon", arrowParens: "avoid" }, [ "typescript" ]); -run_spec(__dirname, { parser: "babylon", arrowFunctionParentheses: "always" }, [ +run_spec(__dirname, { parser: "babylon", arrowParens: "always" }, [ "typescript" ]); diff --git a/tests/test_declarations/jsfmt.spec.js b/tests/test_declarations/jsfmt.spec.js index e34fd7e4..d5c0967c 100644 --- a/tests/test_declarations/jsfmt.spec.js +++ b/tests/test_declarations/jsfmt.spec.js @@ -1,2 +1,2 @@ run_spec(__dirname, null, ["typescript"]); -run_spec(__dirname, { arrowFunctionParentheses: "always" }, ["typescript"]); +run_spec(__dirname, { arrowParens: "always" }, ["typescript"]);