dima74 / intellij-indent-rainbow

Extension which shows indentation with a faint rainbow colored background to make them more readable
https://plugins.jetbrains.com/plugin/13308-indent-rainbow/
GNU General Public License v3.0
64 stars 14 forks source link

[TypeScript] Method parameter destructuring #33

Closed t-ricci-delta closed 3 years ago

t-ricci-delta commented 3 years ago

Intent rainbow does not seem to like when I destructure typed parameters on methods in TypeScript

image

The indentation is configured as two spaces, and you can see a bright red background if any space is added at the start of the line after the open brackets and before the closing brackets {}

This is verified in Rider on windows 10, but I remember it happening in macOS and other jetbrains products as well

dima74 commented 3 years ago

@t-ricci-delta thanks for report!

Plugin highlights indent in red based on default IntelliJ formatter. If some line is highlighted in red, it means that after "Reformat Code" action this line indent will be changed. So you have four options:

1) Reformat your code 2) Configure your code style 3) Enable checkbox "Never highlight indent as error" in settings 4) Use "simple highlighter" (not recommended)

t-ricci-delta commented 3 years ago

@t-ricci-delta thanks for report!

Plugin highlights indent in red based on default IntelliJ formatter. If some line is highlighted in red, it means that after "Reformat Code" action this line indent will be changed. So you have four options:

  1. Reformat your code
  2. Configure your code style
  3. Enable checkbox "Never highlight indent as error" in settings
  4. Use "simple highlighter" (not recommended)

I tried to run "Reformat Code" but the coding style remained the same. Also I'm using the Prettier extension as well: https://plugins.jetbrains.com/plugin/10456-prettier

t-ricci-delta commented 3 years ago

@t-ricci-delta thanks for report!

Plugin highlights indent in red based on default IntelliJ formatter. If some line is highlighted in red, it means that after "Reformat Code" action this line indent will be changed. So you have four options:

  1. Reformat your code
  2. Configure your code style
  3. Enable checkbox "Never highlight indent as error" in settings
  4. Use "simple highlighter" (not recommended)

Regarding point 2. I haven't found any option to allow to indent if the parameter destructuring is carried over multiple lines instead of in the same line.

I'd avoid solutions 3 and 4

dima74 commented 3 years ago

Looks like the only option is to use "simple highlighter", since non-default formatter is used (Prettier)

t-ricci-delta commented 3 years ago

Seems a problem of the default formatter for typescript (I disabled Prettier), this is what formatting the code looked like (ugly alignment of destructured parameter)

image

I'm still tinkering with the default code style to find out which option is behaving like that exactly

t-ricci-delta commented 3 years ago

The error color to me was useful if the number of spaces was not even (multiple of configured tab width), but it's not what the plugin implementation is checking, if it relies on the formatter

(maybe it's the simple highlighter for this use case)

dima74 commented 3 years ago

The error color to me was useful if the number of spaces was not even (multiple of configured tab width)

This is exactly how simple highlighter works, if I remember correctly

t-ricci-delta commented 3 years ago

The error color to me was useful if the number of spaces was not even (multiple of configured tab width)

This is exactly how simple highlighter works, if I remember correctly

Then I'll stick to it since for js/ts using Prettier is far more useful. It would be a nice to have the possibility to have the other languages (C#/Java) show the spacing from the default formatter though.

For now I'm content with the "simple highligher option" since I only care if there are mixed tabs/spaces or uneven number of spaces

dima74 commented 2 years ago

It would be a nice to have the possibility to have the other languages (C#/Java) show the spacing from the default formatter though.

The option to use different highlighters for different languages was added in the latest release 1.7.0:

image