Indent script and style tags content in *.vue files
See original GitHub issuePrettier 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:
- Created 6 years ago
- Reactions:87
- Comments:229 (78 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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:
something being actively requested for over a year with hundreds of comments seem to qualify for “huge demand” compared to precedents (arrow parens, JSX single quotes)
This is currently the most commented issue in the entire Prettier repo.
Quote: “Prettier has to strike a balance between ideal goals and listening to the community.”
I believe adding an option could significantly improve Prettier’s adoption in the Vue community (and I do want that to happen).