-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support prettier-ignore comments inside pug templates #125
Support prettier-ignore comments inside pug templates #125
Conversation
88e6492
to
7dbefa3
Compare
@Shinigami92 I tried to request a review but for some reason, the button doesn't show up on this PR |
It's up for debate if it only ever should ignore the next line, or all nested elements as well (e.g. the 2nd example above, the Personally I find it more pug-like if it affects the nested things as well. That's also how commenting things out works in pug. Happy to discuss! |
Ok I need to investigate why my community cannot request these. Maybe it's a GitHub Teams feature to do so 🤔 But thx for telling me 🙂 |
@Shinigami92 this used to work, I think? Maybe it was something you changed recently? |
Very interesting idea 🤔 I mean I need to look in your current working code 😅 |
The current implementation does that already! 🤣 |
Fucking hell, can I come across the globe and just hug you?! I really start to think about to give both of you (also @SkyaTura) more privileges in my repo But, need to lock into it with IDE in depth |
@lehni and @SkyaTura: If you didn't already noticed -> when creating branches directly in this repo, it's easier for me to check them out and review them with vscode 🙂 Also I think, you can add and change some labels and assignees etc in issues and PRs 🤔 |
I'm away from the computer now. Will write more later. Thanks! |
So if I understood everything correct, the following wouldn't make sense, and therefore is correctly commented? div
//- prettier-ignore | (1)
div
//- prettier-ignore | <-- already ignored be the above one (1)?!
div
div
div
//- prettier-ignore | (2)
div
//- prettier-ignore | <-- already ignored be the above one (2)?!
div
div Should we allow a reason? div
//- prettier-ignore: I want this this way!
div |
Yes, exactly! It's kind of similar to what happens when you comment out a block of pug code: // everything indented underneath will be commented out:
div
div
div
div
div
div
div
Yes, we could simply match |
f15565f
to
40ae906
Compare
I really like that feature, but we should check this against a code base with multiple |
@Shinigami92 I am happy to add more tests for various scenarios of nesting, was thinking the same! But I don't think we need a performance test, and that would be hard to even test reliably (something else could slow down the test runner as it is running these tests and times them. you'd have to run them over and over again). Reasons for why I don't think a test for speed is necessary: When the Bottom line: pug code that contains |
I'm away from the computer mostly today, will wrap this up tomorrow probably! Thanks for the reviews @Shinigami92! |
@lehni I didn't mean an automated test, I just meant a one time study |
7f7f2a8
to
f8df949
Compare
@Shinigami92 I did a little speed test now, using my improved test in const expected: string = readFileSync(resolve(__dirname, 'formatted.pug'), 'utf8');
const code: string = readFileSync(resolve(__dirname, 'unformatted.pug'), 'utf8');
let actual: string = '';
console.time('format')
for (let i = 0; i < 100; i++) {
actual = format(code, { parser: 'pug' as any, plugins: [plugin] });
}
console.timeEnd('format') Here are the times: With handling of So the changes in this PR actually make the processing run twice as fast in this case, because less formatting needs to be performed on the parts that can remain unformatted. This confirms my expectations formulated above, I think. |
I noticed that the above test is a bit tricky because it's slowed down by logging. If I run with the const time = Date.now()
for (let i = 0; i < 100; i++) {
actual = format(code, { parser: 'pug' as any, plugins: [plugin] });
}
expect(Date.now() - time).toBe(0); And with this, I get the following times: master: So not quite twice as fast, but |
@lehni Is something still missing after the conflict has been resolved or can I merge it then? |
Use such comments to prevent automatic formatting of the following line or block: //- prettier-ignore
f8df949
to
7aed907
Compare
@Shinigami92 No this is all good from my side! I've resolved the conflict also. |
Use
//- prettier-ignore
comments to prevent automatic formatting of the following line or block:->