Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Multi-purpose TypeScript hygiene tool to clean imports, enforce structure, and reduce clutter.

License

Notifications You must be signed in to change notification settings

remcostoeten/Hygienic

Repository files navigation

Resolving the unrelated histories error in Git

When you encounter the error message fatal: refusing to merge unrelated histories during a git pull, it means that the branches you are trying to merge do not share a common commit history.

This can happen if the repository history was rewritten or if the branches were independently created.

To resolve this error, you can use the --allow-unrelated-histories option with your git pull command:

git pull origin master --allow-unrelated-histories

This forces Git to merge the histories even if they are unrelated.

Be cautious when doing this, as it can lead to merge conflicts that you will need to resolve manually.

Would you like me to run this command for you now?

Hygienic

Hygienic is a versatile TypeScript tool that:

  • Cleans up unused imports, types, methods, and variables
  • Organizes barrel file imports
  • Enforces a consistent structure

👉 Making your colleagues hate you less during code reviews.


Install

bun add -g @remcostoeten/hygienic

Or run without installing:

bunx @remcostoeten/hygienic src/

pnpm also works, or npm/yarn if you're a maniac

Usage

hygienic src/          # Preview changes
hygienic src/ --fix    # Apply changes

Options

  • --check - Exit with error if changes needed (CI mode)
  • --verbose - Show detailed output
  • --except <patterns> - Skip files/folders
  • --include <patterns> - Only process these patterns
  • --config - Interactive setup

Examples

hygienic src/ --fix --sort
hygienic components/ --check   # CI mode
hygienic src/ --except test stories

What it does

Before:

import { Button } from '@/shared/components/ui/button';
import { Input } from '@/shared/components/ui/input';
import { Card } from '@/shared/components/ui/card';

After:

import { Button, Input, Card } from '@/shared/components/ui';

⚙️ Config

Run hygienic --config or edit ~/.config/import-consolidator/config.json:

{
  "barrelPaths": ["src/shared/components/ui/index.ts"],
  "extensions": [".tsx"],
  "sortImports": false
}

Features

  • Consolidates only when a barrel file exists
  • Creates backups before making changes
  • Caches results for speed
  • Git status checking
  • CI/CD support with --check

API

For build tools and custom integrations:

import { UIImportConsolidator, Config } from '@remcostoeten/hygienic';

const config = new Config();
await config.initialize();

const consolidator = new UIImportConsolidator(config);
await consolidator.initialize();

const results = await consolidator.processFiles(['src/'], false, true);

See examples/ for more.


xxx, Remco Stoeten

About

Multi-purpose TypeScript hygiene tool to clean imports, enforce structure, and reduce clutter.

Resources

License

Stars

Watchers

Forks

Packages

No packages published