From cc24db4159fad84eb398c3d72c9c32418c9341ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sajn=C3=B3g?= Date: Fri, 27 Jul 2018 00:42:27 +0200 Subject: [PATCH] Update default settings in html-closing-bracket-newline (multiline -> always) --- docs/rules/html-closing-bracket-newline.md | 42 +++++++------------ lib/rules/html-closing-bracket-newline.js | 5 ++- .../lib/rules/html-closing-bracket-newline.js | 11 ++--- 3 files changed, 26 insertions(+), 32 deletions(-) diff --git a/docs/rules/html-closing-bracket-newline.md b/docs/rules/html-closing-bracket-newline.md index 1fad0fea9..e5134bec7 100644 --- a/docs/rules/html-closing-bracket-newline.md +++ b/docs/rules/html-closing-bracket-newline.md @@ -25,7 +25,7 @@ This rule enforces a line break (or no line break) before tag's closing brackets { "vue/html-closing-bracket-newline": ["error", { "singleline": "never", - "multiline": "never" + "multiline": "always" }] } ``` @@ -34,63 +34,53 @@ This rule enforces a line break (or no line break) before tag's closing brackets - `"never"` ... disallow line breaks before the closing bracket. This is the default. - `"always"` ... require one line break before the closing bracket. - `multiline` ... the configuration for multiline elements. It's a multiline element if the last attribute is not on the same line of the opening bracket. - - `"never"` ... disallow line breaks before the closing bracket. This is the default. - - `"always"` ... require one line break before the closing bracket. + - `"never"` ... disallow line breaks before the closing bracket. + - `"always"` ... require one line break before the closing bracket. This is the default. Plus, you can use [`vue/html-indent`](./html-indent.md) rule to enforce indent-level of the closing brackets. :-1: Examples of **incorrect** code for this rule: ```html -/*eslint html-closing-bracket-newline: "error"*/ +
+
-
+ class="bar"> ``` :+1: Examples of **correct** code for this rule: ```html -/*eslint html-closing-bracket-newline: "error"*/ +
+ class="bar" +> ``` -:-1: Examples of **incorrect** code for `{ "multiline": "always" }`: +:-1: Examples of **incorrect** code for `{ "multiline": "never" }`: ```html -/*eslint html-closing-bracket-newline: ["error", { multiline: always }]*/ + -
+ class="bar" +> ``` -:+1: Examples of **correct** code for `{ "multiline": "always" }`: +:+1: Examples of **correct** code for `{ "multiline": "never" }`: ```html -/*eslint html-closing-bracket-newline: ["error", { multiline: always }]*/ + -
-
+ class="bar"> ``` diff --git a/lib/rules/html-closing-bracket-newline.js b/lib/rules/html-closing-bracket-newline.js index 93becc9dc..2e7d4787e 100644 --- a/lib/rules/html-closing-bracket-newline.js +++ b/lib/rules/html-closing-bracket-newline.js @@ -46,7 +46,10 @@ module.exports = { }, create (context) { - const options = context.options[0] || {} + const options = Object.assign({}, { + singleline: 'never', + multiline: 'always' + }, context.options[0] || {}) const template = context.parserServices.getTemplateBodyTokenStore && context.parserServices.getTemplateBodyTokenStore() return utils.defineTemplateBodyVisitor(context, { diff --git a/tests/lib/rules/html-closing-bracket-newline.js b/tests/lib/rules/html-closing-bracket-newline.js index 46e154182..fbb74b690 100644 --- a/tests/lib/rules/html-closing-bracket-newline.js +++ b/tests/lib/rules/html-closing-bracket-newline.js @@ -29,7 +29,8 @@ tester.run('html-closing-bracket-newline', rule, { ` `, @@ -144,20 +145,20 @@ tester.run('html-closing-bracket-newline', rule, { code: ` `, output: ` `, errors: [ - 'Expected no line breaks before closing bracket, but 1 line break found.' + 'Expected 1 line break before closing bracket, but no line breaks found.' ] }, {