diff --git a/lib/rules/no-unsupported-features.js b/lib/rules/no-unsupported-features.js
index 6f7a87ab9..9eb00be0e 100644
--- a/lib/rules/no-unsupported-features.js
+++ b/lib/rules/no-unsupported-features.js
@@ -9,7 +9,7 @@ const utils = require('../utils')
/**
* @typedef {object} SyntaxRule
- * @property {string | ((range: semver.Range) => boolean)} supported
+ * @property {string} supported
* @property { (context: RuleContext) => TemplateListener } [createTemplateBodyVisitor]
* @property { (context: RuleContext) => RuleListener } [createScriptVisitor]
*/
@@ -28,6 +28,8 @@ const FEATURES = {
'v-is': require('./syntaxes/v-is')
}
+const SYNTAX_NAMES = /** @type {(keyof FEATURES)[]} */ (Object.keys(FEATURES))
+
const cache = new Map()
/**
* Get the `semver.Range` object of a given range text.
@@ -71,7 +73,7 @@ module.exports = {
ignores: {
type: 'array',
items: {
- enum: Object.keys(FEATURES)
+ enum: SYNTAX_NAMES
},
uniqueItems: true
}
@@ -82,7 +84,7 @@ module.exports = {
messages: {
// Vue.js 2.5.0+
forbiddenSlotScopeAttribute:
- '`slot-scope` are not supported until Vue.js "2.5.0".',
+ '`slot-scope` are not supported except Vue.js ">=2.5.0 <3.0.0".',
// Vue.js 2.6.0+
forbiddenDynamicDirectiveArguments:
'Dynamic arguments are not supported until Vue.js "2.6.0".',
@@ -119,22 +121,15 @@ module.exports = {
* @returns {boolean} `true` if it's supporting.
*/
function isNotSupportingVersion(aCase) {
- if (typeof aCase.supported === 'function') {
- return !aCase.supported(versionRange)
- }
- return versionRange.intersects(getSemverRange(`<${aCase.supported}`))
+ return !semver.subset(versionRange, getSemverRange(aCase.supported))
}
- const syntaxNames = /** @type {(keyof FEATURES)[]} */ (Object.keys(
- FEATURES
- ))
-
/** @type {TemplateListener} */
let templateBodyVisitor = {}
/** @type {RuleListener} */
let scriptVisitor = {}
- for (const syntaxName of syntaxNames) {
+ for (const syntaxName of SYNTAX_NAMES) {
/** @type {SyntaxRule} */
const syntax = FEATURES[syntaxName]
if (ignores.includes(syntaxName) || !isNotSupportingVersion(syntax)) {
diff --git a/lib/rules/syntaxes/dynamic-directive-arguments.js b/lib/rules/syntaxes/dynamic-directive-arguments.js
index 595f70fb9..9a790e9f7 100644
--- a/lib/rules/syntaxes/dynamic-directive-arguments.js
+++ b/lib/rules/syntaxes/dynamic-directive-arguments.js
@@ -4,7 +4,7 @@
*/
'use strict'
module.exports = {
- supported: '2.6.0',
+ supported: '>=2.6.0',
/** @param {RuleContext} context @returns {TemplateListener} */
createTemplateBodyVisitor(context) {
/**
diff --git a/lib/rules/syntaxes/scope-attribute.js b/lib/rules/syntaxes/scope-attribute.js
index c1673c3cc..c356a6750 100644
--- a/lib/rules/syntaxes/scope-attribute.js
+++ b/lib/rules/syntaxes/scope-attribute.js
@@ -5,6 +5,7 @@
'use strict'
module.exports = {
deprecated: '2.5.0',
+ supported: '<3.0.0',
/** @param {RuleContext} context @returns {TemplateListener} */
createTemplateBodyVisitor(context) {
/**
diff --git a/lib/rules/syntaxes/slot-attribute.js b/lib/rules/syntaxes/slot-attribute.js
index 6f38166ee..1ce27484d 100644
--- a/lib/rules/syntaxes/slot-attribute.js
+++ b/lib/rules/syntaxes/slot-attribute.js
@@ -5,6 +5,7 @@
'use strict'
module.exports = {
deprecated: '2.6.0',
+ supported: '<3.0.0',
/** @param {RuleContext} context @returns {TemplateListener} */
createTemplateBodyVisitor(context) {
const sourceCode = context.getSourceCode()
diff --git a/lib/rules/syntaxes/slot-scope-attribute.js b/lib/rules/syntaxes/slot-scope-attribute.js
index 2afd790b6..902b5ded8 100644
--- a/lib/rules/syntaxes/slot-scope-attribute.js
+++ b/lib/rules/syntaxes/slot-scope-attribute.js
@@ -5,7 +5,7 @@
'use strict'
module.exports = {
deprecated: '2.6.0',
- supported: '2.5.0',
+ supported: '>=2.5.0 <3.0.0',
/**
* @param {RuleContext} context
* @param {object} option
diff --git a/lib/rules/syntaxes/v-bind-prop-modifier-shorthand.js b/lib/rules/syntaxes/v-bind-prop-modifier-shorthand.js
index 4038c81a5..219d2b3c9 100644
--- a/lib/rules/syntaxes/v-bind-prop-modifier-shorthand.js
+++ b/lib/rules/syntaxes/v-bind-prop-modifier-shorthand.js
@@ -3,15 +3,9 @@
* See LICENSE file in root directory for full license.
*/
'use strict'
-const semver = require('semver')
-const unsupported = new semver.Range('<=2.5 || >=2.6.0')
module.exports = {
- // >=2.6.0-beta.1 <=2.6.0-beta.3
- /** @param {semver.Range} versionRange */
- supported: (versionRange) => {
- return !versionRange.intersects(unsupported)
- },
+ supported: '>=2.6.0-beta.1 <=2.6.0-beta.3',
/** @param {RuleContext} context @returns {TemplateListener} */
createTemplateBodyVisitor(context) {
/**
diff --git a/lib/rules/syntaxes/v-is.js b/lib/rules/syntaxes/v-is.js
index a974b820f..9aeeb8d7e 100644
--- a/lib/rules/syntaxes/v-is.js
+++ b/lib/rules/syntaxes/v-is.js
@@ -4,7 +4,7 @@
*/
'use strict'
module.exports = {
- supported: '3.0.0',
+ supported: '>=3.0.0',
/** @param {RuleContext} context @returns {TemplateListener} */
createTemplateBodyVisitor(context) {
/**
diff --git a/lib/rules/syntaxes/v-model-argument.js b/lib/rules/syntaxes/v-model-argument.js
index bba028e12..d1bd59738 100644
--- a/lib/rules/syntaxes/v-model-argument.js
+++ b/lib/rules/syntaxes/v-model-argument.js
@@ -5,7 +5,7 @@
'use strict'
module.exports = {
- supported: '3.0.0',
+ supported: '>=3.0.0',
/** @param {RuleContext} context @returns {TemplateListener} */
createTemplateBodyVisitor(context) {
return {
diff --git a/lib/rules/syntaxes/v-model-custom-modifiers.js b/lib/rules/syntaxes/v-model-custom-modifiers.js
index 5630f9ad4..d11116b2d 100644
--- a/lib/rules/syntaxes/v-model-custom-modifiers.js
+++ b/lib/rules/syntaxes/v-model-custom-modifiers.js
@@ -11,7 +11,7 @@
const BUILTIN_MODIFIERS = new Set(['lazy', 'number', 'trim'])
module.exports = {
- supported: '3.0.0',
+ supported: '>=3.0.0',
/** @param {RuleContext} context @returns {TemplateListener} */
createTemplateBodyVisitor(context) {
return {
diff --git a/lib/rules/syntaxes/v-slot.js b/lib/rules/syntaxes/v-slot.js
index ae71dc9de..9a9ba1fba 100644
--- a/lib/rules/syntaxes/v-slot.js
+++ b/lib/rules/syntaxes/v-slot.js
@@ -4,7 +4,7 @@
*/
'use strict'
module.exports = {
- supported: '2.6.0',
+ supported: '>=2.6.0',
/** @param {RuleContext} context @returns {TemplateListener} */
createTemplateBodyVisitor(context) {
const sourceCode = context.getSourceCode()
diff --git a/tests/lib/rules/no-unsupported-features/dynamic-directive-arguments.js b/tests/lib/rules/no-unsupported-features/dynamic-directive-arguments.js
index 5dd9bba77..61b39e738 100644
--- a/tests/lib/rules/no-unsupported-features/dynamic-directive-arguments.js
+++ b/tests/lib/rules/no-unsupported-features/dynamic-directive-arguments.js
@@ -54,7 +54,7 @@ tester.run('no-unsupported-features/dynamic-directive-arguments', rule, {
`,
- options: buildOptions({ version: '2.6.0-beta.2' })
+ options: buildOptions({ version: '^3.0.0' })
}
],
invalid: [
diff --git a/tests/lib/rules/no-unsupported-features/slot-scope-attribute.js b/tests/lib/rules/no-unsupported-features/slot-scope-attribute.js
index f9be7a006..5307aa616 100644
--- a/tests/lib/rules/no-unsupported-features/slot-scope-attribute.js
+++ b/tests/lib/rules/no-unsupported-features/slot-scope-attribute.js
@@ -70,7 +70,8 @@ tester.run('no-unsupported-features/slot-scope-attribute', rule, {
output: null,
errors: [
{
- message: '`slot-scope` are not supported until Vue.js "2.5.0".',
+ message:
+ '`slot-scope` are not supported except Vue.js ">=2.5.0 <3.0.0".',
line: 4
}
]
@@ -86,7 +87,25 @@ tester.run('no-unsupported-features/slot-scope-attribute', rule, {
output: null,
errors: [
{
- message: '`slot-scope` are not supported until Vue.js "2.5.0".',
+ message:
+ '`slot-scope` are not supported except Vue.js ">=2.5.0 <3.0.0".',
+ line: 4
+ }
+ ]
+ },
+ {
+ code: `
+
+
+
+
+ `,
+ options: buildOptions({ version: '^3.0.0' }),
+ output: null,
+ errors: [
+ {
+ message:
+ '`slot-scope` are not supported except Vue.js ">=2.5.0 <3.0.0".',
line: 4
}
]
diff --git a/tests/lib/rules/no-unsupported-features/v-slot.js b/tests/lib/rules/no-unsupported-features/v-slot.js
index 6874731bd..66b3b0b9e 100644
--- a/tests/lib/rules/no-unsupported-features/v-slot.js
+++ b/tests/lib/rules/no-unsupported-features/v-slot.js
@@ -70,7 +70,7 @@ tester.run('no-unsupported-features/v-slot', rule, {
`,
- options: buildOptions({ version: '2.6.0-beta.2' })
+ options: buildOptions({ version: '^3.0.0' })
}
],
invalid: [