Skip to content

Commit 9f8e549

Browse files
authored
keeping prettier-comments files as close to the source (#466)
1 parent b0c0b9c commit 9f8e549

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/nodes/StringLiteral.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ const { printString } = require('../prettier-comments/common/util');
77

88
const StringLiteral = {
99
print: ({ node, options }) => {
10-
const list = node.parts.map((part, index) =>
11-
printString(part, {
12-
...options,
10+
const list = node.parts.map(
11+
(part, index) =>
1312
// node.isUnicode is an array of the same length as node.parts
1413
// that indicates if that string fragment has the unicode prefix
15-
isUnicode: node.isUnicode[index]
16-
})
14+
(node.isUnicode[index] ? 'unicode' : '') + printString(part, options)
1715
);
1816

1917
return join(line, list);

src/prettier-comments/common/util.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,12 +475,11 @@ function printString(rawContent, options) {
475475
options.parser === "css" ||
476476
options.parser === "less" ||
477477
options.parser === "scss"
478-
),
479-
options.isUnicode
478+
)
480479
);
481480
}
482481

483-
function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes, isUnicode) {
482+
function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
484483
const otherQuote = enclosingQuote === '"' ? "'" : '"';
485484

486485
// Matches _any_ escape and unescaped quotes (both single and double).
@@ -515,7 +514,7 @@ function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes, isUn
515514
: "\\" + escaped;
516515
});
517516

518-
return (isUnicode ? "unicode" : "") + enclosingQuote + newContent + enclosingQuote;
517+
return enclosingQuote + newContent + enclosingQuote;
519518
}
520519

521520
function printNumber(rawNumber) {

0 commit comments

Comments
 (0)