| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
One keystroke. One click. Hundreds of files organized. — A lightweight, modern VSCode extension that sorts and organizes your TypeScript/JavaScript imports.
Read the full story: TypeScript Hero is dead (is yet another VS Code extension gone forever?)
Before organizing imports:
import { UserDetail } from './components/user-detail';
import { Component } from '@angular/core';
import { UnusedService } from './services/unused';
import {Router} from "@angular/router"
import { map, switchMap } from 'rxjs/operators';
import {OnInit, inject} from "@angular/core"
import { BookList } from './components/book-list';After pressing Ctrl+Alt+O (or Cmd+Alt+O on macOS):
import { Component, inject, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { map, switchMap } from 'rxjs/operators';
import { BookList } from './components/book-list';
import { UserDetail } from './components/user-detail';What happened:
The defaults are already great! Just install and you're ready to go:
That's it! Your imports are now organized.
Want to customize? See the Configuration Cookbook for ready-to-use presets (Angular, React, Node, Monorepo).
Access these commands via Command Palette (Ctrl+Shift+P / Cmd+Shift+P):
Tip: Workspace and folder commands automatically skip build artifacts (node_modules, dist, build, etc.). You can add custom exclude patterns for auto-generated files — see excludePatterns configuration.
Enable automatic import organization when saving files:
{
"miniTypescriptHero.imports.organizeOnSave": true
}Tip: If you enable organizeOnSave, disable VS Code's built-in source.organizeImports to avoid conflicts. Use the "Check for configuration conflicts" command to detect issues.
VS Code has a built-in "Organize Imports" that removes unused imports and sorts alphabetically. Since TypeScript 4.7+, it preserves blank lines you manually add between groups.
The key difference: VS Code requires manual blank lines for grouping (you type them, VS Code preserves them). Mini TypeScript Hero automatically creates groups based on patterns.
❌ Automatically create groups based on patterns — VS Code sorts everything alphabetically unless you manually add blank lines
❌ Remove /index from paths — Keeps ./foo/index as-is instead of cleaning to ./foo
❌ Sort by first specifier — Only sorts by module path, not by the first imported name
Mini TypeScript Hero with default grouping (["Plains", "Modules", "Workspace"]):
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { map, switchMap } from 'rxjs/operators';
import { BookList } from './components/book-list';
import { UserDetail } from './components/user-detail';External imports (node_modules) automatically separated from internal imports (local files) with a blank line.
VS Code built-in without manual blank lines:
import { BookList } from './components/book-list';
import { UserDetail } from './components/user-detail';
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { map, switchMap } from 'rxjs/operators';Everything sorted alphabetically as one flat list (by module specifier). To separate them, you'd manually add a blank line and maintain it every time you add imports.
Your settings auto-migrate on first use. Legacy mode enabled automatically for compatibility.
Full migration details: See Migration Guide
Mini TypeScript Hero focuses on import organization. Prettier and ESLint still own formatting and linting. They work together as long as only one tool sorts imports.
On save:
{
"miniTypescriptHero.imports.organizeOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": false // IMPORTANT: disable VS Code built-in
}
}Why disable source.organizeImports? If both Mini TS Hero and VS Code built-in organize imports on save, your imports get rearranged multiple times.
Check conflicts automatically: Run "Mini TS Hero: Check for configuration conflicts" from the Command Palette.
Turn off import-sorting rules in ESLint:
// .eslintrc.js
module.exports = {
rules: {
"sort-imports": "off",
"import/order": "off",
}
};Disable Prettier plugins that sort imports:
If your team already has ESLint/Prettier import-sorting, use Mini TS Hero mainly for unused import removal:
{
"miniTypescriptHero.imports.disableImportsSorting": true,
"miniTypescriptHero.imports.disableImportRemovalOnOrganize": false,
"miniTypescriptHero.imports.mergeImportsFromSameModule": false
}Mini TS Hero respects your VS Code settings by default:
To reduce friction with Prettier, match your VS Code settings to your Prettier config. For team projects, see the Monorepo preset which shows how to use useOnlyExtensionSettings to enforce consistent formatting.
This extension does not collect any telemetry or user data. Your code, settings, and usage patterns remain completely private.
The extension preserves most comments in your import blocks:
Preserved:
Best Practice: Put critical comments above the import statement for maximum visibility.
Legacy mode (legacyMode: true) is automatically enabled for users migrating from the original TypeScript Hero extension. In this mode, some settings behave differently to maintain output compatibility:
New users get legacyMode: false by default. You can toggle this setting anytime via the command palette.
This extension continues TypeScript Hero by Christoph Bühler. The original went unmaintained, so I picked it up and modernized it.
MIT License — Copyright (c) Angular.Schule (by Johannes Hoppe)
MIT License — Original work Copyright (c) Christoph Bühler
🇬🇧 mini-typescript-hero is brought to you by the Angular.Schule team – two Google Developer Experts (GDE) from Germany. We get you and your team up to speed with Angular through remote trainings in English! Visit angular.schule to learn more.
🇩🇪 mini-typescript-hero wurde für Sie entwickelt von der Angular.Schule! Wir machen Sie und Ihr Team fit für das Webframework Angular – in offenen Gruppen oder individuellen Inhouse-Schulungen. Von den Buchautoren und Google Developer Experts (GDE) Johannes Hoppe und Ferdinand Malcher.
| Back | FazBrowse Home | New Git URL |