Skip to content

Base indentation inside <script> and <style> #59

@rndmerle

Description

@rndmerle

🚀 Feature Proposal

Prettier applied on a .vue file will remove the base indentation of <script> and <style> content:

Input:

<script>
  console.log('Hello World!');
</script>

Output:

<script>
console.log('Hello World!');
</script>

Not everyone is happy with this tho: prettier/prettier#3888

Prettyhtml actually do the opposite:

Input:

<script>
console.log('Hello World!');
</script>

Output:

<script>
  console.log('Hello World!');
</script>

Desired output

There are two solutions imo:

  • Follow the current convention established by Vue guidelines and followed by Prettier: remove initial indentation on <script> and <style> content
  • Be flexible and align the base indentation with the first line of the element. For instance:

Input:

<script>
  console.log('Hello');
console.log('World!');
</script>

Output:

<script>
  console.log('Hello');
  console.log('World!');
</script>

Input:

<script>
console.log('Hello');
  console.log('World!');
</script>

Output:

<script>
console.log('Hello');
console.log('World!');
</script>

Motivation

Either respect the current Vue / Prettier convention, or respect the current initial base indentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions