import-sort-style-module-tsconfig
v1.3.1
Published
import-sort-style-module but treating tsconfig paths separately
Downloads
2
Readme
import-sort-style-module-tsconfig
Finds your tsconfig.json
and uses that to separate imports.
Sort order
- Absolute imports without members.
- Node modules.
- Absolute imports with members.
- Typescript path imports with members.
- Typescript path imports without members.
- Relative imports with members.
- Relative imports without members.
Example:
import 'ignore-styles';
import path from 'path';
import React from 'react';
import MyComponent from 'src/components/my';
import 'src/theme/style.css';
import Box from './box';
import './style.css';
Installation
npm install --save-dev \
forked-import-sort \
forked-import-sort-cli \
forked-import-sort-parser-typescript \
import-sort-style-module-tsconfig
Add following to your package.json
:
"lint-staged": {
"*.{tsx,ts}": [
/* ... */
"import-sort --write .",
"git add"
]
},
"importSort": {
".ts, .tsx": {
"parser": "forked-import-sort-parser-typescript",
"style": "module-tsconfig",
"options": {}
}
}
Usage
Either install sort-imports for VSCode, or use via CLI (file watcher, etc.):
npx import-sort --write .
Options
You may also pass options to this style by putting them to options
directive in package.json
.
| Key | Type | Default | Description |
|--------------|---------|---------|--------------------------------------------------|
| isolatePaths | boolean | true | Separates every tsconfig path as new group |
| workingDir | string | unset | Used as directory for tsconfig.json
resolution |