@@ -9,7 +9,7 @@ const utils = require('../utils')
99
1010/**
1111 * @typedef {object } SyntaxRule
12- * @property {string | ((range: semver.Range) => boolean) } supported
12+ * @property {string } supported
1313 * @property { (context: RuleContext) => TemplateListener } [createTemplateBodyVisitor]
1414 * @property { (context: RuleContext) => RuleListener } [createScriptVisitor]
1515 */
@@ -28,6 +28,8 @@ const FEATURES = {
2828 'v-is' : require ( './syntaxes/v-is' )
2929}
3030
31+ const SYNTAX_NAMES = /** @type {(keyof FEATURES)[] } */ ( Object . keys ( FEATURES ) )
32+
3133const cache = new Map ( )
3234/**
3335 * Get the `semver.Range` object of a given range text.
@@ -71,7 +73,7 @@ module.exports = {
7173 ignores : {
7274 type : 'array' ,
7375 items : {
74- enum : Object . keys ( FEATURES )
76+ enum : SYNTAX_NAMES
7577 } ,
7678 uniqueItems : true
7779 }
@@ -82,7 +84,7 @@ module.exports = {
8284 messages : {
8385 // Vue.js 2.5.0+
8486 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".' ,
8688 // Vue.js 2.6.0+
8789 forbiddenDynamicDirectiveArguments :
8890 'Dynamic arguments are not supported until Vue.js "2.6.0".' ,
@@ -119,22 +121,15 @@ module.exports = {
119121 * @returns {boolean } `true` if it's supporting.
120122 */
121123 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 ) )
126125 }
127126
128- const syntaxNames = /** @type {(keyof FEATURES)[] } */ ( Object . keys (
129- FEATURES
130- ) )
131-
132127 /** @type {TemplateListener } */
133128 let templateBodyVisitor = { }
134129 /** @type {RuleListener } */
135130 let scriptVisitor = { }
136131
137- for ( const syntaxName of syntaxNames ) {
132+ for ( const syntaxName of SYNTAX_NAMES ) {
138133 /** @type {SyntaxRule } */
139134 const syntax = FEATURES [ syntaxName ]
140135 if ( ignores . includes ( syntaxName ) || ! isNotSupportingVersion ( syntax ) ) {
0 commit comments