Skip to content

Instantly share code, notes, and snippets.

View NeoSimvolist's full-sized avatar

Leonid NeoSimvolist

View GitHub Profile
# Автоматическая группировка импортов в исходном коде typescript
### Для работы понадобится jscodeshift
```
npm i -g jscodeshift
```
### Скачиваем скрипт и кладем в корень проекта с исходным кодом
https://gist.github.com/NeoSimvolist/88511054aea3dbbf6c117c340b3fe484#file-no-duplicate-imports-ts
/**
* Copyright (c) 2019-present, ProductBoard, Inc.
* All rights reserved.
*/
export default function transform(file, api) {
const j = api.jscodeshift;
const imports = j(file.source)
.find(j.ImportDeclaration)