Skip to content

Commit a4b40a2

Browse files
committed
Fix: multiline-html-element-content-newline case sensitivity
fix issue #662
1 parent 0fd0f7b commit a4b40a2

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed

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

Lines changed: 15 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 isIgnoreElement (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 (isIgnoreElement(node)) {
8996
// ignore element name
9097
inIgnoreElement = node
9198
return
@@ -95,6 +102,11 @@ module.exports = {
95102
return
96103
}
97104

105+
if (node.name === 'ignoretag') {
106+
console.log(node)
107+
debugger
108+
}
109+
98110
if (!isMultilineElement(node)) {
99111
return
100112
}
@@ -114,7 +126,7 @@ module.exports = {
114126
},
115127
messageId: 'unexpectedAfterClosingBracket',
116128
data: {
117-
name: node.name,
129+
name: node.rawName,
118130
actual: getPhrase(beforeLineBreaks)
119131
},
120132
fix (fixer) {

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,38 @@ tester.run('multiline-html-element-content-newline', rule, {
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy