Anders
Anders

Reputation: 700

WebStorm TypeScript import formatting options

Auto-importing TypeScript classes works great (from WebStorm), it even goes as far as cleaning up "the mess I've made", when reformatting.

However.

Imports are always formatted as:

import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';

Where the team I'm working on, prefers the format:

import { 
  Component,
  EventEmitter,
  Input,
  OnInit,
  Output
} from '@angular/core';

It makes reviewing pull requests easier, etc... so, fine.

Can it be true that the reformatting / organize imports functionality does not support this formatting style? I can not find a setting for it.

Upvotes: 0

Views: 735

Answers (1)

Jevgeni
Jevgeni

Reputation: 2574

Webstorm 2017.1 has an option for that.

Go to: Preferences | Editor | Code Style | Typescript | Wrapping and Braces scroll to the bottom and find ES6 import/export row, set it to Wrap always

btw: I'd also recommend using trailing comma, to avoid extra line changes during GIT commits, when adding more imports:

import { 
   Component,
   EventEmitter,
   Input,
   OnInit,
   Output,
} from '@angular/core';

Upvotes: 6

Related Questions