Skip to content

[feat] enforce Vue block order #1290

@susnux

Description

@susnux

Traditionally the block order in Vue SFC was:

  • template
  • script
  • styles

But nowadays with script setup its a bit mixed between the mentioned order and:

  • script-setup
  • (script) [optional only used for module scope variables]
  • template
  • styles

The later has the benefit that template and styles often belong together and are now easier to jump between without need to skip JS.
Script often is only related to template but not styles.

So because of the mixed styles I would suggest to enforce a order here, either template-script or script-template.
Or at least do so for script-setup.

One example for script-setup could be:

{
  "vue/block-order": ["error", {
    "order": [  "script[setup]", [ "script:not([setup])", "template" ], "style" ]
  }]
}

This only enforces script-setup to come before template but ignore if you still use script and use <template><script> order

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions