From ae685b3b1b91256acf4c72056f983467581d484e Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 14 Nov 2018 01:32:40 +0100 Subject: [PATCH 1/2] Fix: multiline-html-element-content-newline case sensitivity fix issue #662 --- .../multiline-html-element-content-newline.js | 13 ++++++-- .../multiline-html-element-content-newline.js | 32 +++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/lib/rules/multiline-html-element-content-newline.js b/lib/rules/multiline-html-element-content-newline.js index 415c8ddf4..9ceba78c0 100644 --- a/lib/rules/multiline-html-element-content-newline.js +++ b/lib/rules/multiline-html-element-content-newline.js @@ -9,6 +9,7 @@ // ------------------------------------------------------------------------------ const utils = require('../utils') +const casing = require('../utils/casing') // ------------------------------------------------------------------------------ // Helpers @@ -20,7 +21,7 @@ function isMultilineElement (element) { function parseOptions (options) { return Object.assign({ - 'ignores': ['pre', 'textarea'] + ignores: ['pre', 'textarea'] }, options) } @@ -80,12 +81,18 @@ module.exports = { let inIgnoreElement + function isIgnoreElement (node) { + return ignores.includes(node.name) || + ignores.includes(casing.pascalCase(node.rawName)) || + ignores.includes(casing.kebabCase(node.rawName)) + } + return utils.defineTemplateBodyVisitor(context, { 'VElement' (node) { if (inIgnoreElement) { return } - if (ignores.indexOf(node.name) >= 0) { + if (isIgnoreElement(node)) { // ignore element name inIgnoreElement = node return @@ -114,7 +121,7 @@ module.exports = { }, messageId: 'unexpectedAfterClosingBracket', data: { - name: node.name, + name: node.rawName, actual: getPhrase(beforeLineBreaks) }, fix (fixer) { diff --git a/tests/lib/rules/multiline-html-element-content-newline.js b/tests/lib/rules/multiline-html-element-content-newline.js index c60fa513f..340a90c91 100644 --- a/tests/lib/rules/multiline-html-element-content-newline.js +++ b/tests/lib/rules/multiline-html-element-content-newline.js @@ -98,6 +98,38 @@ tester.run('multiline-html-element-content-newline', rule, { ignores: ['ignore-tag'] }] }, + { + code: ` + `, + options: [{ + ignores: ['IgnoreTag'] + }] + }, + { + code: ` + `, + options: [{ + ignores: ['IgnoreTag'] + }] + }, // Ignore if no closing brackets ` `, options: [{ @@ -107,7 +107,7 @@ tester.run('multiline-html-element-content-newline', rule, { >content
content
- >content + content content `, options: [{ @@ -123,7 +123,7 @@ tester.run('multiline-html-element-content-newline', rule, { >content
content
- >content + content content `, options: [{