-
-
Notifications
You must be signed in to change notification settings - Fork 681
New: directive comments (fixes #260) #320
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing! Really good stuff 👍 Clever approach
|
||
```html | ||
<template> | ||
<!-- eslint-disable-next-line vue/max-attributes-per-line --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also add this information in README
docs/rules/comment-directive.md
Outdated
</template> | ||
``` | ||
|
||
This rule doesn't make any warning. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't throw
docs/rules/comment-directive.md
Outdated
@@ -0,0 +1,24 @@ | |||
# support comment-directives in `<template>` (comment-directive) | |||
|
|||
This rule supports the following comment directives in `<template>`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sole purpose of this rule is to provide `eslint-disable` functionality in `<template>`.
It supports usage of the following comments:
...
Plus I think you should add quick information of how this works actually, because it might be a bit confusing for people to see a rule, that actually has nothing in common with any other rule :D
it('disable all rules if <!-- eslint-disable -->', () => { | ||
const code = ` | ||
<template> | ||
<!-- eslint-disable --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you perhaps add few more examples with nested/multiline elements like e.g.:
<template>
<ul>
<li v-for="item in items" <!-- eslint-disable-line -->
:class="item.class"
:title="item.title"
<!-- eslint-disable-next-line -->
title="test"
/>
</ul>
</template>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just an invalid HTML code. Some no-parsing-error
warnings will be shown.
Thank you for the review. I updated docs. |
cf21e90
to
b68f9c0
Compare
b68f9c0
to
3afe9ce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect! Thank you @mysticatea 🥇
Fixes #260.
This PR adds supports of directive comments in
<template>
:<!-- eslint-disable -->
<!-- eslint-enable -->
<!-- eslint-disable-line -->
<!-- eslint-disable-next-line -->
The mechanism is:
vue/directive-comment
rule reports those comments.vue/directive-comment
errors and the reported errors in disabled areas.This PR adds
vue/directive-comment
rule tobase
category, but the rule doesn't report any errors (as more exact, allvue/directive-comment
errors are removed in post-process), so it doesn't break user's CI builds.