Format Space within braces for ES6 import/export

I haven't been able to figure out how to set format to add or retain the spaces within braces for TypeScript / ES6 import/export. 

So I want

```
import { Component, EventEmitter, OnInit, Output, Input } from '@angular/core’;
```
 
Instead of 
 
```
import {Component, EventEmitter, OnInit, Output, Input} from '@angular/core';
```
31
17 comments

please try enabling Preferences | Editor | Code Style | TypeScript, Spaces / Within / ES6 import/export braces - does it help?

57
Avatar
Permanently deleted user

That was it - thanks (I totally didn't see that option before.) 

0
Avatar
Permanently deleted user

Upvoted. This helped me greatly.

Never thought Typescript will be a separate option in the list of Code Options.

0
Avatar
Permanently deleted user

Is this option also available for Resharper?

0

Unfortunately, at this moment there is no such option in Resharper.

Please vote for this feature https://youtrack.jetbrains.com/issue/RSRP-465954 to increase its priority and to be notified about updates.

0

Very helpful. Thanks Elena.

0
Avatar
Permanently deleted user

Thanks @Elena, your solution fixed my problem! My imports are now spacing correctly.

0

If I want this setting to be in the .editorconfig (so my colleagues have same settings when formatting the code), what shall I do? When exporting EditorConfig, there are only settings for indentation. I did not find any property for this in the index https://www.jetbrains.com/help/rider/EditorConfig_Index.html

0

Not sure about Rider, but in Webstorm it is

ij_javascript_spaces_within_imports = true
0

And for the regular IntelliJ IDEA? The

ij_javascript_spaces_within_imports

has no effect..

0

it's the same in IDEA, and it does work for me

0

for JavaScript

ij_javascript_spaces_within_imports = true

for Typescript

ij_typescript_spaces_within_imports = true
1

I'm using version 2021.2.3 on Typescript project, setting ON ES6 import/export braces doesn't add spaces. Any help ?

1

Are you using .editorconfig? Its settings override the code style preferences. Please also make sure that you don't have Prettier set up as your default formatter

0

solved I changed Typescrpit setting editor 

0

This works for javascript:

ij_javascript_spaces_within_imports = true

But after putting it in .editorconfig I had to restart the project. Which I mostly do via

File -> "Invalidate Caches..." and then choose bottom left "Just restart"

and you get a beautiful autocomplete like this

import { myObject } from 'path/to/object'
0

Please sign in to leave a comment.