0

In my Angular project I would like to enforce tabs instead of spaces. That's why I added the following rule to my .eslintrc.json:

"indent": ["error", "tab", { "SwitchCase": 1 }],

This basically works, but it comes with an ugly side-effect: An additional indentation is enforced in the line below a decorator.

Therefore this is the current formatting:

@ViewChild(MatAutocomplete)
    autocomplete: MatAutocomplete; // This line should not be indented

@Input()
    value: string; // This line should not be indented

Yet this would be the expected formatting:

@ViewChild(MatAutocomplete)
autocomplete: MatAutocomplete;

@Input()
value: string;

How can I achieve the expected formatting while keeping tabs (instead of spaces) as default?

Any help is appreciated :-)

kellermat
  • 2,859
  • 2
  • 4
  • 21

1 Answers1

0

I was eventually able to resolve my issue with the help of this SO-article.

I added the following lines to my .eslintrc.json:

"indent": ["error", "tab", { "ignoredNodes": [
            "FunctionExpression > .params[decorators.length > 0]",
            "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
            "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
        ]}]
kellermat
  • 2,859
  • 2
  • 4
  • 21