Skip to content

Latest commit

 

History

History
75 lines (61 loc) · 2.72 KB

MIGRATION.md

File metadata and controls

75 lines (61 loc) · 2.72 KB

Migration Guide


Migrating from v2.x.x to v3.x.x

TL;DR

  • Replace experimentalBabelParserPluginsList with the new importOrderParserPlugins in your prettier config.
  • Use the importOrderSortSpecifiers to sort import specifiers.
  • Use <THIRD_PARTY_MODULES> special word in importOrder to place your third party imports at any location.
  • Disable case sensitivity in the soring via importOrderCaseInsensitive option.
  • Use importOrderSeparation to separate the import groups.

New changes

  • Sort the import specifiers: The plugin is now able to sort the import specifiers in an import declaration. This can be achieved by setting up the importOrderSortSpecifiers boolean flag. See usage

Input:

import { a, d, c, b } from 'some-package'

Output:

import { a, b, c, d } from 'some-package'
  • Place third party modules anywhere in the imports: You can place the third party import at the desired place in import order. See usage

Prettier config:

module.exports = {
    "importOrder": ["^@core/(.*)$", "<THIRD_PARTY_MODULES>", "^@ui/(.*)$", "^[./]"]
}

Input:

import threeLevelRelativePath from '../../../threeLevelRelativePath';
import sameLevelRelativePath from './sameLevelRelativePath';
import thirdPartyTwo from 'third-party-2';
import otherthing from '@core/otherthing';
import thirdPartyOne from 'third-party-1';
import twoLevelRelativePath from '../../twoLevelRelativePath';
import component from '@ui/hello';
import thirdPartyThree from 'third-party-3';

Output:

import otherthing from '@core/otherthing';
import thirdPartyOne from 'third-party-1';
import thirdPartyTwo from 'third-party-2';
import thirdPartyThree from 'third-party-3';
import component from '@ui/hello';
import threeLevelRelativePath from '../../../threeLevelRelativePath';
import twoLevelRelativePath from '../../twoLevelRelativePath';
import sameLevelRelativePath from './sameLevelRelativePath';
  • Disable case sensitivity for sorting: By default, the case sensitivity for the sorting is enabled. Now you can disable the case sensitivity with the importOrderCaseInsensitive option. See usage

  • Pass options to the Babel parser plugins: You can pass the options to the babel parser plugins via the importOrderParserPlugins option. See usage

Breaking changes

  • Renaming of experimentalBabelParserPluginsList: In version 3, the experimentalBabelParserPluginsList has been removed. You can use the same API with a new name and better option handling for babel parser. See usage