@@ -65,10 +65,13 @@ module.exports = {
65
65
/**
66
66
* Wrap a given core rule to apply it to Vue.js template.
67
67
* @param {Rule } coreRule The core rule implementation to wrap.
68
- * @param {string|undefined } category The category of this rule.
68
+ * @param {Object|undefined } options The option of this rule.
69
+ * @param {string|undefined } options.category The category of this rule.
70
+ * @param {boolean|undefined } options.skipDynamicArguments If `true`, skip validation within dynamic arguments.
69
71
* @returns {Rule } The wrapped rule implementation.
70
72
*/
71
- wrapCoreRule ( coreRule , category ) {
73
+ wrapCoreRule ( coreRule , options ) {
74
+ const { category, skipDynamicArguments } = options || { }
72
75
return {
73
76
create ( context ) {
74
77
const tokenStore =
@@ -92,6 +95,19 @@ module.exports = {
92
95
delete handlers [ 'Program:exit' ]
93
96
}
94
97
98
+ if ( skipDynamicArguments ) {
99
+ let withinDynamicArguments = false
100
+ for ( const name of Object . keys ( handlers ) ) {
101
+ const original = handlers [ name ]
102
+ handlers [ name ] = ( ...args ) => {
103
+ if ( withinDynamicArguments ) return
104
+ original ( ...args )
105
+ }
106
+ }
107
+ handlers [ 'VDirectiveKey > VExpressionContainer' ] = ( ) => { withinDynamicArguments = true }
108
+ handlers [ 'VDirectiveKey > VExpressionContainer:exit' ] = ( ) => { withinDynamicArguments = false }
109
+ }
110
+
95
111
// Apply the handlers to templates.
96
112
return module . exports . defineTemplateBodyVisitor ( context , handlers )
97
113
} ,
0 commit comments