Template literals: Don't break on identifiers but break if comments (#3299)
parent
d5a3abd7a6
commit
759953ef6d
|
@ -1988,7 +1988,7 @@ function genericPrintNoParens(path, options, print, args) {
|
|||
let printed = expressions[i];
|
||||
|
||||
if (
|
||||
n.expressions[i].type === "Identifier" ||
|
||||
(n.expressions[i].comments && n.expressions[i].comments.length) ||
|
||||
n.expressions[i].type === "MemberExpression" ||
|
||||
n.expressions[i].type === "ConditionalExpression"
|
||||
) {
|
||||
|
|
|
@ -42,8 +42,10 @@ ExampleStory.getFragment('story')}
|
|||
d //comment
|
||||
}
|
||||
|
||||
\${// $FlowFixMe found when converting React.createClass to ES6
|
||||
ExampleStory.getFragment("story")}
|
||||
\${
|
||||
// $FlowFixMe found when converting React.createClass to ES6
|
||||
ExampleStory.getFragment("story")
|
||||
}
|
||||
\`;
|
||||
|
||||
<div>
|
||||
|
|
|
@ -36,17 +36,21 @@ console.log(
|
|||
console.log(\`brew cask audit --download \${_.map(definitions, 'caskName').join(' ')}\`)
|
||||
|
||||
console.log(\`\\nApparently jetbrains changed the release artifact for \${app.name}@\${app.jetbrains.version}.\\n\`);
|
||||
|
||||
descirbe('something', () => {
|
||||
test(\`{pass: false} expect(\${small}).toBeGreaterThanOrEqual(\${big})\`, () => {});
|
||||
})
|
||||
|
||||
throw new Error(\`pretty-format: Option "theme" has a key "\${key}" whose value "\${value}" is undefined in ansi-styles.\`,)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
const long = \`long \${
|
||||
a.b //comment
|
||||
} long longlong \${a.b.c.d.e} long longlong \${a.b.c.d.e} long longlong \${
|
||||
a.b.c.d.e
|
||||
} long long\`;
|
||||
const long = \`long \${a.b.c.d.e} long longlong \${
|
||||
loooooooooooooooooong
|
||||
} long longlong \${loooooooooooooooooong} long longlong \${
|
||||
loooooooooooooooooong
|
||||
} long long\`;
|
||||
const long = \`long \${
|
||||
a.b.c.d.e
|
||||
} long longlong \${loooooooooooooooooong} long longlong \${loooooooooooooooooong} long longlong \${loooooooooooooooooong} long long\`;
|
||||
|
||||
const long = \`long long long long long long long long long long long \${
|
||||
a.b.c.d.e
|
||||
|
@ -94,6 +98,14 @@ console.log(
|
|||
}.\\n\`
|
||||
);
|
||||
|
||||
descirbe("something", () => {
|
||||
test(\`{pass: false} expect(\${small}).toBeGreaterThanOrEqual(\${big})\`, () => {});
|
||||
});
|
||||
|
||||
throw new Error(
|
||||
\`pretty-format: Option "theme" has a key "\${key}" whose value "\${value}" is undefined in ansi-styles.\`
|
||||
);
|
||||
|
||||
`;
|
||||
|
||||
exports[`styled-components-with-expressions.js 1`] = `
|
||||
|
|
|
@ -33,3 +33,9 @@ console.log(
|
|||
console.log(`brew cask audit --download ${_.map(definitions, 'caskName').join(' ')}`)
|
||||
|
||||
console.log(`\nApparently jetbrains changed the release artifact for ${app.name}@${app.jetbrains.version}.\n`);
|
||||
|
||||
descirbe('something', () => {
|
||||
test(`{pass: false} expect(${small}).toBeGreaterThanOrEqual(${big})`, () => {});
|
||||
})
|
||||
|
||||
throw new Error(`pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`,)
|
||||
|
|
Loading…
Reference in New Issue