Thanks to visit codestin.com
Credit goes to github.com

Skip to content

πŸ› Vue parser fails when there are attributes after v-elseΒ #8080

@matt1003

Description

@matt1003

Environment information

CLI:
  Version:                      2.3.5
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  BIOME_THREADS:                unset
  NO_COLOR:                     unset
  TERM:                         st-256color
  JS_RUNTIME_VERSION:           v22.20.0
  JS_RUNTIME_NAME:              node
  NODE_PACKAGE_MANAGER:         npm/10.9.3

Biome Configuration:
  Status:                       Loaded successfully
  Path:                         biome.jsonc
  Formatter enabled:            true
  Linter enabled:               true
  Assist enabled:               true
  VCS enabled:                  true

Workspace:
  Open Documents:               0

What happened?

Vue parser spits the dummy with a Expected an attribute but instead found ... error when an else-if directive is proceeded by attributes.

Example:

<template>
  <p v-if="true" class="flex">Hello</p>
  <p v-else class="flex">World</p>
</template>

Error:

biome format --write Test.vue
Test.vue:3:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  βœ– Expected an attribute but instead found 'class="flex">World<'.

    1 β”‚ <template>
    2 β”‚   <p v-if="true" class="flex">Hello</p>
  > 3 β”‚   <p v-else class="flex">World</p>
      β”‚             ^^^^^^^^^^^^^^^^^^^
    4 β”‚ </template>
    5 β”‚

  β„Ή Expected an attribute here.

    1 β”‚ <template>
    2 β”‚   <p v-if="true" class="flex">Hello</p>
  > 3 β”‚   <p v-else class="flex">World</p>
      β”‚             ^^^^^^^^^^^^^^^^^^^
    4 β”‚ </template>
    5 β”‚


Test.vue:3:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  βœ– expected `>` but instead found `p`

    1 β”‚ <template>
    2 β”‚   <p v-if="true" class="flex">Hello</p>
  > 3 β”‚   <p v-else class="flex">World</p>
      β”‚                                 ^
    4 β”‚ </template>
    5 β”‚

  β„Ή Remove p

Playground:

https://biomejs.dev/playground/?indentStyle=space&indentWidth=4&bracketSameLine=true&indentScriptAndStyle=true&code=PAB0AGUAbQBwAGwAYQB0AGUAPgAKACAAIAA8AHAAIAB2AC0AaQBmAD0AIgB0AHIAdQBlACIAIABjAGwAYQBzAHMAPQAiAGYAbABlAHgAIgA%2BAEgAZQBsAGwAbwA8AC8AcAA%2BAAoAIAAgADwAcAAgAHYALQBlAGwAcwBlACAAYwBsAGEAcwBzAD0AIgBmAGwAZQB4ACIAPgBXAG8AcgBsAGQAPAAvAHAAPgAKADwALwB0AGUAbQBwAGwAYQB0AGUAPgAKAA%3D%3D&language=vue

Expected result

It should not throw an error.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

Labels

A-ParserArea: parserL-HTMLLanguage: HTML and super languagesS-Bug-confirmedStatus: report has been confirmed as a valid bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions