diff --git a/src/printer.js b/src/printer.js index 847d0285a..c0f6aa33e 100644 --- a/src/printer.js +++ b/src/printer.js @@ -65,7 +65,7 @@ function genericPrint(path, options, printPath) { if ( node.comments && node.comments.length > 0 && - node.comments[node.comments.length - 1].value.trim() === "prettier-ignore" + node.comments.some(comment => comment.value.trim() === "prettier-ignore") ) { return options.originalText.slice(util.locStart(node), util.locEnd(node)); } diff --git a/tests/ignore/__snapshots__/jsfmt.spec.js.snap b/tests/ignore/__snapshots__/jsfmt.spec.js.snap index b2c170ea4..cfd4c8849 100644 --- a/tests/ignore/__snapshots__/jsfmt.spec.js.snap +++ b/tests/ignore/__snapshots__/jsfmt.spec.js.snap @@ -26,6 +26,11 @@ exports[`ignore.js 1`] = ` \\"gross-formatting\\", }; + function giveMeSome() { + a( a ); // prettier-ignore + // shouldn't I return something? :shrug: + } + // prettier-ignore console.error( 'In order to use ' + prompt + ', you need to configure a ' + @@ -85,6 +90,11 @@ function a() { \\"gross-formatting\\", }; + function giveMeSome() { + a( a ); // prettier-ignore + // shouldn't I return something? :shrug: + } + // prettier-ignore console.error( 'In order to use ' + prompt + ', you need to configure a ' + diff --git a/tests/ignore/ignore.js b/tests/ignore/ignore.js index 9e16dbd98..63fc1e447 100644 --- a/tests/ignore/ignore.js +++ b/tests/ignore/ignore.js @@ -23,6 +23,11 @@ function a() { "gross-formatting", }; + function giveMeSome() { + a( a ); // prettier-ignore + // shouldn't I return something? :shrug: + } + // prettier-ignore console.error( 'In order to use ' + prompt + ', you need to configure a ' +