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>` |
|
| `false` | `--jsx-bracket-same-line` | `jsxBracketSameLine: <bool>` |
|
||||||
|
|
||||||
# Arrow Function Parentheses
|
## Arrow Function Parentheses
|
||||||
|
|
||||||
Include parentheses around a sole arrow function parameter.
|
Include parentheses around a sole arrow function parameter.
|
||||||
|
|
||||||
|
@ -105,9 +105,9 @@ Valid options:
|
||||||
* `"avoid"` - Omit parens when possible. Example: `x => x`
|
* `"avoid"` - Omit parens when possible. Example: `x => x`
|
||||||
* `"always"` - Always include parens. Example: `(x) => x`
|
* `"always"` - Always include parens. Example: `(x) => x`
|
||||||
|
|
||||||
| Default | CLI Override | API Override |
|
| 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
|
## Range
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ const categoryOrder = [
|
||||||
* Note: The options below are sorted alphabetically.
|
* Note: The options below are sorted alphabetically.
|
||||||
*/
|
*/
|
||||||
const detailedOptions = normalizeDetailedOptions({
|
const detailedOptions = normalizeDetailedOptions({
|
||||||
"arrow-function-parentheses": {
|
"arrow-parens": {
|
||||||
type: "choice",
|
type: "choice",
|
||||||
category: CATEGORY_FORMAT,
|
category: CATEGORY_FORMAT,
|
||||||
forwardToApi: true,
|
forwardToApi: true,
|
||||||
|
|
|
@ -22,7 +22,7 @@ const defaults = {
|
||||||
requirePragma: false,
|
requirePragma: false,
|
||||||
semi: true,
|
semi: true,
|
||||||
proseWrap: true,
|
proseWrap: true,
|
||||||
arrowFunctionParentheses: "avoid"
|
arrowParens: "avoid"
|
||||||
};
|
};
|
||||||
|
|
||||||
const exampleConfig = Object.assign({}, defaults, {
|
const exampleConfig = Object.assign({}, defaults, {
|
||||||
|
|
|
@ -3262,15 +3262,16 @@ function printFunctionParams(path, print, options, expandArg, printTypeParams) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldPrintParamsWithoutParens(path, options) {
|
function shouldPrintParamsWithoutParens(path, options) {
|
||||||
if (options.arrowFunctionParentheses === "always") {
|
if (options.arrowParens === "always") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.arrowFunctionParentheses === "avoid") {
|
if (options.arrowParens === "avoid") {
|
||||||
const node = path.getValue();
|
const node = path.getValue();
|
||||||
return canPrintParamsWithoutParens(node);
|
return canPrintParamsWithoutParens(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback default; should be unreachable
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
run_spec(__dirname, null, ["typescript"]);
|
run_spec(__dirname, null, ["typescript"]);
|
||||||
run_spec(__dirname, { trailingComma: "all" }, ["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"
|
"typescript"
|
||||||
]);
|
]);
|
||||||
run_spec(__dirname, { parser: "babylon", arrowFunctionParentheses: "always" }, [
|
run_spec(__dirname, { parser: "babylon", arrowParens: "always" }, [
|
||||||
"typescript"
|
"typescript"
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
run_spec(__dirname, null, ["typescript"]);
|
run_spec(__dirname, null, ["typescript"]);
|
||||||
run_spec(__dirname, { arrowFunctionParentheses: "always" }, ["typescript"]);
|
run_spec(__dirname, { arrowParens: "always" }, ["typescript"]);
|
||||||
|
|
Loading…
Reference in New Issue