Skip to content

Commit 450c467

Browse files
committed
fix(tsfmt): check rules.indent[1] is "tabs" fromt tslint fixes #42
1 parent 539b71b commit 450c467

File tree

5 files changed

+40
-2
lines changed

5 files changed

+40
-2
lines changed

lib/provider/tslintjson.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ export default function makeFormatCodeOptions(fileName: string, opts: Options, f
4747
if (!config.rules) {
4848
return formatOptions;
4949
}
50-
if (config.rules.indent && config.rules.indent[0] && config.rules.indent[1] === "spaces") {
51-
formatOptions.ConvertTabsToSpaces = true;
50+
if (config.rules.indent && config.rules.indent[0]) {
51+
if (config.rules.indent[1] === "spaces") {
52+
formatOptions.ConvertTabsToSpaces = true;
53+
} else if (config.rules.indent[1] === "tabs") {
54+
formatOptions.ConvertTabsToSpaces = false;
55+
}
5256
}
5357
if (config.rules.whitespace && config.rules.whitespace[0]) {
5458
for (let p in config.rules.whitespace) {
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"IndentSize": 4,
3+
"TabSize": 4,
4+
"IndentStyle": 2,
5+
"NewLineCharacter": "\r\n",
6+
"ConvertTabsToSpaces": false,
7+
"InsertSpaceAfterCommaDelimiter": true,
8+
"InsertSpaceAfterSemicolonInForStatements": true,
9+
"InsertSpaceBeforeAndAfterBinaryOperators": true,
10+
"InsertSpaceAfterKeywordsInControlFlowStatements": true,
11+
"InsertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
12+
"InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
13+
"InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
14+
"InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
15+
"PlaceOpenBraceOnNewLineForFunctions": false,
16+
"PlaceOpenBraceOnNewLineForControlBlocks": false
17+
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Sample {
2+
hello(word = "world") { return "Hello, " + word; }
3+
}
4+
5+
var s = new Sample();
6+
if (s === s) { console.log(s.hello()); }
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Sample {
2+
hello(word="world"){return "Hello, " + word;}
3+
}
4+
5+
var s=new Sample();
6+
if(s===s){console.log(s.hello());}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"indent": [true, "tabs"]
4+
}
5+
}

0 commit comments

Comments
 (0)