Home > database >  IntelliJ Fleet: Disable adding semicolons in typescript when formatting
IntelliJ Fleet: Disable adding semicolons in typescript when formatting

Time:10-29

I've just installed IntelliJ Fleet to make the switch from VSCode and I've noticed that in my typescript code every time I try to format code (Cmd-Opt-L) it adds a trailing semicolon to every statement, even though I have no such option enabled in ESLInt.

How can I disable this?

CodePudding user response:

It seems like there is no way to turn that off, after looking here and in JetBrains Fleet's Settings homepage.

Why would you want to turn it off anyways, unless it's getting in the way? Sure, the compiler adds in semicolons if they are absent at the end of lines, but it is much more readable to place them at the end of each line, and is the standard. I really see no purpose in wanting this option turned off. However, I don't use IntelliJ Fleet, and I have heard people say that sometimes the automatic semicolon is annoying or getting in their way, and maybe your case is the same.

NOTE: Not sure of the entire behaviour on this, but I found something that might help on this blog post. In your eslintrc.yml or eslintrc.json file, you should add this to your rules section:

rules: {
  "semi": [2, "never"]
}

The "never" disallows semicolons at the end of lines, "except to disambiguate statements beginning with [, (, /, or -."

The 2 will throw an error if there is a semicolon, but if you change it to 1 it will simply throw an error.

CodePudding user response:

IntelliJ Fleet does support formatting with the de facto industry standard prettier. Create a .prettierrc.json (or any of the other configuration files) file in your project and add the following configuration:

{
  "semi": false
}

If you run into further issues, check out this thread.

  • Related