0

In IntelliJ Ultimate, we are working on a react application and this is our code styles:

<code_scheme name="Default" version="173">
  <HTMLCodeStyleSettings>
    <option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
  </HTMLCodeStyleSettings>
  <JSCodeStyleSettings version="0">
    <option name="USE_DOUBLE_QUOTES" value="false" />
    <option name="FORCE_QUOTE_STYlE" value="true" />
    <option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
    <option name="SPACES_WITHIN_IMPORTS" value="true" />
  </JSCodeStyleSettings>
  <XML>
    <option name="XML_SPACE_INSIDE_EMPTY_TAG" value="true" />
  </XML>
  <codeStyleSettings language="JavaScript">
    <option name="IF_BRACE_FORCE" value="3" />
    <indentOptions>
      <option name="INDENT_SIZE" value="2" />
      <option name="TAB_SIZE" value="2" />
    </indentOptions>
  </codeStyleSettings>
</code_scheme>

Is there a way to set the code style to set absolute import before relative import?

import _ from 'lodash';
import User from './User';

bad

import User from './User';
import _ from 'lodash';
Dimitri Kopriwa
  • 13,139
  • 27
  • 98
  • 204

1 Answers1

1

You can enable sorting the imports by the module name – that way all the application imports that start with ./ will go after the imports from node_modules. This option is available in Preferences | Editor | Code Style | JavaScript or TypeScript | Imports, Sort imports by modules.

For advanced imports sorting/grouping support, please vote for WEB-21182

lena
  • 90,154
  • 11
  • 145
  • 150
  • Hi, are you sure about this? I have just tried to set this and format the code with `CTRL+SHIFT+F`, this was not sorted by imports by module: `import LocalToggle from '../../components/LocalToggle'; import ThemeToggle from '@bootstrap-styled/redux/lib/ThemeToggle';` – Dimitri Kopriwa Feb 26 '19 at 11:41
  • please check if you have *Optimize imports* enabled in *Reformat file* dialog – lena Feb 26 '19 at 14:01