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

fix(eslint-plugin-vue): [valid-v-bind-sync] Added Case: when valid is then valid .sync #1335

Merged
merged 6 commits into from Dec 4, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion lib/rules/valid-v-bind-sync.js
Expand Up @@ -82,6 +82,20 @@ function maybeNullObjectMemberExpression(node) {
return false
}

function isValidIs(node) {
const { attributes } = node
const isAttribute = attributes.filter((attr) => {
ota-meshi marked this conversation as resolved.
Show resolved Hide resolved
if (attr.type === 'VAttribute' && attr.key.name === 'is') return attr
ota-meshi marked this conversation as resolved.
Show resolved Hide resolved
})
if (
isAttribute.length > 0 &&
['tr', 'li', 'option'].includes(node.parent.name)
ota-meshi marked this conversation as resolved.
Show resolved Hide resolved
) {
return true
}
return false
}

// ------------------------------------------------------------------------------
// Rule Definition
// ------------------------------------------------------------------------------
Expand Down Expand Up @@ -120,7 +134,7 @@ module.exports = {
const element = node.parent.parent
const name = element.name

if (!isValidElement(element)) {
if (!isValidElement(element) && !isValidIs(node.parent)) {
context.report({
node,
loc: node.loc,
Expand Down
14 changes: 14 additions & 0 deletions tests/lib/rules/valid-v-bind-sync.js
Expand Up @@ -145,6 +145,20 @@ tester.run('valid-v-bind-sync', rule, {
{
filename: 'empty-value.vue',
code: '<template><MyComponent :foo.sync="" /></template>'
},
{
filename: 'test.vue',
code: `
<template>
<table>
<tr is="my-row"
:some-prop.sync="somePropValue"
:some-other-prop.sync="someOtherPropValue">
<td></td>
</tr>
</table>
</template>
`
}
],
invalid: [
Expand Down