Skip to content

Commit 97bab1d

Browse files
authoredMay 10, 2017
Merge pull request #99 from clebert/vscode
feat: add missing rules recently added by vscode
2 parents ceeea29 + ad6797a commit 97bab1d

File tree

7 files changed

+17
-5
lines changed

7 files changed

+17
-5
lines changed
 

‎lib/provider/vscodesettings.ts

+8
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ interface VSCodeSettings {
1515
"typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": boolean;
1616
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": boolean;
1717
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": boolean;
18+
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": boolean;
1819
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": boolean;
1920
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": boolean;
21+
"typescript.format.insertSpaceBeforeFunctionParenthesis": boolean;
2022
"typescript.format.placeOpenBraceOnNewLineForFunctions": boolean;
2123
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": boolean;
2224

@@ -58,12 +60,18 @@ export default function makeFormatCodeOptions(fileName: string, opts: Options, f
5860
if (config["typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"] != null) {
5961
formatSettings.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets = config["typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"];
6062
}
63+
if (config["typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"] != null) {
64+
formatSettings.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces = config["typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"];
65+
}
6166
if (config["typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"] != null) {
6267
formatSettings.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces = config["typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"];
6368
}
6469
if (config["typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"] != null) {
6570
formatSettings.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces = config["typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"];
6671
}
72+
if (config["typescript.format.insertSpaceBeforeFunctionParenthesis"] != null) {
73+
formatSettings.insertSpaceBeforeFunctionParenthesis = config["typescript.format.insertSpaceBeforeFunctionParenthesis"];
74+
}
6775
if (config["typescript.format.placeOpenBraceOnNewLineForFunctions"] != null) {
6876
formatSettings.placeOpenBraceOnNewLineForFunctions = config["typescript.format.placeOpenBraceOnNewLineForFunctions"];
6977
}

‎test/expected/vscode/a/main.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": true,
1818
"insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": true,
1919
"insertSpaceAfterTypeAssertion": false,
20-
"insertSpaceBeforeFunctionParenthesis": false,
20+
"insertSpaceBeforeFunctionParenthesis": true,
2121
"placeOpenBraceOnNewLineForFunctions": true,
2222
"placeOpenBraceOnNewLineForControlBlocks": true
2323
}

‎test/expected/vscode/a/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Sample
22
{
3-
hello( word: string = "world" ): string { return "Hello, " + word; }
3+
hello ( word: string = "world" ): string { return "Hello, " + word; }
44
}
55

66
var s: Sample = new Sample();

‎test/expected/vscode/b/main.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
1414
"insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
1515
"insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
16-
"insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
16+
"insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
1717
"insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
1818
"insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
1919
"insertSpaceAfterTypeAssertion": false,

‎test/expected/vscode/b/main.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Sample {
2-
hello(word: string="world"): string { return "Hello, "+word; }
2+
hello(word: string="world"): string {return "Hello, "+word;}
33
}
44

55
var s: Sample=new Sample();
6-
if(s===s) { console.log(s.hello()); }
6+
if(s===s) {console.log(s.hello());}

‎test/fixture/vscode/a/.vscode/settings.json

+2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
"typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
99
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": true,
1010
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": true,
11+
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
1112
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": true,
1213
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": true,
14+
"typescript.format.insertSpaceBeforeFunctionParenthesis": true,
1315
"typescript.format.placeOpenBraceOnNewLineForFunctions": true,
1416
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": true
1517
}

‎test/fixture/vscode/b/.vscode/settings.json

+2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
"typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
99
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
1010
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
11+
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
1112
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
1213
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
14+
"typescript.format.insertSpaceBeforeFunctionParenthesis": false,
1315
"typescript.format.placeOpenBraceOnNewLineForFunctions": false,
1416
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": false
1517
}

0 commit comments

Comments
 (0)