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();
});
|
next_line_shifted |
|---|
bar(function foo()
{
bar();
});
|
next_line_shifted_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);
|
next_line |
|---|
while (cond)
{
Action();
};
do
{
Action();
} while (cond);
|
next_line_shifted |
|---|
while (cond)
{
Action();
};
do
{
Action();
} while (cond);
|
next_line_shifted_2 |
|---|
while (cond)
{
Action();
};
do
{
Action();
} while (cond);
|
pico |
|---|
while (cond)
{ Action(); };
do
{ Action(); } while (cond);
|
缩进圆括号、中括号和表达式大括号
属性名称:
[resharper_]js_indent_pars, [resharper_]indent_pars
可能的值:
括号内: 括号内(BSD/K&R 风格)括号外: 括号和内部等距(Whitesmiths 风格)括号外和内: 括号 1x,内部 2x(GNU 风格)无: 无缩进
示例:
括号内 |
|---|
a =
{
1,
2,
3
};
b =
(
1 + 2
)
|
括号外 |
|---|
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
可能的值:
不更改: 不更改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;
}
|