Skip to content

Commit faf5f3b

Browse files
committed
Correct message & Add doc
1 parent b46a9e4 commit faf5f3b

File tree

3 files changed

+59
-29
lines changed

3 files changed

+59
-29
lines changed

docs/rules/curly-bracket-spacing.md

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,66 @@
11
# Enforce spacing on the style of curly brackets. (curly-bracket-spacing)
22

3-
Please describe the origin of the rule here.
3+
## :book: Rule Details
44

5+
This rule aims to enforce unified spacing of curly brackets.
56

6-
## Rule Details
7+
:-1: Examples of **incorrect** code for this rule:
78

8-
This rule aims to...
9+
```html
10+
<template>
11+
<div>{{ text }}</div>
12+
</template>
13+
```
14+
15+
:+1: Examples of **correct** code for this rule:
916

10-
Examples of **incorrect** code for this rule:
17+
```html
18+
<template>
19+
<div>{{ text }}</div>
20+
</template>
21+
```
1122

12-
```js
23+
## :wrench: Options
1324

14-
// fill me in
25+
Default casing is set to `always`
1526

1627
```
28+
'vue/curly-bracket-spacing': [2, 'always'|'never']
29+
```
1730

18-
Examples of **correct** code for this rule:
1931

20-
```js
32+
### `"always"` - Expect one space between expression and curly brackets.
2133

22-
// fill me in
34+
:+1: Examples of **correct** code`:
2335

36+
```html
37+
<template>
38+
<div>{{ text }}</div>
39+
</template>
2440
```
2541

26-
### Options
42+
:-1: Examples of **incorrect** code`:
2743

28-
If there are any options, describe them here. Otherwise, delete this section.
44+
```html
45+
<template>
46+
<div>{{text}}</div>
47+
</template>
48+
```
49+
50+
### `"never"` - Expect no spaces between expression and curly brackets.
2951

30-
## When Not To Use It
52+
:+1: Examples of **correct** code`:
3153

32-
Give a short description of when it would be appropriate to turn off this rule.
54+
```html
55+
<template>
56+
<div>{{text}}</div>
57+
</template>
58+
```
3359

34-
## Further Reading
60+
:-1: Examples of **incorrect** code`:
3561

36-
If there are other links that describe the issue this rule addresses, please include them here in a bulleted list.
62+
```html
63+
<template>
64+
<div>{{ text }}</div>
65+
</template>
66+
```

lib/rules/curly-bracket-spacing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module.exports = {
4848
start: leftToken.loc.end,
4949
end: rightToken.loc.start
5050
},
51-
message: 'Found {{spaces}} whitespaces but there should be {{type}}.',
51+
message: 'Found {{spaces}} whitespaces, {{type}} expected.',
5252
data: {
5353
spaces: spaces === 0 ? 'none' : spaces,
5454
type: optSpaces ? '1' : 'none'

tests/lib/rules/curly-bracket-spacing.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ ruleTester.run('curly-bracket-spacing', rule, {
7272
output: '<template><div>{{ }}</div></template>',
7373
options: ['always'],
7474
errors: [{
75-
message: 'Found 9 whitespaces but there should be 1.',
75+
message: 'Found 9 whitespaces, 1 expected.',
7676
type: 'VExpressionEnd'
7777
}]
7878
},
@@ -82,7 +82,7 @@ ruleTester.run('curly-bracket-spacing', rule, {
8282
output: '<template><div>{{ text }}</div></template>',
8383
options: ['always'],
8484
errors: [{
85-
message: 'Found none whitespaces but there should be 1.',
85+
message: 'Found none whitespaces, 1 expected.',
8686
type: 'VExpressionEnd'
8787
}]
8888
},
@@ -92,7 +92,7 @@ ruleTester.run('curly-bracket-spacing', rule, {
9292
output: '<template><div>{{ text }}</div></template>',
9393
options: ['always'],
9494
errors: [{
95-
message: 'Found none whitespaces but there should be 1.',
95+
message: 'Found none whitespaces, 1 expected.',
9696
type: 'Identifier'
9797
}]
9898
},
@@ -102,7 +102,7 @@ ruleTester.run('curly-bracket-spacing', rule, {
102102
output: '<template><div>{{text}}</div></template>',
103103
options: ['never'],
104104
errors: [{
105-
message: 'Found 1 whitespaces but there should be none.',
105+
message: 'Found 1 whitespaces, none expected.',
106106
type: 'Identifier'
107107
}]
108108
},
@@ -112,7 +112,7 @@ ruleTester.run('curly-bracket-spacing', rule, {
112112
output: '<template><div>{{text}}</div></template>',
113113
options: ['never'],
114114
errors: [{
115-
message: 'Found 1 whitespaces but there should be none.',
115+
message: 'Found 1 whitespaces, none expected.',
116116
type: 'VExpressionEnd'
117117
}]
118118
},
@@ -122,10 +122,10 @@ ruleTester.run('curly-bracket-spacing', rule, {
122122
output: '<template><div>{{ text }}</div></template>',
123123
options: ['always'],
124124
errors: [{
125-
message: 'Found none whitespaces but there should be 1.',
125+
message: 'Found none whitespaces, 1 expected.',
126126
type: 'Identifier'
127127
}, {
128-
message: 'Found none whitespaces but there should be 1.',
128+
message: 'Found none whitespaces, 1 expected.',
129129
type: 'VExpressionEnd'
130130
}]
131131
},
@@ -135,10 +135,10 @@ ruleTester.run('curly-bracket-spacing', rule, {
135135
output: '<template><div>{{text}}</div></template>',
136136
options: ['never'],
137137
errors: [{
138-
message: 'Found 1 whitespaces but there should be none.',
138+
message: 'Found 1 whitespaces, none expected.',
139139
type: 'Identifier'
140140
}, {
141-
message: 'Found 1 whitespaces but there should be none.',
141+
message: 'Found 1 whitespaces, none expected.',
142142
type: 'VExpressionEnd'
143143
}]
144144
},
@@ -148,10 +148,10 @@ ruleTester.run('curly-bracket-spacing', rule, {
148148
output: '<template><div>{{ text }}</div></template>',
149149
options: ['always'],
150150
errors: [{
151-
message: 'Found 3 whitespaces but there should be 1.',
151+
message: 'Found 3 whitespaces, 1 expected.',
152152
type: 'Identifier'
153153
}, {
154-
message: 'Found 3 whitespaces but there should be 1.',
154+
message: 'Found 3 whitespaces, 1 expected.',
155155
type: 'VExpressionEnd'
156156
}]
157157
},
@@ -161,10 +161,10 @@ ruleTester.run('curly-bracket-spacing', rule, {
161161
output: '<template><div>{{text}}</div></template>',
162162
options: ['never'],
163163
errors: [{
164-
message: 'Found 3 whitespaces but there should be none.',
164+
message: 'Found 3 whitespaces, none expected.',
165165
type: 'Identifier'
166166
}, {
167-
message: 'Found 3 whitespaces but there should be none.',
167+
message: 'Found 3 whitespaces, none expected.',
168168
type: 'VExpressionEnd'
169169
}]
170170
}

0 commit comments

Comments
 (0)