Skip to content

Commit 6a117c2

Browse files
authored
Update default settings in html-closing-bracket-newline (multiline -> always) (#539)
1 parent 4cfd125 commit 6a117c2

File tree

3 files changed

+26
-32
lines changed

3 files changed

+26
-32
lines changed

docs/rules/html-closing-bracket-newline.md

+16-26
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ This rule enforces a line break (or no line break) before tag's closing brackets
2525
{
2626
"vue/html-closing-bracket-newline": ["error", {
2727
"singleline": "never",
28-
"multiline": "never"
28+
"multiline": "always"
2929
}]
3030
}
3131
```
@@ -34,63 +34,53 @@ This rule enforces a line break (or no line break) before tag's closing brackets
3434
- `"never"` ... disallow line breaks before the closing bracket. This is the default.
3535
- `"always"` ... require one line break before the closing bracket.
3636
- `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.
37-
- `"never"` ... disallow line breaks before the closing bracket. This is the default.
38-
- `"always"` ... require one line break before the closing bracket.
37+
- `"never"` ... disallow line breaks before the closing bracket.
38+
- `"always"` ... require one line break before the closing bracket. This is the default.
3939

4040
Plus, you can use [`vue/html-indent`](./html-indent.md) rule to enforce indent-level of the closing brackets.
4141

4242
:-1: Examples of **incorrect** code for this rule:
4343

4444
```html
45-
/*eslint html-closing-bracket-newline: "error"*/
45+
<!-- eslint html-closing-bracket-newline: "error" -->
4646

4747
<div id="foo" class="bar"
4848
>
49+
4950
<div
5051
id="foo"
51-
class="bar"
52-
>
53-
<div
54-
id="foo"
55-
class="bar"
56-
>
52+
class="bar">
5753
```
5854

5955
:+1: Examples of **correct** code for this rule:
6056

6157
```html
62-
/*eslint html-closing-bracket-newline: "error"*/
58+
<!-- eslint html-closing-bracket-newline: "error" -->
6359

6460
<div id="foo" class="bar">
6561
<div
6662
id="foo"
67-
class="bar">
63+
class="bar"
64+
>
6865
```
6966

70-
:-1: Examples of **incorrect** code for `{ "multiline": "always" }`:
67+
:-1: Examples of **incorrect** code for `{ "multiline": "never" }`:
7168

7269
```html
73-
/*eslint html-closing-bracket-newline: ["error", { multiline: always }]*/
70+
<!-- eslint html-closing-bracket-newline: ["error", { multiline: never }] -->
7471

75-
<div id="foo" class="bar"
76-
>
7772
<div
7873
id="foo"
79-
class="bar">
74+
class="bar"
75+
>
8076
```
8177

82-
:+1: Examples of **correct** code for `{ "multiline": "always" }`:
78+
:+1: Examples of **correct** code for `{ "multiline": "never" }`:
8379

8480
```html
85-
/*eslint html-closing-bracket-newline: ["error", { multiline: always }]*/
81+
<!-- html-closing-bracket-newline: ["error", { multiline: never }] -->
8682

87-
<div id="foo" class="bar">
8883
<div
8984
id="foo"
90-
class="bar"
91-
>
92-
<div
93-
id="foo"
94-
class="bar"
95-
>
85+
class="bar">
9686
```

lib/rules/html-closing-bracket-newline.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ module.exports = {
4646
},
4747

4848
create (context) {
49-
const options = context.options[0] || {}
49+
const options = Object.assign({}, {
50+
singleline: 'never',
51+
multiline: 'always'
52+
}, context.options[0] || {})
5053
const template = context.parserServices.getTemplateBodyTokenStore && context.parserServices.getTemplateBodyTokenStore()
5154

5255
return utils.defineTemplateBodyVisitor(context, {

tests/lib/rules/html-closing-bracket-newline.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ tester.run('html-closing-bracket-newline', rule, {
2929
`
3030
<template>
3131
<div
32-
id="">
32+
id=""
33+
>
3334
</div>
3435
</template>
3536
`,
@@ -144,20 +145,20 @@ tester.run('html-closing-bracket-newline', rule, {
144145
code: `
145146
<template>
146147
<div
147-
id=""
148-
>
148+
id="">
149149
</div>
150150
</template>
151151
`,
152152
output: `
153153
<template>
154154
<div
155-
id="">
155+
id=""
156+
>
156157
</div>
157158
</template>
158159
`,
159160
errors: [
160-
'Expected no line breaks before closing bracket, but 1 line break found.'
161+
'Expected 1 line break before closing bracket, but no line breaks found.'
161162
]
162163
},
163164
{

0 commit comments

Comments
 (0)