@@ -9,7 +9,7 @@ const utils = require('../utils')
9
9
10
10
/**
11
11
* @typedef {object } SyntaxRule
12
- * @property {string | ((range: semver.Range) => boolean) } supported
12
+ * @property {string } supported
13
13
* @property { (context: RuleContext) => TemplateListener } [createTemplateBodyVisitor]
14
14
* @property { (context: RuleContext) => RuleListener } [createScriptVisitor]
15
15
*/
@@ -28,6 +28,8 @@ const FEATURES = {
28
28
'v-is' : require ( './syntaxes/v-is' )
29
29
}
30
30
31
+ const SYNTAX_NAMES = /** @type {(keyof FEATURES)[] } */ ( Object . keys ( FEATURES ) )
32
+
31
33
const cache = new Map ( )
32
34
/**
33
35
* Get the `semver.Range` object of a given range text.
@@ -71,7 +73,7 @@ module.exports = {
71
73
ignores : {
72
74
type : 'array' ,
73
75
items : {
74
- enum : Object . keys ( FEATURES )
76
+ enum : SYNTAX_NAMES
75
77
} ,
76
78
uniqueItems : true
77
79
}
@@ -82,7 +84,7 @@ module.exports = {
82
84
messages : {
83
85
// Vue.js 2.5.0+
84
86
forbiddenSlotScopeAttribute :
85
- '`slot-scope` are not supported until Vue.js "2.5.0".' ,
87
+ '`slot-scope` are not supported except Vue.js ">= 2.5.0 <3.0 .0".' ,
86
88
// Vue.js 2.6.0+
87
89
forbiddenDynamicDirectiveArguments :
88
90
'Dynamic arguments are not supported until Vue.js "2.6.0".' ,
@@ -119,22 +121,15 @@ module.exports = {
119
121
* @returns {boolean } `true` if it's supporting.
120
122
*/
121
123
function isNotSupportingVersion ( aCase ) {
122
- if ( typeof aCase . supported === 'function' ) {
123
- return ! aCase . supported ( versionRange )
124
- }
125
- return versionRange . intersects ( getSemverRange ( `<${ aCase . supported } ` ) )
124
+ return ! semver . subset ( versionRange , getSemverRange ( aCase . supported ) )
126
125
}
127
126
128
- const syntaxNames = /** @type {(keyof FEATURES)[] } */ ( Object . keys (
129
- FEATURES
130
- ) )
131
-
132
127
/** @type {TemplateListener } */
133
128
let templateBodyVisitor = { }
134
129
/** @type {RuleListener } */
135
130
let scriptVisitor = { }
136
131
137
- for ( const syntaxName of syntaxNames ) {
132
+ for ( const syntaxName of SYNTAX_NAMES ) {
138
133
/** @type {SyntaxRule } */
139
134
const syntax = FEATURES [ syntaxName ]
140
135
if ( ignores . includes ( syntaxName ) || ! isNotSupportingVersion ( syntax ) ) {
0 commit comments