Do not inline arrow when argument has a leading comment (#1660)
Fixes #1614
This commit is contained in:
1 parent
fa8408b53f
commit
aeed7840e2
3 files changed
+81
-6
No files matched your search
+7
-6
@@ -392,12 +392,13 @@ function genericPrintNoParens(path, options, print, args) {
|
||||
// We want to always keep these types of nodes on the same line
|
||||
// as the arrow.
|
||||
if (
|
||||
n.body.type === "ArrayExpression" ||
|
||||
n.body.type === "ObjectExpression" ||
|
||||
n.body.type === "JSXElement" ||
|
||||
n.body.type === "BlockStatement" ||
|
||||
isTemplateOnItsOwnLine(n.body, options.originalText) ||
|
||||
n.body.type === "ArrowFunctionExpression"
|
||||
!hasLeadingOwnLineComment(options.originalText, n.body) &&
|
||||
(n.body.type === "ArrayExpression" ||
|
||||
n.body.type === "ObjectExpression" ||
|
||||
n.body.type === "JSXElement" ||
|
||||
n.body.type === "BlockStatement" ||
|
||||
isTemplateOnItsOwnLine(n.body, options.originalText) ||
|
||||
n.body.type === "ArrowFunctionExpression")
|
||||
) {
|
||||
return group(collapsed);
|
||||
}
|
||||
|
||||
@@ -239,6 +239,57 @@ jest.mock(
|
||||
|
||||
`;
|
||||
|
||||
exports[`comment.js 1`] = `
|
||||
/**
|
||||
* Curried function that ends with a BEM CSS Selector
|
||||
*
|
||||
* @param {String} block - the BEM Block you'd like to select.
|
||||
* @returns {Function}
|
||||
*/
|
||||
export const bem = block =>
|
||||
/**
|
||||
* @param {String} [element] - the BEM Element within that block; if undefined, selects the block itself.
|
||||
* @returns {Function}
|
||||
*/
|
||||
element =>
|
||||
/**
|
||||
* @param {?String} [modifier] - the BEM Modifier for the Block or Element; if undefined, selects the Block or Element unmodified.
|
||||
* @returns {String}
|
||||
*/
|
||||
modifier =>
|
||||
[
|
||||
".",
|
||||
css(block),
|
||||
element ? \`__\${css(element)}\` : "",
|
||||
modifier ? \`--\${css(modifier)}\` : ""
|
||||
].join("");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/**
|
||||
* Curried function that ends with a BEM CSS Selector
|
||||
*
|
||||
* @param {String} block - the BEM Block you'd like to select.
|
||||
* @returns {Function}
|
||||
*/
|
||||
export const bem = block =>
|
||||
/**
|
||||
* @param {String} [element] - the BEM Element within that block; if undefined, selects the block itself.
|
||||
* @returns {Function}
|
||||
*/
|
||||
element =>
|
||||
/**
|
||||
* @param {?String} [modifier] - the BEM Modifier for the Block or Element; if undefined, selects the Block or Element unmodified.
|
||||
* @returns {String}
|
||||
*/
|
||||
modifier =>
|
||||
[
|
||||
".",
|
||||
css(block),
|
||||
element ? \`__\${css(element)}\` : "",
|
||||
modifier ? \`--\${css(modifier)}\` : ""
|
||||
].join("");
|
||||
|
||||
`;
|
||||
|
||||
exports[`currying.js 1`] = `
|
||||
const fn = b => c => d => {
|
||||
return 3;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Curried function that ends with a BEM CSS Selector
|
||||
*
|
||||
* @param {String} block - the BEM Block you'd like to select.
|
||||
* @returns {Function}
|
||||
*/
|
||||
export const bem = block =>
|
||||
/**
|
||||
* @param {String} [element] - the BEM Element within that block; if undefined, selects the block itself.
|
||||
* @returns {Function}
|
||||
*/
|
||||
element =>
|
||||
/**
|
||||
* @param {?String} [modifier] - the BEM Modifier for the Block or Element; if undefined, selects the Block or Element unmodified.
|
||||
* @returns {String}
|
||||
*/
|
||||
modifier =>
|
||||
[
|
||||
".",
|
||||
css(block),
|
||||
element ? `__${css(element)}` : "",
|
||||
modifier ? `--${css(modifier)}` : ""
|
||||
].join("");
|
||||
Reference in new issue
Block a user