Skip to content

Commit

Permalink
Merge pull request #99 from clebert/vscode
Browse files Browse the repository at this point in the history
feat: add missing rules recently added by vscode
  • Loading branch information
vvakame authored May 10, 2017
2 parents ceeea29 + ad6797a commit 97bab1d
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 5 deletions.
8 changes: 8 additions & 0 deletions lib/provider/vscodesettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ interface VSCodeSettings {
"typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": boolean;
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": boolean;
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": boolean;
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": boolean;
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": boolean;
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": boolean;
"typescript.format.insertSpaceBeforeFunctionParenthesis": boolean;
"typescript.format.placeOpenBraceOnNewLineForFunctions": boolean;
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": boolean;

Expand Down Expand Up @@ -58,12 +60,18 @@ export default function makeFormatCodeOptions(fileName: string, opts: Options, f
if (config["typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"] != null) {
formatSettings.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets = config["typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"];
}
if (config["typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"] != null) {
formatSettings.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces = config["typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"];
}
if (config["typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"] != null) {
formatSettings.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces = config["typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"];
}
if (config["typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"] != null) {
formatSettings.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces = config["typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"];
}
if (config["typescript.format.insertSpaceBeforeFunctionParenthesis"] != null) {
formatSettings.insertSpaceBeforeFunctionParenthesis = config["typescript.format.insertSpaceBeforeFunctionParenthesis"];
}
if (config["typescript.format.placeOpenBraceOnNewLineForFunctions"] != null) {
formatSettings.placeOpenBraceOnNewLineForFunctions = config["typescript.format.placeOpenBraceOnNewLineForFunctions"];
}
Expand Down
2 changes: 1 addition & 1 deletion test/expected/vscode/a/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": true,
"insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": true,
"insertSpaceAfterTypeAssertion": false,
"insertSpaceBeforeFunctionParenthesis": false,
"insertSpaceBeforeFunctionParenthesis": true,
"placeOpenBraceOnNewLineForFunctions": true,
"placeOpenBraceOnNewLineForControlBlocks": true
}
2 changes: 1 addition & 1 deletion test/expected/vscode/a/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Sample
{
hello( word: string = "world" ): string { return "Hello, " + word; }
hello ( word: string = "world" ): string { return "Hello, " + word; }
}

var s: Sample = new Sample();
Expand Down
2 changes: 1 addition & 1 deletion test/expected/vscode/b/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
"insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
"insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
"insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
"insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
"insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
"insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
"insertSpaceAfterTypeAssertion": false,
Expand Down
4 changes: 2 additions & 2 deletions test/expected/vscode/b/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Sample {
hello(word: string="world"): string { return "Hello, "+word; }
hello(word: string="world"): string {return "Hello, "+word;}
}

var s: Sample=new Sample();
if(s===s) { console.log(s.hello()); }
if(s===s) {console.log(s.hello());}
2 changes: 2 additions & 0 deletions test/fixture/vscode/a/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": true,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": true,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": true,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": true,
"typescript.format.insertSpaceBeforeFunctionParenthesis": true,
"typescript.format.placeOpenBraceOnNewLineForFunctions": true,
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": true
}
2 changes: 2 additions & 0 deletions test/fixture/vscode/b/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
"typescript.format.insertSpaceBeforeFunctionParenthesis": false,
"typescript.format.placeOpenBraceOnNewLineForFunctions": false,
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": false
}

0 comments on commit 97bab1d

Please sign in to comment.