Skip to content

Commit ddbdd83

Browse files
committed
refactor: rename
1 parent 254e4c5 commit ddbdd83

File tree

6 files changed

+39
-30
lines changed

6 files changed

+39
-30
lines changed

docs/rules/attribute-hyphenation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ This rule enforces using hyphenated attribute names on custom components in Vue
3737
{
3838
"vue/attribute-hyphenation": ["error", "always" | "never", {
3939
"ignore": [],
40-
"exclude": []
40+
"ignoreTags": []
4141
}]
4242
}
4343
```
@@ -48,7 +48,7 @@ and all the [SVG attributes](https://developer.mozilla.org/en-US/docs/Web/SVG/At
4848
- `"always"` (default) ... Use hyphenated name.
4949
- `"never"` ... Don't use hyphenated name except the ones that are ignored.
5050
- `"ignore"` ... Array of ignored names.
51-
- `"exclude"` ... Array of exclude tag names.
51+
- `"ignoreTags"` ... Array of exclude tag names.
5252

5353
### `"always"`
5454

@@ -111,11 +111,11 @@ Don't use hyphenated name but allow custom attributes
111111

112112
</eslint-code-block>
113113

114-
### `"never", { "exclude": ["/^custom-/"] }`
114+
### `"never", { "ignoreTags": ["/^custom-/"] }`
115115

116-
Exclude tags from applying this rule.
116+
Ignore tags from applying this rule.
117117

118-
<eslint-code-block fix :rules="{'vue/attribute-hyphenation': ['error', 'never', { exclude: ['/^custom-/'] }]}">
118+
<eslint-code-block fix :rules="{'vue/attribute-hyphenation': ['error', 'never', { ignoreTags: ['/^custom-/'] }]}">
119119

120120
```vue
121121
<template>

docs/rules/v-on-event-hyphenation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ This rule enforces using hyphenated v-on event names on custom components in Vue
4040
"vue/v-on-event-hyphenation": ["error", "always" | "never", {
4141
"autofix": false,
4242
"ignore": [],
43-
"exclude": []
43+
"ignoreTags": []
4444
}]
4545
}
4646
```
4747

4848
- `"always"` (default) ... Use hyphenated name.
4949
- `"never"` ... Don't use hyphenated name.
5050
- `"ignore"` ... Array of ignored names.
51-
- `"exclude"` ... Array of exclude tag names.
51+
- `"ignoreTags"` ... Array of exclude tag names.
5252
- `"autofix"` ... If `true`, enable autofix. If you are using Vue 2, we recommend that you do not use it due to its side effects.
5353

5454
### `"always"`
@@ -106,11 +106,11 @@ Don't use hyphenated name but allow custom event names
106106

107107
</eslint-code-block>
108108

109-
### `"never", { "exclude": ["/^custom-/"] }`
109+
### `"never", { "ignoreTags": ["/^custom-/"] }`
110110

111-
Exclude tags from applying this rule.
111+
Ignore tags from applying this rule.
112112

113-
<eslint-code-block fix :rules="{'vue/v-on-event-hyphenation': ['error', 'never', { exclude: ['/^custom-/'], autofix: true }]}">
113+
<eslint-code-block fix :rules="{'vue/v-on-event-hyphenation': ['error', 'never', { ignoreTags: ['/^custom-/'], autofix: true }]}">
114114

115115
```vue
116116
<template>

