typescript-formatter icon indicating copy to clipboard operation
typescript-formatter copied to clipboard

Weird formatting indentation

Open danielpza opened this issue 7 years ago • 6 comments
trafficstars

actual:

const schema = new Schema({
}, {
        id: false,
    });

expected:

const schema = new Schema({
}, {
    id: false,
});

tslint:

{
    "defaultSeverity": "error",
    "extends": [
        "tslint:recommended"
    ],
    "jsRules": {},
    "rules": {
        "align": false,
        "no-empty-interface": false,
        "no-unused-expression": false,
        "object-literal-sort-keys": false,
        "no-namespace": false,
        "no-irregular-whitespace": true,
        "curly": true,
        "no-bitwise": true,
        "label-position": true,
        "no-construct": true,
        "no-eval": true,
        "no-duplicate-super": true,
        "no-duplicate-variable": true,
        "no-invalid-template-strings": true,
        "no-sparse-arrays": true,
        "no-string-literal": true,
        "triple-equals": true,
        "eofline": true,
        "indent": [true, "spaces", 4],
        "no-consecutive-blank-lines": true,
        "space-before-function-paren": [true, {"anonymous": "always", "named": "never", "asyncArrow": "always"}],
        "max-file-line-count": [true, 150]
    },
    "rulesDirectory": []
}

danielpza avatar Dec 06 '17 20:12 danielpza

sorry for late response. typescript-formatter uses TypeScript's Compiler API. https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API Could you report this issue to TypeScript repo?

vvakame avatar Dec 17 '17 16:12 vvakame

I'm getting this annoying issue too. TypeScript Version: 2.6 TypeScript Formatter Version: 7.0.1 (from yarn.lock)

@vvakame Can you provide additional information on this bug? If it's a regression on the TypeScript compiler, on what previous version did this work fine on?

I just can't imagine how the issue is on their end?

silbinarywolf avatar Jan 11 '18 22:01 silbinarywolf

@vvakame Disregard. Found an issue tracking this on TS. https://github.com/Microsoft/TypeScript/issues/20766

silbinarywolf avatar Jan 11 '18 22:01 silbinarywolf

sorry, I do not have useful information. tsfmt is just a bridge between API and CLI.

vvakame avatar Jan 12 '18 02:01 vvakame

All good! I didn't realize the formatter was so coupled to the compiler!

silbinarywolf avatar Jan 12 '18 02:01 silbinarywolf

I'd say it would be more consistent if parameters were always put on newlines, so expected should be like this:

const schema = new Schema(
  {
  },
  {
    id: false,
  },
);

samal-rasmussen avatar Nov 05 '18 14:11 samal-rasmussen