1.1.8 • Published 3 years ago
import-sort-style-rn v1.1.8
import-sort-style-rn
Sensible import sorting style for React Native projects.
Usage
Installation
yarn add --dev import-sort-cli import-sort-style-rn
Setup
Add the following to your package.json
:
"importSort": {
".js, .jsx": {
"parser": "babylon",
"style": "rn"
}
}
Typescript
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"
+ }
}
Style
// 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';