lib/rules/attribute-hyphenation.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module.exports = {
5858
uniqueItems: true,
5959
additionalItems: false
6060
},
61-
exclude: {
61+
ignoreTags: {
6262
type: 'array',
6363
items: { type: 'string' },
6464
uniqueItems: true,
@@ -80,9 +80,10 @@ module.exports = {
8080
const optionsPayload = context.options[1]
8181
const useHyphenated = option !== 'never'
8282
/** @type {RegExp[]} */
83-
const excludedTags = ((optionsPayload && optionsPayload.exclude) || []).map(
84-
toRegExp
85-
)
83+
const ignoreTags = (
84+
(optionsPayload && optionsPayload.ignoreTags) ||
85+
[]
86+
).map(toRegExp)
8687
const ignoredAttributes = ['data-', 'aria-', 'slot-scope', ...svgAttributes]
8788

8889
if (optionsPayload && optionsPayload.ignore) {
@@ -144,16 +145,16 @@ module.exports = {
144145
/**
145146
* @param {string} name
146147
*/
147-
function isExcludedTags(name) {
148-
return excludedTags.some((re) => re.test(name))
148+
function isIgnoredTags(name) {
149+
return ignoreTags.some((re) => re.test(name))
149150
}
150151

151152
return utils.defineTemplateBodyVisitor(context, {
152153
VAttribute(node) {
153154
const element = node.parent.parent
154155
if (
155156
(!utils.isCustomComponent(element) && element.name !== 'slot') ||
156-
isExcludedTags(element.rawName)
157+
isIgnoredTags(element.rawName)
157158
)
158159
return
159160

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = {
3737
uniqueItems: true,
3838
additionalItems: false
3939
},
40-
exclude: {
40+
ignoreTags: {
4141
type: 'array',
4242
items: { type: 'string' },
4343
uniqueItems: true,
@@ -64,9 +64,10 @@ module.exports = {
6464
/** @type {string[]} */
6565
const ignoredAttributes = (optionsPayload && optionsPayload.ignore) || []
6666
/** @type {RegExp[]} */
67-
const excludedTags = ((optionsPayload && optionsPayload.exclude) || []).map(
68-
toRegExp
69-
)
67+
const ignoreTags = (
68+
(optionsPayload && optionsPayload.ignoreTags) ||
69+
[]
70+
).map(toRegExp)
7071
const autofix = Boolean(optionsPayload && optionsPayload.autofix)
7172

7273
const caseConverter = casing.getConverter(
@@ -113,16 +114,16 @@ module.exports = {
113114
/**
114115
* @param {string} name
115116
*/
116-
function isExcludedTags(name) {
117-
return excludedTags.some((re) => re.test(name))
117+
function isIgnoreTags(name) {
118+
return ignoreTags.some((re) => re.test(name))
118119
}
119120

120121
return utils.defineTemplateBodyVisitor(context, {
121122
"VAttribute[directive=true][key.name.name='on']"(node) {
122123
const element = node.parent.parent
123124
if (
124125
!utils.isCustomComponent(element) ||
125-
isExcludedTags(element.rawName)
126+
isIgnoreTags(element.rawName)
126127
) {
127128
return
128129
}

tests/lib/rules/attribute-hyphenation.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ ruleTester.run('attribute-hyphenation', rule, {
9494
<custom-component my-prop></custom-component>
9595
</template>
9696
`,
97-
options: ['never', { exclude: ['VueComponent', '/^custom-/'] }]
97+
options: ['never', { ignoreTags: ['VueComponent', '/^custom-/'] }]
9898
}
9999
],
100100

@@ -474,12 +474,13 @@ ruleTester.run('attribute-hyphenation', rule, {
474474
<CustomComponent my-prop/>
475475
</template>
476476
`,
477-
options: ['never', { exclude: ['CustomComponent'] }],
477+
options: ['never', { ignoreTags: ['CustomComponent'] }],
478478
errors: [
479479
{
480480
message: "Attribute 'my-prop' can't be hyphenated.",
481481
type: 'VIdentifier',
482-
line: 3
482+
line: 3,
483+
column: 17
483484
}
484485
]
485486
}

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ tester.run('v-on-event-hyphenation', rule, {
6060
<custom-component v-on:custom-event="events"/>
6161
</template>
6262
`,
63-
options: ['never', { exclude: ['/^Vue/', 'custom-component'] }]
63+
options: ['never', { ignoreTags: ['/^Vue/', 'custom-component'] }]
6464
}
6565
],
6666
invalid: [
@@ -210,8 +210,14 @@ tester.run('v-on-event-hyphenation', rule, {
210210
<CustomComponent v-on:custom-event="events"/>
211211
</template>
212212
`,
213-
options: ['never', { autofix: true, exclude: ['CustomComponent'] }],
214-
errors: ["v-on event 'v-on:custom-event' can't be hyphenated."]
213+
options: ['never', { autofix: true, ignoreTags: ['CustomComponent'] }],
214+
errors: [
215+
{
216+
message: "v-on event 'v-on:custom-event' can't be hyphenated.",
217+
line: 3,
218+
column: 23
219+
}
220+
]
215221
}
216222
]
217223
})

0 commit comments

Comments
 (0)