Prettier: `prettier-ignore` is ignored if there is a comment before

Created on 2 Apr 2017  路  3Comments  路  Source: prettier/prettier

This works as expected (the module.exports thing stays untouched by prettier):

console.log('hi');

// prettier-ignore
module.exports = {
  "foo": "bar",
};

But the following doesn't work (module.exports is reformatted):

// Some comment stuff

// prettier-ignore
module.exports = {
  "foo": "bar",
};

easy help wanted locked-due-to-inactivity bug

Most helpful comment

https://github.com/prettier/prettier/blob/60816af4ce6df274b10f3f9cd264a78f1106c48b/src/printer.js#L68

Looks like I only check for the first comment attached to a node. /facepalm

All 3 comments

Here's a live reproduction. Thanks for reporting!

https://github.com/prettier/prettier/blob/60816af4ce6df274b10f3f9cd264a78f1106c48b/src/printer.js#L68

Looks like I only check for the first comment attached to a node. /facepalm

@vjeux Good thing you added "easy" :) #1125 is ready for review, since I had 10 minutes and didn't want to do _real_ work stuff.

Was this page helpful?
0 / 5 - 0 ratings