Support "// prettier-ignore" in comment blocks (#1125)

* // prettier-ignore has to be last comment

* Add test for #1109
master
Eric Clemmons 2017-04-05 12:08:08 -05:00 committed by Christopher Chedeau
parent 3ddd6c9271
commit def91efd16
3 changed files with 25 additions and 1 deletions

View File

@ -65,7 +65,7 @@ function genericPrint(path, options, printPath) {
if (
node.comments &&
node.comments.length > 0 &&
node.comments[0].value.trim() === "prettier-ignore"
node.comments[node.comments.length - 1].value.trim() === "prettier-ignore"
) {
return options.originalText.slice(util.locStart(node), util.locEnd(node));
}

View File

@ -18,6 +18,14 @@ exports[`ignore.js 1`] = `
0, 0, 0
);
// Let's make sure that this comment doesn't interfere
// prettier-ignore
const commentsWithPrettierIgnore = {
\\"ewww\\":
\\"gross-formatting\\",
};
// prettier-ignore
console.error(
'In order to use ' + prompt + ', you need to configure a ' +
@ -69,6 +77,14 @@ function a() {
0, 0, 0
);
// Let's make sure that this comment doesn't interfere
// prettier-ignore
const commentsWithPrettierIgnore = {
\\"ewww\\":
\\"gross-formatting\\",
};
// prettier-ignore
console.error(
'In order to use ' + prompt + ', you need to configure a ' +

View File

@ -15,6 +15,14 @@ function a() {
0, 0, 0
);
// Let's make sure that this comment doesn't interfere
// prettier-ignore
const commentsWithPrettierIgnore = {
"ewww":
"gross-formatting",
};
// prettier-ignore
console.error(
'In order to use ' + prompt + ', you need to configure a ' +