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.

Allow to ignore based on languages

See original GitHub issue

Environments:

  • Prettier Version: 1.15.1

Steps to reproduce:

As a user I want to ignore certain languages that are part of a larger file that I do want to format.

  • App.vue
<template>
  <div id="app">
    <img src="./assets/logo.png">
    <HelloWorld/>
  </div>
</template>

<script>
import HelloWorld from './components/HelloWorld'
export default {
  name: 'App',
  components: {
    HelloWorld
  }
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>

I don’t want to format the HTML template

  • .prettierignore
{
  "languages": ["html"]
}

Expected behavior:

Prettier format the file, but the HTML template.

<template>
  <div id="app">
    <img src="./assets/logo.png">
    <HelloWorld/>
  </div>
</template>

<script>
import HelloWorld from "./components/HelloWorld";
export default {
  name: "App",
  components: {
    HelloWorld
  }
};
</script>

<style>
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>

Actual behavior:

There is no way to ignore a part of a file based on the language.

Related:

#5378

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:21 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
blowsiecommented, Nov 12, 2018

Why isn’t option 1 (use eslint-config-prettier) a good choice for you?

Because using this means no longer following the style guide.

3reactions
blowsiecommented, Nov 12, 2018

Because if I’m not following a predefined style guide, I would have to manage / define my own for other team members to use.

Best practice would be to use the standards defined by the framework.

Read more comments on GitHub >

github_iconTop Results From Across the Web

git - Ignore the same directory structure on multiples path with ...
I have a website linked to Git repository at Bitbucket. This site is multi language but I need to upload to repository only...
Read more >
ignorePlurals API parameter - Algolia
ignorePlurals is used in conjunction with the queryLanguages setting. · You can send ignorePlurals one of 3 values: · For optimum relevance, it...
Read more >
Ignore configuration storage collections? [#2973431] - Drupal
We need to be able to ignore what languages are turned on, because the languages ... Extend the base class from config filter...
Read more >
Ignore HTTP Accept-Language headers - djangosnippets
A little tiny middleware that, when used in multilingual sites, will make Django I18N ignore any Accept-Language headers in the request, ...
Read more >
Ignoring Code - Prettier
Use “prettier-ignore” comments to ignore parts of files. Ignoring Files: .prettierignore. To exclude files from formatting, create a .prettierignore file in the ...
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