JavaScript 的 EditorConfig 属性:大括号布局
大括号布局
空大括号格式设置
属性名称:
[resharper_]js_empty_block_style, [resharper_]empty_block_style
可能的值:
multiline:分行显示together:将大括号放在一起together_same_line:同一行放在一起
示例:
格式化之前 | 格式化后,多行 |
|---|---|
function func(par1,
par2) {}
| function func(par1,
par2) {
}
|
格式化之前 | 格式化后,放在一起 |
|---|---|
function func(par1,
par2) {}
| function func(par1,
par2) {}
|
格式化之前 | 格式化后,放在一起_同一行 |
|---|---|
function func(par1,
par2) {}
| function func(par1,
par2) {}
|
函数
属性名称:
[resharper_]js_function_braces, [resharper_]js_brace_style, [resharper_]function_braces, [resharper_]brace_style
可能的值:
end_of_line: 行尾 (K&R 样式)end_of_line_no_space: 行尾(无空格)next_line: 下一行 (BSD 样式)next_line_shifted: 下一行缩进 (Whitesmiths 样式)next_line_shifted_2: 下一行缩进 2 (GNU 样式)pico: 紧凑 (Pico 样式)
示例:
end_of_line |
|---|
function foo() {
bar();
}
|
end_of_line_no_space |
|---|
function foo(){
bar();
}
|
下一行 |
|---|
function foo()
{
bar();
}
|
下一行缩进 |
|---|
function foo()
{
bar();
}
|
下一行缩进 2 |
|---|
function foo()
{
bar();
}
|
pico |
|---|
function foo() { bar(); }
|
作为形参传递给其他函数调用的函数
属性名称:
[resharper_]js_function_in_invocation_braces, [resharper_]js_brace_style, [resharper_]function_in_invocation_braces, [resharper_]brace_style
可能的值:
end_of_line: 行尾 (K&R 样式)end_of_line_no_space: 行尾(无空格)next_line: 下一行 (BSD 样式)next_line_shifted: 下一行缩进 (Whitesmiths 样式)next_line_shifted_2: 下一行缩进 2 (GNU 样式)pico: 紧凑 (Pico 样式)
示例:
end_of_line |
|---|
bar(function foo() {
bar();
});
|
end_of_line_no_space |
|---|
bar(function foo(){
bar();
});
|
下一行 |
|---|
bar(function foo()
{
bar();
});
|
下一行缩进 |
|---|
bar(function foo()
{
bar();
});
|
下一行缩进 2 |
|---|
bar(function foo()
{
bar();
});
|
pico |
|---|
bar(function foo() { bar(); });
|
控制语句
属性名称:
[resharper_]js_control_statements_braces, [resharper_]js_brace_style, [resharper_]control_statements_braces, [resharper_]brace_style
可能的值:
end_of_line: 行尾 (K&R 样式)end_of_line_no_space: 行尾(无空格)next_line: 下一行 (BSD 样式)next_line_shifted: 下一行缩进 (Whitesmiths 样式)next_line_shifted_2: 下一行缩进 2 (GNU 样式)pico: 紧凑 (Pico 样式)
示例:
end_of_line |
|---|
while (cond) {
Action();
};
do {
Action();
} while (cond);
|
end_of_line_no_space |
|---|
while (cond){
Action();
};
do{
Action();
} while (cond);
|
下一行 |
|---|
while (cond)
{
Action();
};
do
{
Action();
} while (cond);
|
下一行缩进 |
|---|
while (cond)
{
Action();
};
do
{
Action();
} while (cond);
|
下一行缩进 2 |
|---|
while (cond)
{
Action();
};
do
{
Action();
} while (cond);
|
pico |
|---|
while (cond)
{ Action(); };
do
{ Action(); } while (cond);
|
缩进圆括号、中括号和表达式大括号
属性名称:
[resharper_]js_indent_pars, [resharper_]indent_pars
可能的值:
inside:括号内(BSD/K&R 风格)outside:括号和括号内等距(Whitesmiths 风格)outside_and_inside:括号 1x,括号内 2x(GNU 风格)none:无缩进
示例:
inside |
|---|
a =
{
1,
2,
3
};
b =
(
1 + 2
)
|
outside |
|---|
a =
{
1,
2,
3
};
b =
(
1 + 2
)
|
括号外和括号内 |
|---|
a =
{
1,
2,
3
};
b =
(
1 + 2
)
|
无 |
|---|
a =
{
1,
2,
3
};
b =
(
1 + 2
)
|
强制使用大括号
语句中的大括号
属性名称:
[resharper_]js_force_control_statements_braces, [resharper_]force_control_statements_braces
可能的值:
do_not_change:不更改always_remove:移除大括号always_add:添加大括号only_for_multiline:多行使用大括号
示例:
格式化之前 | 格式化后,do_not_change |
|---|---|
if (condition) {
foo();
}
else
while (condition)
foo();
| if (condition) {
foo();
} else
while (condition)
foo();
|
格式化之前 | 格式化后,always_remove |
|---|---|
if (condition) {
foo();
}
else
while (condition)
foo();
| if (condition) foo();
else
while (condition)
foo();
|
格式化之前 | 格式化后,always_add |
|---|---|
if (condition) {
foo();
}
else
while (condition)
foo();
| if (condition) {
foo();
} else {
while (condition) {
foo();}}
|
格式化之前 | 格式化后,only_for_multiline |
|---|---|
if (condition) {
foo();
}
else
while (condition)
foo();
| if (condition) foo();
else {
while (condition)
foo();}
|
Case 语句
缩进 'switch' 中的 'case'
属性名称:
[resharper_]js_indent_switch_labels, [resharper_]indent_switch_labels
可能的值:
true | false
示例:
true |
|---|
switch (expression) {
case 0:
break;
}
|
false |
|---|
switch (expression) {
case 0:
break;
}
|