diff --git a/lib/rules/attribute-hyphenation.js b/lib/rules/attribute-hyphenation.js
index ef8ea0312..5b5b77566 100644
--- a/lib/rules/attribute-hyphenation.js
+++ b/lib/rules/attribute-hyphenation.js
@@ -49,10 +49,10 @@ module.exports = {
const option = context.options[0]
const optionsPayload = context.options[1]
const useHyphenated = option !== 'never'
- const ignoredAttributes = ['data-', 'aria-', 'slot-scope']
+ let ignoredAttributes = ['data-', 'aria-', 'slot-scope']
if (optionsPayload && optionsPayload.ignore) {
- ignoredAttributes.push(optionsPayload.ignore)
+ ignoredAttributes = ignoredAttributes.concat(optionsPayload.ignore)
}
const caseConverter = casing.getConverter(useHyphenated ? 'kebab-case' : 'camelCase')
@@ -63,7 +63,7 @@ module.exports = {
context.report({
node: node.key,
loc: node.loc,
- message: useHyphenated ? "Attribute '{{text}}' must be hyphenated." : "Attribute '{{text}}' cann't be hyphenated.",
+ message: useHyphenated ? "Attribute '{{text}}' must be hyphenated." : "Attribute '{{text}}' can't be hyphenated.",
data: {
text
},
diff --git a/tests/lib/rules/attribute-hyphenation.js b/tests/lib/rules/attribute-hyphenation.js
index 340bd32d6..c1f9b57bc 100644
--- a/tests/lib/rules/attribute-hyphenation.js
+++ b/tests/lib/rules/attribute-hyphenation.js
@@ -45,8 +45,8 @@ ruleTester.run('attribute-hyphenation', rule, {
},
{
filename: 'test.vue',
- code: '',
- options: ['never', { 'ignore': ['custom-hypen'] }]
+ code: '',
+ options: ['never', { 'ignore': ['custom-hyphen', 'second-custom'] }]
}
],
@@ -57,7 +57,7 @@ ruleTester.run('attribute-hyphenation', rule, {
output: '
',
options: ['never'],
errors: [{
- message: "Attribute 'my-prop' cann't be hyphenated.",
+ message: "Attribute 'my-prop' can't be hyphenated.",
type: 'VIdentifier',
line: 1
}]
@@ -79,7 +79,7 @@ ruleTester.run('attribute-hyphenation', rule, {
output: '
',
options: ['never'],
errors: [{
- message: "Attribute ':my-prop' cann't be hyphenated.",
+ message: "Attribute ':my-prop' can't be hyphenated.",
type: 'VDirectiveKey',
line: 1
}]
@@ -101,7 +101,7 @@ ruleTester.run('attribute-hyphenation', rule, {
output: '
',
options: ['never'],
errors: [{
- message: "Attribute 'v-bind:my-prop' cann't be hyphenated.",
+ message: "Attribute 'v-bind:my-prop' can't be hyphenated.",
type: 'VDirectiveKey',
line: 1
}]
@@ -116,6 +116,89 @@ ruleTester.run('attribute-hyphenation', rule, {
type: 'VDirectiveKey',
line: 1
}]
+ },
+ {
+ filename: 'test.vue',
+ code: '
',
+ output: '
',
+ options: ['always', { 'ignore': [] }],
+ errors: [{
+ message: "Attribute 'v-bind:MyProp' must be hyphenated.",
+ type: 'VDirectiveKey',
+ line: 1
+ }]
+ },
+ {
+ filename: 'test.vue',
+ code: '
',
+ output: '
',
+ options: ['never', { ignore: ['my-prop'] }],
+ errors: [{
+ message: "Attribute ':second-prop' can't be hyphenated.",
+ type: 'VDirectiveKey',
+ line: 1
+ }]
+ },
+ {
+ filename: 'test.vue',
+ code: '
',
+ output: '
',
+ options: ['always', { ignore: ['secondProp'] }],
+ errors: [{
+ message: "Attribute 'v-bind:myProp' must be hyphenated.",
+ type: 'VDirectiveKey',
+ line: 1
+ }]
+ },
+ {
+ filename: 'test.vue',
+ code: `
+
+
+
+
+
+ `,
+ output: `
+
+
+
+
+
+ `,
+ options: ['never', { 'ignore': ['custom-hyphen', 'second-custom'] }],
+ errors: [{
+ message: "Attribute 'third-custom' can't be hyphenated.",
+ type: 'VIdentifier',
+ line: 3
+ }]
+ },
+ {
+ filename: 'test.vue',
+ code: `
+
+
+
+
+
+ `,
+ output: `
+
+
+
+
+
+ `,
+ options: ['never'],
+ errors: [{
+ message: "Attribute 'custom-hyphen' can't be hyphenated.",
+ type: 'VIdentifier',
+ line: 3
+ }, {
+ message: "Attribute 'second-custom' can't be hyphenated.",
+ type: 'VIdentifier',
+ line: 3
+ }]
}
]
})