import-sort-style-pietile
Simple and meaningful imports order style for import-sort. Works great with JavaScript and TypeScript.
Usage
-
Install packages:
- import-sort:
yarn add --dev import-sort
- parser either JavaScript or _TypeScript:
yarn add --dev import-sort-parser-babylon
oryarn add --dev import-sort-parser-typescript
- this style:
yarn add --dev import-sort-style-pietile
- import-sort:
-
Setup config:
{ ".js, .jsx": { "parser": "babylon", "style": "pietile" }, ".ts, .tsx": { "parser": "typescript", "style": "pietile" } }
-
Sort imports either from CLI or with Editor plugin (VSCode for example)
Result
// Modules without members. Don't sort them as the order can be important.
import 'babel-polyfill';
// React module is special due to JSX requirement
import React from 'react';
// Modules from Node.js library
import { readFile, writeFile } from 'fs';
import * as path from 'path';
// Installed modules
import moment from 'moment';
// Project modules external to the current file
import Controller from '../../lib/Controller';
import RedButton from '../Buttons/RedButton';
// Project modules internal to the current file
import AwesomeComponent from './AwesomeComponent';
// Resources
import icon from './icon.png';