Warning
This package has been deprecated in favour of https://github.com/IanVS/prettier-plugin-sort-imports. To achieve a sorting result with that package that is similar-ish to this one, you can use this as reference.
Sensible import sorting style for React Native projects.
yarn add --dev import-sort-cli import-sort-style-rn
Add the following to your package.json
:
"importSort": {
".js, .jsx": {
"parser": "babylon",
"style": "rn"
}
}
You can use a different parser for Typescript files. More info here.
yarn add --dev import-sort-parser-typescript
Add this to your package.json
:
"importSort": {
".js, .jsx": {
"parser": "babylon",
"style": "rn"
},
+ ".ts, .tsx": {
+ "parser": "typescript",
+ "style": "rn"
+ }
}
// Modules with side effects (not sorted internally because order may matter)
// React (Native) modules
// Node.js modules
// Installed modules
import 'c';
import 'a';
import React from 'react';
import { Text, ... } from 'react-native';
import { readFile } from 'fs';
import axios from 'axios';
// Absolute project modules
// "External" project modules ("../")
// "Internal" project modules ("./")
import { padding } from 'theme';
import Divider from '../components/Divider';
import Bubble from './Bubble';