1
votes

For example, when I have the following TypeScript code const bar = <foo>{ answer: 42 } tslint issues a warning 'missing whitespace' between > and {. So, to fix it, I have to write: const bar = <foo> { answer: 42 } However, every time I format my file in vs code (SHIFT+ALT+F), my formatting is reset to the version at the top, causing a new tslint issue. As I cannot change the formatting rules in vs code, do I need to add a rule to tslint or editorconfig?

2
what does tslint.json contain?Suraj Rao
{ "extends": "tslint:recommended", "rules": { "quotemark": [true, "single", "double"], "max-line-length": [200], "whitespace": [true, "check-branch", "check-decl", "check-operator", "check-separator", "check-type" ], "trailing-comma": [true, { "multiline": "never", "singleline": "never" }], "object-literal-sort-keys": false } }Erik Vullings

2 Answers

1
votes

You could change the tslint.json and edit whitespace rule in your project. Your example looks like the check-typecast setting.

"check-typecast" checks for whitespace between a typecast and its target.

As suggested override your rule set with:

"whitespace": [true, "check-branch", "check-decl", "check-operator", "check-separator", "check-type" ]
-1
votes
  "typedef-whitespace": [
  true,
  {
    "call-signature": "nospace",
    "index-signature": "nospace",
    "parameter": "nospace",
    "property-declaration": "nospace",
    "variable-declaration": "nospace"
  },
  {
    "call-signature": "onespace",
    "index-signature": "onespace",
    "parameter": "onespace",
    "property-declaration": "onespace",
    "variable-declaration": "onespace"
  }