Skip to content

Commit 07a7d9f

Browse files
armano2michalsnik
authored andcommitted
Fix: multiline-html-element-content-newline case sensitivity (#663)
* Fix: multiline-html-element-content-newline case sensitivity fix issue #662 * fix typo in tests
1 parent 5da94e1 commit 07a7d9f

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

lib/rules/multiline-html-element-content-newline.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// ------------------------------------------------------------------------------
1010

1111
const utils = require('../utils')
12+
const casing = require('../utils/casing')
1213

1314
// ------------------------------------------------------------------------------
1415
// Helpers
@@ -20,7 +21,7 @@ function isMultilineElement (element) {
2021

2122
function parseOptions (options) {
2223
return Object.assign({
23-
'ignores': ['pre', 'textarea']
24+
ignores: ['pre', 'textarea']
2425
}, options)
2526
}
2627

@@ -80,12 +81,18 @@ module.exports = {
8081

8182
let inIgnoreElement
8283

84+
function isIgnoredElement (node) {
85+
return ignores.includes(node.name) ||
86+
ignores.includes(casing.pascalCase(node.rawName)) ||
87+
ignores.includes(casing.kebabCase(node.rawName))
88+
}
89+
8390
return utils.defineTemplateBodyVisitor(context, {
8491
'VElement' (node) {
8592
if (inIgnoreElement) {
8693
return
8794
}
88-
if (ignores.indexOf(node.name) >= 0) {
95+
if (isIgnoredElement(node)) {
8996
// ignore element name
9097
inIgnoreElement = node
9198
return
@@ -114,7 +121,7 @@ module.exports = {
114121
},
115122
messageId: 'unexpectedAfterClosingBracket',
116123
data: {
117-
name: node.name,
124+
name: node.rawName,
118125
actual: getPhrase(beforeLineBreaks)
119126
},
120127
fix (fixer) {

tests/lib/rules/multiline-html-element-content-newline.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,45 @@ tester.run('multiline-html-element-content-newline', rule, {
9191
>content</ignore-tag>
9292
<ignore-tag><div
9393
>content</div></ignore-tag>
94-
<ignore-tag>>content
94+
<ignore-tag>content
9595
content</ignore-tag>
9696
</template>`,
9797
options: [{
9898
ignores: ['ignore-tag']
9999
}]
100100
},
101+
{
102+
code: `
103+
<template>
104+
<IgnoreTag>content</IgnoreTag>
105+
<IgnoreTag
106+
id="test-pre"
107+
>content</IgnoreTag>
108+
<IgnoreTag><div
109+
>content</div></IgnoreTag>
110+
<IgnoreTag>content
111+
content</IgnoreTag>
112+
</template>`,
113+
options: [{
114+
ignores: ['IgnoreTag']
115+
}]
116+
},
117+
{
118+
code: `
119+
<template>
120+
<ignore-tag>content</ignore-tag>
121+
<ignore-tag
122+
id="test-pre"
123+
>content</ignore-tag>
124+
<ignore-tag><div
125+
>content</div></ignore-tag>
126+
<ignore-tag>content
127+
content</ignore-tag>
128+
</template>`,
129+
options: [{
130+
ignores: ['IgnoreTag']
131+
}]
132+
},
101133
// Ignore if no closing brackets
102134
`
103135
<template>

0 commit comments

Comments
 (0)