Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/secondfry/import-sort-style-module-tsconfig
import-sort-style-module but treating tsconfig paths separately
https://github.com/secondfry/import-sort-style-module-tsconfig
import-sort import-sort-style typescript
Last synced: about 1 month ago
JSON representation
import-sort-style-module but treating tsconfig paths separately
- Host: GitHub
- URL: https://github.com/secondfry/import-sort-style-module-tsconfig
- Owner: secondfry
- License: mit
- Created: 2021-04-14T15:10:58.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-10-29T19:30:50.000Z (about 3 years ago)
- Last Synced: 2024-10-08T16:38:35.548Z (about 1 month ago)
- Topics: import-sort, import-sort-style, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/import-sort-style-module-tsconfig
- Size: 281 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# import-sort-style-module-tsconfig
Finds your `tsconfig.json` and uses that to separate imports.- [import-sort-style-module-tsconfig](#import-sort-style-module-tsconfig)
- [Sort order](#sort-order)
- [Installation](#installation)
- [Usage](#usage)
- [Options](#options)## Sort order
1. Absolute imports without members.
2. Node modules.
3. Absolute imports with members.
4. Typescript path imports with members.
5. Typescript path imports without members.
6. Relative imports with members.
7. Relative imports without members.Example:
```typescript
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][vsc-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 |[vsc-sort-imports]: https://marketplace.visualstudio.com/items?itemName=amatiasq.sort-imports