Correctly place trailing comments in conditionals (#754)
Previously we would blindly put leading comments of the next expression, but we didn't account for a real trailing comment. By checking if the leadingNode is on the same line, we can correctly put it there when needed Fixes #685master
parent
d613f92f60
commit
5cc21c5498
|
@ -161,8 +161,10 @@ function attach(comments, ast, text) {
|
||||||
if (
|
if (
|
||||||
handleConditionalExpressionComments(
|
handleConditionalExpressionComments(
|
||||||
enclosingNode,
|
enclosingNode,
|
||||||
|
precedingNode,
|
||||||
followingNode,
|
followingNode,
|
||||||
comment
|
comment,
|
||||||
|
text
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
// We're good
|
// We're good
|
||||||
|
@ -382,10 +384,16 @@ function handleMemberExpressionComment(enclosingNode, followingNode, comment) {
|
||||||
|
|
||||||
function handleConditionalExpressionComments(
|
function handleConditionalExpressionComments(
|
||||||
enclosingNode,
|
enclosingNode,
|
||||||
|
precedingNode,
|
||||||
followingNode,
|
followingNode,
|
||||||
comment
|
comment,
|
||||||
|
text
|
||||||
) {
|
) {
|
||||||
|
const isSameLineAsPrecedingNode = precedingNode &&
|
||||||
|
!util.hasNewlineInRange(text, locEnd(precedingNode), locStart(comment));
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
(!precedingNode || !isSameLineAsPrecedingNode) &&
|
||||||
enclosingNode &&
|
enclosingNode &&
|
||||||
enclosingNode.type === "ConditionalExpression" &&
|
enclosingNode.type === "ConditionalExpression" &&
|
||||||
followingNode
|
followingNode
|
||||||
|
|
|
@ -32,6 +32,10 @@ const extractTextPluginOptions = shouldUseRelativeAssetPaths
|
||||||
const extractTextPluginOptions = shouldUseRelativeAssetPaths // Making sure that the publicPath goes back to to build folder.
|
const extractTextPluginOptions = shouldUseRelativeAssetPaths // Making sure that the publicPath goes back to to build folder.
|
||||||
? { publicPath: Array(cssFilename.split(\"/\").length).join(\"../\") }
|
? { publicPath: Array(cssFilename.split(\"/\").length).join(\"../\") }
|
||||||
: {};
|
: {};
|
||||||
|
|
||||||
|
const { configureStore } = process.env.NODE_ENV === \"production\"
|
||||||
|
? require(\"./configureProdStore\") // a
|
||||||
|
: require(\"./configureDevStore\"); // b
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
var inspect = 4 === util.inspect.length
|
var inspect = 4 === util.inspect.length
|
||||||
? // node <= 0.8.x
|
? // node <= 0.8.x
|
||||||
|
@ -63,9 +67,12 @@ const extractTextPluginOptions = shouldUseRelativeAssetPaths
|
||||||
{ publicPath: Array(cssFilename.split(\"/\").length).join(\"../\") }
|
{ publicPath: Array(cssFilename.split(\"/\").length).join(\"../\") }
|
||||||
: {};
|
: {};
|
||||||
|
|
||||||
const extractTextPluginOptions = shouldUseRelativeAssetPaths
|
const extractTextPluginOptions = shouldUseRelativeAssetPaths // Making sure that the publicPath goes back to to build folder.
|
||||||
? // Making sure that the publicPath goes back to to build folder.
|
? { publicPath: Array(cssFilename.split(\"/\").length).join(\"../\") }
|
||||||
{ publicPath: Array(cssFilename.split(\"/\").length).join(\"../\") }
|
|
||||||
: {};
|
: {};
|
||||||
|
|
||||||
|
const { configureStore } = process.env.NODE_ENV === \"production\"
|
||||||
|
? require(\"./configureProdStore\") // a
|
||||||
|
: require(\"./configureDevStore\"); // b
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -31,3 +31,7 @@ const extractTextPluginOptions = shouldUseRelativeAssetPaths
|
||||||
const extractTextPluginOptions = shouldUseRelativeAssetPaths // Making sure that the publicPath goes back to to build folder.
|
const extractTextPluginOptions = shouldUseRelativeAssetPaths // Making sure that the publicPath goes back to to build folder.
|
||||||
? { publicPath: Array(cssFilename.split("/").length).join("../") }
|
? { publicPath: Array(cssFilename.split("/").length).join("../") }
|
||||||
: {};
|
: {};
|
||||||
|
|
||||||
|
const { configureStore } = process.env.NODE_ENV === "production"
|
||||||
|
? require("./configureProdStore") // a
|
||||||
|
: require("./configureDevStore"); // b
|
||||||
|
|
Loading…
Reference in New Issue