Support "// prettier-ignore" in comment blocks (#1125)
* // prettier-ignore has to be last comment * Add test for #1109master
parent
3ddd6c9271
commit
def91efd16
|
@ -65,7 +65,7 @@ function genericPrint(path, options, printPath) {
|
||||||
if (
|
if (
|
||||||
node.comments &&
|
node.comments &&
|
||||||
node.comments.length > 0 &&
|
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));
|
return options.originalText.slice(util.locStart(node), util.locEnd(node));
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,14 @@ exports[`ignore.js 1`] = `
|
||||||
0, 0, 0
|
0, 0, 0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Let's make sure that this comment doesn't interfere
|
||||||
|
|
||||||
|
// prettier-ignore
|
||||||
|
const commentsWithPrettierIgnore = {
|
||||||
|
\\"ewww\\":
|
||||||
|
\\"gross-formatting\\",
|
||||||
|
};
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
console.error(
|
console.error(
|
||||||
'In order to use ' + prompt + ', you need to configure a ' +
|
'In order to use ' + prompt + ', you need to configure a ' +
|
||||||
|
@ -69,6 +77,14 @@ function a() {
|
||||||
0, 0, 0
|
0, 0, 0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Let's make sure that this comment doesn't interfere
|
||||||
|
|
||||||
|
// prettier-ignore
|
||||||
|
const commentsWithPrettierIgnore = {
|
||||||
|
\\"ewww\\":
|
||||||
|
\\"gross-formatting\\",
|
||||||
|
};
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
console.error(
|
console.error(
|
||||||
'In order to use ' + prompt + ', you need to configure a ' +
|
'In order to use ' + prompt + ', you need to configure a ' +
|
||||||
|
|
|
@ -15,6 +15,14 @@ function a() {
|
||||||
0, 0, 0
|
0, 0, 0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Let's make sure that this comment doesn't interfere
|
||||||
|
|
||||||
|
// prettier-ignore
|
||||||
|
const commentsWithPrettierIgnore = {
|
||||||
|
"ewww":
|
||||||
|
"gross-formatting",
|
||||||
|
};
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
console.error(
|
console.error(
|
||||||
'In order to use ' + prompt + ', you need to configure a ' +
|
'In order to use ' + prompt + ', you need to configure a ' +
|
||||||
|
|
Loading…
Reference in New Issue