Skip to content

Commit c58cac2

Browse files
committed
chore: edit after review
1 parent dd474bb commit c58cac2

9 files changed

+21
-33
lines changed

lib/rules/attribute-hyphenation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ module.exports = {
7979
const option = context.options[0]
8080
const optionsPayload = context.options[1]
8181
const useHyphenated = option !== 'never'
82-
const ignoredTagsMatcher = toRegExpGroupMatcher(optionsPayload?.ignoreTags)
82+
const isIgnoredTagName = toRegExpGroupMatcher(optionsPayload?.ignoreTags)
8383
const ignoredAttributes = ['data-', 'aria-', 'slot-scope', ...svgAttributes]
8484

8585
if (optionsPayload && optionsPayload.ignore) {
@@ -143,7 +143,7 @@ module.exports = {
143143
const element = node.parent.parent
144144
if (
145145
(!utils.isCustomComponent(element) && element.name !== 'slot') ||
146-
ignoredTagsMatcher(element.rawName)
146+
isIgnoredTagName(element.rawName)
147147
)
148148
return
149149

lib/rules/component-name-in-template-casing.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ module.exports = {
8181
const caseType = allowedCaseOptions.includes(caseOption)
8282
? caseOption
8383
: defaultCase
84-
const ignoreMatcher = toRegExpGroupMatcher(options.ignores)
84+
const isIgnored = toRegExpGroupMatcher(options.ignores)
8585
/** @type {string[]} */
8686
const globals = (options.globals || []).map(casing.pascalCase)
8787
const registeredComponentsOnly = options.registeredComponentsOnly !== false
@@ -115,7 +115,7 @@ module.exports = {
115115
* @returns {boolean} `true` if the given node is the verification target node.
116116
*/
117117
function isVerifyTarget(node) {
118-
if (ignoreMatcher(node.rawName)) {
118+
if (isIgnored(node.rawName)) {
119119
// ignore
120120
return false
121121
}

lib/rules/custom-event-name-casing.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ module.exports = {
9292
const caseType = context.options[0] || DEFAULT_CASE
9393
const objectOption = context.options[1] || {}
9494
const caseChecker = casing.getChecker(caseType)
95-
const ignoreMatcher = toRegExpGroupMatcher(objectOption.ignores)
95+
const isIgnored = toRegExpGroupMatcher(objectOption.ignores)
9696

9797
/**
9898
* Check whether the given event name is valid.
@@ -108,7 +108,7 @@ module.exports = {
108108
*/
109109
function verify(nameWithLoc) {
110110
const name = nameWithLoc.name
111-
if (isValidEventName(name) || ignoreMatcher(name)) {
111+
if (isValidEventName(name) || isIgnored(name)) {
112112
return
113113
}
114114
context.report({

lib/rules/no-restricted-class.js

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,10 @@ const regexp = require('../utils/regexp')
1212
* @param {string} className
1313
* @param {*} node
1414
* @param {RuleContext} context
15-
* @param {(name: string) => boolean} forbiddenGroupMatcher
15+
* @param {(name: string) => boolean} isForbiddenClass
1616
*/
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)) {
2419
const loc = node.value ? node.value.loc : node.loc
2520
context.report({
2621
node,
@@ -119,15 +114,15 @@ module.exports = {
119114
/** @param {RuleContext} context */
120115
create(context) {
121116
const { options = [] } = context
122-
const forbiddenGroupMatcher = regexp.toRegExpGroupMatcher(options)
117+
const isForbiddenClass = regexp.toRegExpGroupMatcher(options)
123118

124119
return utils.defineTemplateBodyVisitor(context, {
125120
/**
126121
* @param {VAttribute & { value: VLiteral } } node
127122
*/
128123
'VAttribute[directive=false][key.name="class"][value!=null]'(node) {
129124
for (const className of node.value.value.split(/\s+/)) {
130-
reportForbiddenClass(className, node, context, forbiddenGroupMatcher)
125+
reportForbiddenClass(className, node, context, isForbiddenClass)
131126
}
132127
},
133128

@@ -142,12 +137,7 @@ module.exports = {
142137
for (const { className, reportNode } of extractClassNames(
143138
/** @type {Expression} */ (node.expression)
144139
)) {
145-
reportForbiddenClass(
146-
className,
147-
reportNode,
148-
context,
149-
forbiddenGroupMatcher
150-
)
140+
reportForbiddenClass(className, reportNode, context, isForbiddenClass)
151141
}
152142
}
153143
})

lib/rules/no-undef-properties.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ module.exports = {
107107
create(context) {
108108
const options = context.options[0] || {}
109109
const { ignores = [String.raw`/^\$/`] } = options
110-
const ignoreMatcher = toRegExpGroupMatcher(ignores)
110+
const isIgnored = toRegExpGroupMatcher(ignores)
111111
const propertyReferenceExtractor = definePropertyReferenceExtractor(context)
112112
const programNode = context.getSourceCode().ast
113113
/**
@@ -189,7 +189,7 @@ module.exports = {
189189
report(node, name, messageId = 'undef') {
190190
if (
191191
reserved.includes(name) ||
192-
ignoreMatcher(name) ||
192+
isIgnored(name) ||
193193
propertiesDefinedByStoreHelpers.has(name)
194194
) {
195195
return

lib/rules/prop-name-casing.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ const allowedCaseOptions = ['camelCase', 'snake_case']
1616
/** @param {RuleContext} context */
1717
function create(context) {
1818
const options = context.options[0]
19-
const ignorePropsMatcher = toRegExpGroupMatcher(
20-
context.options[1]?.ignoreProps
21-
)
19+
const isIgnoredProp = toRegExpGroupMatcher(context.options[1]?.ignoreProps)
2220
const caseType = allowedCaseOptions.includes(options) ? options : 'camelCase'
2321
const checker = casing.getChecker(caseType)
2422

@@ -31,7 +29,7 @@ function create(context) {
3129
if (propName == null) {
3230
continue
3331
}
34-
if (!checker(propName) && !ignorePropsMatcher(propName)) {
32+
if (!checker(propName) && !isIgnoredProp(propName)) {
3533
context.report({
3634
node: item.node,
3735
messageId: 'invalidCase',

lib/rules/restricted-component-names.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ module.exports = {
5151
/** @param {RuleContext} context */
5252
create(context) {
5353
const options = context.options[0] || {}
54-
const allowMatcher = toRegExpGroupMatcher(options.allow)
54+
const isAllowed = toRegExpGroupMatcher(options.allow)
5555

5656
/** @param {string} name */
5757
function isAllowedTarget(name) {
58-
return reservedNames.has(name) || allowMatcher(name)
58+
return reservedNames.has(name) || isAllowed(name)
5959
}
6060

6161
return utils.defineTemplateBodyVisitor(context, {

lib/rules/v-on-event-hyphenation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ module.exports = {
6363
const useHyphenated = option !== 'never'
6464
/** @type {string[]} */
6565
const ignoredAttributes = (optionsPayload && optionsPayload.ignore) || []
66-
const ignoredTagsMatcher = toRegExpGroupMatcher(optionsPayload?.ignoreTags)
66+
const isIgnoredTag = toRegExpGroupMatcher(optionsPayload?.ignoreTags)
6767
const autofix = Boolean(optionsPayload && optionsPayload.autofix)
6868

6969
const caseConverter = casing.getConverter(
@@ -112,7 +112,7 @@ module.exports = {
112112
const element = node.parent.parent
113113
if (
114114
!utils.isCustomComponent(element) ||
115-
ignoredTagsMatcher(element.rawName)
115+
isIgnoredTag(element.rawName)
116116
) {
117117
return
118118
}

lib/utils/regexp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function escape(string) {
3030
function toRegExp(string, flags = {}) {
3131
const parts = RE_REGEXP_STR.exec(string)
3232
const { add: forceAddFlags = '', remove: forceRemoveFlags = '' } =
33-
typeof flags === 'object' ? flags : {} // Avoid issues when this is called diretly from array.map
33+
typeof flags === 'object' ? flags : {} // Avoid issues when this is called directly from array.map
3434
if (parts) {
3535
return new RegExp(
3636
parts[1],

0 commit comments

Comments
 (0)