https://github.com/cptpiepmatz/pretty-ts-imports
A Tool to sort Typescript Imports with a set of complex Rules.
https://github.com/cptpiepmatz/pretty-ts-imports
beautifier complex import imports prettier pretty primp rules ts typescript
Last synced: 3 months ago
JSON representation
A Tool to sort Typescript Imports with a set of complex Rules.
- Host: GitHub
- URL: https://github.com/cptpiepmatz/pretty-ts-imports
- Owner: cptpiepmatz
- License: mit
- Created: 2021-08-01T21:41:10.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-08T18:16:18.000Z (5 months ago)
- Last Synced: 2025-01-06T21:34:49.036Z (4 months ago)
- Topics: beautifier, complex, import, imports, prettier, pretty, primp, rules, ts, typescript
- Language: TypeScript
- Homepage:
- Size: 2.08 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
primp
pretty-ts-imports
Sort your TS Imports with complex Rules.
[](https://github.com/cptpiepmatz/pretty-ts-imports)
[](https://www.npmjs.com/package/pretty-ts-imports)
[](https://typescriptlang.org)
[](https://cptpiepmatz.github.io/pretty-ts-imports/modules.html)
[](https://github.com/cptpiepmatz/pretty-ts-imports/blob/main/LICENSE)
[](https://github.com/cptpiepmatz/pretty-ts-imports/tree/main/spec)
[](https://github.com/cptpiepmatz/pretty-ts-imports/tree/main/spec)
[](https://github.com/cptpiepmatz/pretty-ts-imports/tree/main/spec)**primp** is a tool to sort your typescript imports by a set of complex rules.
Now you can have the imports your way, if you want that.## Installation
Simply install primp via command line with npm or yarn globally.
```shell
# via npm registry
npm install -g pretty-ts-imports# via github registry
npm install -g @cptpiepmatz/pretty-ts-imports
```Or in your project locally.
```shell
# via npm registry
npm install -D pretty-ts-imports# via github registry
npm install -D @cptpiepmatz/pretty-ts-imports
```## Usage
```shell
# using the short form
primp# using the long form
pretty-ts-imports
```### Arguments
By using argument flags you can further control primp to more specifically fit
your needs.
- `-r, --recursive` run recursively over the given directory
- `-o, --output` output the files to the given path instead of in-place updates
- `-t, --tsconfig` overwrite path to tsconfig
- `-c, --config` overwrite path to config
- `-w, --watch` run primp in watch mode## Config
You can use a config to customize how primp should handle your files.
Primp will try to automatically find a primp-config in the given path and above
it.
If primp still won't find your config, you can help it out using the `-c` flag.Primp will recognize following file formats automatically:
- `.json`
- `.json5`
- `.yml`
- `.yaml`And following file names:
- `primp`
- `pretty-ts-imports`
- `prettytsimports`Examples of the config files may be found in
[examples](https://github.com/cptpiepmatz/pretty-ts-imports/tree/main/examples).Explanation of the config may be found in
[primp.json5](https://github.com/cptpiepmatz/pretty-ts-imports/tree/main/examples/configs/primp.json5)
or in
[primp.yml](https://github.com/cptpiepmatz/pretty-ts-imports/tree/main/examples/configs/primp.yml).## Programmatically Usage
If you want to use elements of this code in your codebase.
Either for handling imports yourself or using the sorter in webpack or anything
like that, you can easily import them from this package.You can find docs
[here](https://cptpiepmatz.github.io/pretty-ts-imports/modules.html).