From 5f4f735ea2c370bfa127553ef51ccf26512dc1c0 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Thu, 27 Sep 2018 16:37:34 +0100 Subject: [PATCH] fix(provider): read TS Lint indent size The TS Lint [`indent` rule](https://palantir.github.io/tslint/rules/indent/) can specify the indentation size: ``` "indent": [true, "spaces"] ``` ``` "indent": [true, "spaces", 4] ``` ``` "indent": [true, "tabs", 2] ``` This patch allows `tsfmt` to read that size and correctly set the formatting options. This means that `tslint` and `tsfmt` do not fight over the indentation size. --- lib/provider/tslintjson.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/provider/tslintjson.ts b/lib/provider/tslintjson.ts index 7b8f978..cb027b0 100644 --- a/lib/provider/tslintjson.ts +++ b/lib/provider/tslintjson.ts @@ -22,7 +22,8 @@ export async function makeFormatCodeOptions(fileName: string, opts: Options, for const whitespace = rules.get("whitespace"); if (indent && indent.ruleArguments) { - switch (indent.ruleArguments[0]) { + const [character, size] = indent.ruleArguments; + switch (character) { case "spaces": formatSettings.convertTabsToSpaces = true; break; @@ -32,6 +33,9 @@ export async function makeFormatCodeOptions(fileName: string, opts: Options, for default: break; } + if (typeof size === 'number') { + formatSettings.indentSize = size; + } } if (whitespace && whitespace.ruleArguments) { for (let p in whitespace.ruleArguments) {