@@ -12,15 +12,10 @@ const regexp = require('../utils/regexp')
12
12
* @param {string } className
13
13
* @param {* } node
14
14
* @param {RuleContext } context
15
- * @param {(name: string) => boolean } forbiddenGroupMatcher
15
+ * @param {(name: string) => boolean } isForbiddenClass
16
16
*/
17
- const reportForbiddenClass = (
18
- className ,
19
- node ,
20
- context ,
21
- forbiddenGroupMatcher
22
- ) => {
23
- if ( forbiddenGroupMatcher ( className ) ) {
17
+ const reportForbiddenClass = ( className , node , context , isForbiddenClass ) => {
18
+ if ( isForbiddenClass ( className ) ) {
24
19
const loc = node . value ? node . value . loc : node . loc
25
20
context . report ( {
26
21
node,
@@ -119,15 +114,15 @@ module.exports = {
119
114
/** @param {RuleContext } context */
120
115
create ( context ) {
121
116
const { options = [ ] } = context
122
- const forbiddenGroupMatcher = regexp . toRegExpGroupMatcher ( options )
117
+ const isForbiddenClass = regexp . toRegExpGroupMatcher ( options )
123
118
124
119
return utils . defineTemplateBodyVisitor ( context , {
125
120
/**
126
121
* @param {VAttribute & { value: VLiteral } } node
127
122
*/
128
123
'VAttribute[directive=false][key.name="class"][value!=null]' ( node ) {
129
124
for ( const className of node . value . value . split ( / \s + / ) ) {
130
- reportForbiddenClass ( className , node , context , forbiddenGroupMatcher )
125
+ reportForbiddenClass ( className , node , context , isForbiddenClass )
131
126
}
132
127
} ,
133
128
@@ -142,12 +137,7 @@ module.exports = {
142
137
for ( const { className, reportNode } of extractClassNames (
143
138
/** @type {Expression } */ ( node . expression )
144
139
) ) {
145
- reportForbiddenClass (
146
- className ,
147
- reportNode ,
148
- context ,
149
- forbiddenGroupMatcher
150
- )
140
+ reportForbiddenClass ( className , reportNode , context , isForbiddenClass )
151
141
}
152
142
}
153
143
} )
0 commit comments