PR feedback

master
Suchipi Izumi 2017-11-27 21:52:49 -07:00
parent a6c12ca7a9
commit 6abdd2c6b7
7 changed files with 13 additions and 12 deletions

View File

@ -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: <bool>` |
# 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"` | <code>--arrow-function-parens <avoid&#124;always></code> | <code>arrowFunctionParentheses: "<avoid&#124;always>"</code> |
| Default | CLI Override | API Override |
| --------- | ----------------------------------------------- | ----------------------------------------------- |
| `"avoid"` | <code>--arrow-parens <avoid&#124;always></code> | <code>arrowParens: "<avoid&#124;always>"</code> |
## Range

View File

@ -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,

View File

@ -22,7 +22,7 @@ const defaults = {
requirePragma: false,
semi: true,
proseWrap: true,
arrowFunctionParentheses: "avoid"
arrowParens: "avoid"
};
const exampleConfig = Object.assign({}, defaults, {

View File

@ -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;
}

View File

@ -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"]);

View File

@ -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"
]);

View File

@ -1,2 +1,2 @@
run_spec(__dirname, null, ["typescript"]);
run_spec(__dirname, { arrowFunctionParentheses: "always" }, ["typescript"]);
run_spec(__dirname, { arrowParens: "always" }, ["typescript"]);