Skip to content

Same rule has different priority in style guide and in eslint-plugin-vue #540

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

Closed
ocavue opened this issue Jul 29, 2018 · 6 comments
Closed

Comments

@ocavue
Copy link
Contributor

ocavue commented Jul 29, 2018

Please describe what the rule should do:

Provide a warning when using v-if on the same element as v-for.

What category of rule is this? (place an "X" next to just one item)

[x] Enforces code style
[ ] Warns about a potential error
[ ] Suggests an alternate way of doing something
[ ] Other (please specify:)

Provide 2-3 code examples that this rule will warn about:

<PostCard
    v-for="page in pages"
    v-if="isVisiblePost(page)"
    :key="page.key"
    :page="page"
    :showContent="false"
    :showLink="true"
/>
<ul>
  <li
    v-for="user in users"
    v-if="shouldShowUsers"
    :key="user.id"
  >
    {{ user.name }}
  <li>
</ul>

Why should this rule be included

  1. Style guide has provided some reasons. This rule's priority is essential, which is the same priority as rule vue/valid-v-for
  2. Because of unknown reason, I found out that if I use v-if with v-for, safari will have some wrong behave. I can bypass it if I follow style guide's suggestion (see link above). Wrong behave in Safari vuepress#678
@mysticatea
Copy link
Member

Thank you for this issue.

I think you are looking for no-use-v-if-with-v-for.

@ocavue
Copy link
Contributor Author

ocavue commented Jul 29, 2018

My bad. vetur didn't show a warning so I thought that there is no such rule. Closing this issue.

@ocavue ocavue closed this as completed Jul 29, 2018
@ocavue
Copy link
Contributor Author

ocavue commented Jul 29, 2018

@mysticatea

I found out that vetur didn't show a warning because no-use-v-if-with-v-for is a "Priority C: Recommended rule" and vetur's default linting configuration is based on eslint-plugin-vue's "Priority A: Essential" set.

no-use-v-if-with-v-for's has a different priority in style guide(beta) and in eslint-plugin-vue. Should these two projects have the same priority for each rule or their priorities are not related?

@mysticatea
Copy link
Member

mysticatea commented Jul 29, 2018

You are right. We should fix it in 5.0.0-beta.x.

@ocavue
Copy link
Contributor Author

ocavue commented Jul 29, 2018

ok, I will reopen this issue and change the title just for reminding.

image

@ocavue ocavue reopened this Jul 29, 2018
@ocavue ocavue changed the title Rule Proposal: Add rule for v-if with v-for Same rule has different priority in style guide and in eslint-plugin-vue Jul 29, 2018
@michalsnik
Copy link
Member

Updated on master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants