question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prettier not respecting `prettier-ignore-start` and `prettier-ignore-end`

See original GitHub issue

Prettier 1.15.2 Playground link

--parser markdown
--prose-wrap never

Input:

- **Sequence of initialization**:
<!-- prettier-ignore-start -->
  #. Firmware
  #. Bootloader (GNU Grub)
  #. Operating System Kernel
  #. Service Manager (e.g. `systemd`)
<!-- prettier-ignore-end -->

Output:

- **Sequence of initialization**:
  <!-- prettier-ignore-start -->
  #. Firmware #. Bootloader (GNU Grub) #. Operating System Kernel #. Service Manager (e.g. `systemd`)
  <!-- prettier-ignore-end -->

Expected behavior: See Input

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:11
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

26reactions
jimmyhorancommented, Jan 28, 2019

I think @anishmittal2020 is onto a great suggestion here. Allowing an explicit range ignore anywhere in any prettier supported file would be very helpful. This kind of implementation is present in many other platform linters and formatters. If you try this out in a prettier playground the range ignore is being ignored 🙈

<!-- prettier-ignore-start -->
<div  class="dark-background">
  </div>
<div class='light-background'></div>
<a href=""/>
<!-- prettier-ignore-end -->

As mentioned above inserting <-- prettier-ignore --> multiple times is not a very nice implementation. A common example would be partials in a HTML file where I would need to do the following…

<!-- prettier-ignore -->
{{ define "title" }}
<!-- prettier-ignore -->
{{ .Title }} &ndash; {{ .Site.Title }}
<!-- prettier-ignore -->
{{ end }}
<!-- prettier-ignore -->
{{ define "main" }}
<!-- prettier-ignore -->
{{ .Content }}
<!-- prettier-ignore -->
{{ end }}

<!-- The rest of my HTML I would like to be formatted -->

Would be much cleaner to be able to do the this…

<!-- prettier-ignore-start -->
{{ define "title" }}
{{ .Title }} &ndash; {{ .Site.Title }}
{{ end }}
{{ define "main" }}
{{ .Content }}
{{ end }}
<!-- prettier-ignore-end -->

<!-- The rest of my HTML I would like to be formatted -->

Is this being worked on by anyone?

4reactions
lamyergeiercommented, Dec 5, 2018

Yes, if we could do prettier ignore for a range at any place in the document, it will be great. I think many people would like that, as I think many people might use other standard (like pandoc) for certain things rarely, but mostly they follow commonmark.

I understand from @duailibe comment that Prettier want’s to enforce standard and weed out nonstandard things. IMHO: In the case of source code, people use prettier to standardize code that can be shared. But in the case of markdown usually, people share the generated HTML or PDF and not markdown. So, I think that this feature can be extended to markdown and limited only to Markdown and not to other language like Javascript etc. If people could use some non-standard markdown, it should be ok as they don’t share the source or the markdown file itself.

Also, sensible people won’t misuse prettier-ignore as they would use it rarely because using this at all the places is as good as not using prettier at all.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ignoring Code - Prettier
Use .prettierignore to ignore (i.e. not reformat) certain files and folders completely. Use “prettier-ignore” comments to ignore parts of files.
Read more >
How to prevent Prettier from breaking test code from 1 line to ...
as the desired following 1-liner: const render = shallow(result).find('UserNotice').find('p');. But prettier keeps reverting it. I tried ...
Read more >
How to configure Prettier and VSCode - Gleb Bahmutov
Not every project uses the same code style, thus it is important to respect the style of whatever project you are currently working...
Read more >
prettier-plugin-go-template - npm
prettier -plugin-go-template. TypeScript icon, indicating that this package has built-in type declarations · Readme · Explore BETA · 1 Dependency · 7 ...
Read more >
@prettier/plugin-xml | Yarn - Package Manager
@prettier/plugin-xml is a prettier plugin for XML. prettier is an opinionated code formatter that supports multiple languages and integrates with most ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found