Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Incorrect parenthesis inserts in v-for with element and index #440

Closed
richardsimko opened this issue Apr 28, 2023 · 2 comments
Closed
Labels
framework: Vue Related to the framework Vue type: bug Functionality that does not work as intended/expected

Comments

@richardsimko
Copy link

Info

Tool Version
Plugin v2.4.2
Prettier v2.8.8
Framework vue
Node v19.0.0
OS mac

Prettier config

{
  "pugFramework": "vue"
}

Input

<template lang="pug">
template(v-for="el, i in foo" :key="i")
  div {{ el }}
</template>

<script setup>
  import { ref } from 'vue';

  const foo = ref(['foo']);
</script>

Output or Error

Replace `el,·i·in·foo` with `(el,·i·in·foo)`

Output file:

<template lang="pug">
template(v-for="(el, i in foo)" :key="i")
  div {{ el }}
</template>

<script setup>
  import { ref } from 'vue';

  const foo = ref(['foo']);
</script>

Expected Output

<template lang="pug">
template(v-for="(el, i) in foo" :key="i")
  div {{ el }}
</template>

<script setup>
  import { ref } from 'vue';

  const foo = ref(['foo']);
</script>

Additional Context

The parenthesis ends up wrapping the whole v-for statement instead of just the two loop variables.

@Shinigami92 Shinigami92 added type: bug Functionality that does not work as intended/expected framework: Vue Related to the framework Vue labels Apr 28, 2023
@richardsimko
Copy link
Author

This seems to also appear in a standalone pug file:

input

.test(v-for="a, b in c")
  .inner

output

.test(v-for="(a, b in c)")
  .inner

@richardsimko
Copy link
Author

Sorry, this is a duplicate of #251

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
framework: Vue Related to the framework Vue type: bug Functionality that does not work as intended/expected
Projects
None yet
Development

No branches or pull requests

2 participants