Skip to content

Commit 611fee0

Browse files
committed
feat(tsfmt): support typescript@1.8.2. add insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces options to tsfmt.json
1 parent 5f034c9 commit 611fee0

File tree

32 files changed

+437
-303
lines changed

32 files changed

+437
-303
lines changed

_tslint.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636
"no-empty": true,
3737
"no-eval": true,
3838
"no-string-literal": false,
39-
"no-trailing-comma": true,
39+
"trailing-comma": [true, {
40+
"singleline": "never",
41+
"multiline": "always"
42+
}],
4043
"no-trailing-whitespace": true,
4144
"no-unreachable": true,
4245
"no-unused-expression": false,

dtsm.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
},
1515
"dependencies": {
1616
"node/node.d.ts": {
17-
"ref": "c393f8974d44840a6c9cc6d5b5c0188a8f05143d"
17+
"ref": "dade4414712ce84e3c63393f1aae407e9e7e6af7"
1818
},
1919
"mocha/mocha.d.ts": {
20-
"ref": "c393f8974d44840a6c9cc6d5b5c0188a8f05143d"
20+
"ref": "dade4414712ce84e3c63393f1aae407e9e7e6af7"
2121
},
2222
"power-assert/power-assert.d.ts": {
23-
"ref": "c393f8974d44840a6c9cc6d5b5c0188a8f05143d"
23+
"ref": "dade4414712ce84e3c63393f1aae407e9e7e6af7"
2424
},
2525
"glob-expand/glob-expand.d.ts": {
26-
"ref": "c393f8974d44840a6c9cc6d5b5c0188a8f05143d"
26+
"ref": "dade4414712ce84e3c63393f1aae407e9e7e6af7"
2727
}
2828
}
2929
}

lib/cli.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ let root = commandpost
105105
tslint: tslint,
106106
editorconfig: editorconfig,
107107
tsfmt: tsfmt,
108-
verbose: verbose
108+
verbose: verbose,
109109
})
110110
.then(result => {
111111
let resultMap: lib.ResultMap = {};
@@ -124,7 +124,7 @@ let root = commandpost
124124
tslint: tslint,
125125
editorconfig: editorconfig,
126126
tsfmt: tsfmt,
127-
verbose: verbose
127+
verbose: verbose,
128128
})
129129
.then(showResultHandler)
130130
.catch(errorHandler);

lib/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function processFiles(files: string[], opts: Options): Promise<ResultMap>
5252
message: `${fileName} does not exist. process abort.\n`,
5353
error: true,
5454
src: "",
55-
dest: ""
55+
dest: "",
5656
};
5757
return Promise.resolve(result);
5858
}
@@ -144,7 +144,7 @@ export function processString(fileName: string, content: string, opts: Options):
144144
message: message,
145145
error: error,
146146
src: content,
147-
dest: formattedCode
147+
dest: formattedCode,
148148
};
149149
return Promise.resolve(result);
150150
});

lib/provider/base.ts

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ interface TsfmtSettings {
2323
// かっこ内が空でない場合に始め括弧の後ろと終わりカッコの前にスペースを挿入する
2424
insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean;
2525
insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean;
26+
// template string literalsの括弧内にスペースを挿入する
27+
insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean;
2628
// 新しい行に関数の始め中括弧を配置する
2729
placeOpenBraceOnNewLineForFunctions?: boolean;
2830
// 新しい行にコントロールブロックの始め中括弧を配置する
@@ -71,6 +73,9 @@ export default function makeFormatCodeOptions(fileName: string, opts: Options, f
7173
if (typeof config.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets === "boolean") {
7274
formatOptions.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets = config.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets;
7375
}
76+
if (typeof config.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces === "boolean") {
77+
formatOptions.InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces = config.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces;
78+
}
7479
if (typeof config.placeOpenBraceOnNewLineForFunctions === "boolean") {
7580
formatOptions.PlaceOpenBraceOnNewLineForFunctions = config.placeOpenBraceOnNewLineForFunctions;
7681
}

lib/provider/tslintjson.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,6 @@ function createDefaultAdditionalFormatCodeOptions(): AdditionalFormatOptions {
101101
"use strict";
102102

103103
return {
104-
noConsecutiveBlankLines: false
104+
noConsecutiveBlankLines: false,
105105
};
106106
}

lib/utils.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ export function createDefaultFormatCodeOptions(): ts.FormatCodeOptions {
2121
InsertSpaceAfterFunctionKeywordForAnonymousFunctions: false,
2222
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false,
2323
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false,
24+
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false,
2425
PlaceOpenBraceOnNewLineForFunctions: false,
25-
PlaceOpenBraceOnNewLineForControlBlocks: false
26+
PlaceOpenBraceOnNewLineForControlBlocks: false,
2627
};
2728
}
2829

0 commit comments

Comments
 (0)