-
-
Notifications
You must be signed in to change notification settings - Fork 666
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the rules to support "v-is". (#1254)
* Change the rules to support "v-is". - Change the `vue/attributes-order` rule to handle `v-is` as `DEFINITION` category. - Change the `vue/no-unregistered-components` rule to handle `v-is` like `:is`. - Change the `vue/no-unused-components` rule to handle `v-is` like `:is`. * Add `"v-is"` to the syntax checked by the `vue/no-unsupported-features` rule.
- Loading branch information
Showing
12 changed files
with
138 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @author Yosuke Ota | ||
* See LICENSE file in root directory for full license. | ||
*/ | ||
'use strict' | ||
module.exports = { | ||
supported: '3.0.0', | ||
/** @param {RuleContext} context @returns {TemplateListener} */ | ||
createTemplateBodyVisitor(context) { | ||
/** | ||
* Reports `v-is` node | ||
* @param {VDirective} vSlotAttr node of `v-is` | ||
* @returns {void} | ||
*/ | ||
function reportVSlot(vSlotAttr) { | ||
context.report({ | ||
node: vSlotAttr.key, | ||
messageId: 'forbiddenVIs' | ||
}) | ||
} | ||
|
||
return { | ||
"VAttribute[directive=true][key.name.name='is']": reportVSlot | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* @author Yosuke Ota | ||
* See LICENSE file in root directory for full license. | ||
*/ | ||
'use strict' | ||
|
||
const RuleTester = require('eslint').RuleTester | ||
const rule = require('../../../../lib/rules/no-unsupported-features') | ||
const utils = require('./utils') | ||
|
||
const buildOptions = utils.optionsBuilder('v-is', '^2.6.0') | ||
const tester = new RuleTester({ | ||
parser: require.resolve('vue-eslint-parser'), | ||
parserOptions: { | ||
ecmaVersion: 2019 | ||
} | ||
}) | ||
|
||
tester.run('no-unsupported-features/v-is', rule, { | ||
valid: [ | ||
{ | ||
code: ` | ||
<template> | ||
<div v-is="foo" /> | ||
</template>`, | ||
options: buildOptions({ version: '^3.0.0' }) | ||
}, | ||
{ | ||
code: ` | ||
<template> | ||
<div :is="foo" /> | ||
</template>`, | ||
options: buildOptions() | ||
}, | ||
{ | ||
code: ` | ||
<template> | ||
<div v-is="foo" /> | ||
</template>`, | ||
options: buildOptions({ version: '^2.5.0', ignores: ['v-is'] }) | ||
} | ||
], | ||
invalid: [ | ||
{ | ||
code: ` | ||
<template> | ||
<div v-is="foo" /> | ||
</template>`, | ||
options: buildOptions(), | ||
errors: [ | ||
{ | ||
message: '`v-is` are not supported until Vue.js "3.0.0".', | ||
line: 3 | ||
} | ||
] | ||
} | ||
] | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters