Skip to content

Commit 9dcfc74

Browse files
Apply suggestions from code review
Co-authored-by: Flo Edelmann <[email protected]>
1 parent c98c01e commit 9dcfc74

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/rules/no-v-html.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ module.exports = {
2121
ignorePattern: {
2222
type: 'string'
2323
}
24-
}
24+
},
25+
additionalProperties: false
2526
}],
2627
messages: {
2728
unexpected: "'v-html' directive can lead to XSS attack."
@@ -30,15 +31,14 @@ module.exports = {
3031
/** @param {RuleContext} context */
3132
create(context) {
3233
const options = context.options[0]
33-
let ignoredVarMatcher = null
34-
if (options?.ignorePattern) {
35-
ignoredVarMatcher = toRegExp(options.ignorePattern, { remove: 'g' })
36-
}
34+
const ignoredVarMatcher = options?.ignorePattern
35+
? toRegExp(options.ignorePattern, { remove: 'g' })
36+
: undefined
3737

3838
return utils.defineTemplateBodyVisitor(context, {
3939
/** @param {VDirective} node */
4040
"VAttribute[directive=true][key.name.name='html']"(node) {
41-
if (ignoredVarMatcher !== null && node.value.expression.type === 'Identifier' && ignoredVarMatcher.test(node.value.expression.name)) {
41+
if (ignoredVarMatcher && node.value.expression.type === 'Identifier' && ignoredVarMatcher.test(node.value.expression.name)) {
4242
return
4343
}
4444
context.report({

0 commit comments

Comments
 (0)