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.

Indent script and style tags content in *.vue files

See original GitHub issue

Prettier 1.10.2 Playground link

When I have a Vue.js file:

<script>
    export default {
        mounted() {
            console.log('Component mounted!')
        }
    }
</script>

How do I stop prettier changing the indentation to:

<script>
export default {
    mounted() {
        console.log("Component mounted!");
    }
};
</script>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:87
  • Comments:229 (78 by maintainers)

github_iconTop GitHub Comments

87reactions
hawkrivescommented, Feb 4, 2018

For me, I view the contents of a script tag like the contents of any other html tag - I indent its body. So for me, it’s consistency.

71reactions
yyx990803commented, Jan 31, 2019

I personally do not indent <script> and <style> blocks, but I don’t find indenting to have any practical downside so as a framework, Vue does not try to enforce it as a convention.

The fact that people have such strong opinions on this one feels almost like tabs vs. spaces. I understand Prettier’s option philosophy and resistance to adding new options, but in this case:

I believe adding an option could significantly improve Prettier’s adoption in the Vue community (and I do want that to happen).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wrong indentation of <script> and <style> in .vue files
Content of <script> and <style> are indented. Workaround: Add "script" and "style" entries into settings "Editor > Code Style > HTML | Other...
Read more >
vue/script-indent
Rule Details #. This rule enforces a consistent indentation style in <script> . The default style is 2 spaces.
Read more >
Prettier 1.19: Long awaited Vue option, TypeScript 3.7 and ...
The new --vue-indent-script-and-style option controls whether or not to indent the code inside <script> and <style> tags in Vue files. Some ...
Read more >
Prettier on Twitter: "Hey Vue.js community! Do you indent the ...
Hey Vue.js community! Do you indent the contents of the <script> and <style> in the Single File Components? #VueJS. Yes. 57.3%. No. 18.7%....
Read more >
Developers - Indent script and style tags content in *.vue files -
Indent script and style tags content in *.vue files. ... When I have a Vue.js file: <script> export default { mounted() { console.log('Component...
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