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: Does not work when source contains for...of statement (Vue) #129

Closed
dlindenkreuz opened this issue Oct 3, 2020 · 4 comments · Fixed by #132
Closed

Bug: Does not work when source contains for...of statement (Vue) #129

dlindenkreuz opened this issue Oct 3, 2020 · 4 comments · Fixed by #132
Assignees
Labels
framework: Vue Related to the framework Vue type: bug Functionality that does not work as intended/expected

Comments

@dlindenkreuz
Copy link

dlindenkreuz commented Oct 3, 2020

When the pug source code contains a for...of statement, the formatter bails and doesn't do anything in the pug segment.

Replace v-for="x of quux" with v-for="x in quux" in the input and everything works as intended.

Info

Tool Version
Plugin v1.7.0
Prettier v2.1.0
Node v12.18.3
OS mac

Input

<!-- Test.vue -->
<template lang="pug">
.test( foo  bar="123" v-for="x of quux")
  | baz {{ quux}}
</template>

<style scoped lang="scss">
.test {
  color:  red;
}
</style>

<script>


export default {
  name: 'Test',
  data: () => ({quux: 'tobi'}),
};
</script>

Actual Output

<!-- Test.vue -->
<template lang="pug">
.test( foo  bar="123" v-for="x of quux")
  | baz {{ quux}}
</template>

<style scoped lang="scss">
.test {
  color: red;
}
</style>

<script>
export default {
  name: "Test",
  data: () => ({ quux: "tobi" }),
};
</script>

Expected Output

<!-- Test.vue -->
<template lang="pug">
.test(foo, bar="123", v-for="x of quux")
  | baz {{ quux }}
</template>

<style scoped lang="scss">
.test {
  color: red;
}
</style>

<script>
export default {
  name: "Test",
  data: () => ({ quux: "tobi" }),
};
</script>
@Shinigami92
Copy link
Member

I'm sorry that currently other features are in pipeline for 1.8 release, so this needs to wait a bit for 1.9 or so

Some things beside:

Did you mean v-for="x in quux" instead of v-for="x of quux" in expected-section?

Also I need to investigate if this is maybe a bug of prettier itself or maybe just a feature request and not a bug ^^

@dlindenkreuz
Copy link
Author

No worries, take your time.

The expected output contains v-for="x in quux" just like the input. Prettier should not change that.

When the input contains for...in instead of for...of, the output should contain the for...in statement as well.

@Shinigami92 Shinigami92 self-assigned this Oct 4, 2020
@Shinigami92 Shinigami92 added the type: bug Functionality that does not work as intended/expected label Oct 4, 2020
@Shinigami92
Copy link
Member

@dlindenkreuz Ok thanks for reporting
It's a bug, and it's on plugin's side

@Shinigami92
Copy link
Member

Uff..nevermind, confused me by my own written try-catch 🤔
Maybe it is a prettier bug...
Need to dig into it

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

Successfully merging a pull request may close this issue.

2 participants