PR feedback
parent
a6c12ca7a9
commit
6abdd2c6b7
|
@ -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.
|
||||
|
||||
|
@ -106,8 +106,8 @@ Valid options:
|
|||
* `"always"` - Always include parens. Example: `(x) => x`
|
||||
|
||||
| Default | CLI Override | API Override |
|
||||
| --------- | --------------------------------------------------------- | ------------------------------------------------------- |
|
||||
| `"avoid"` | <code>--arrow-function-parens <avoid|always></code> | <code>arrowFunctionParentheses: "<avoid|always>"</code> |
|
||||
| --------- | ----------------------------------------------- | ----------------------------------------------- |
|
||||
| `"avoid"` | <code>--arrow-parens <avoid|always></code> | <code>arrowParens: "<avoid|always>"</code> |
|
||||
|
||||
## Range
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -22,7 +22,7 @@ const defaults = {
|
|||
requirePragma: false,
|
||||
semi: true,
|
||||
proseWrap: true,
|
||||
arrowFunctionParentheses: "avoid"
|
||||
arrowParens: "avoid"
|
||||
};
|
||||
|
||||
const exampleConfig = Object.assign({}, defaults, {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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"]);
|
||||
|
|
|
@ -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"
|
||||
]);
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
run_spec(__dirname, null, ["typescript"]);
|
||||
run_spec(__dirname, { arrowFunctionParentheses: "always" }, ["typescript"]);
|
||||
run_spec(__dirname, { arrowParens: "always" }, ["typescript"]);
|
||||
|
|
Loading…
Reference in New Issue