Integrations
Integrate Denji with linters and formatters using lifecycle hooks
Denji provides lifecycle hooks that allow you to integrate with popular linters and formatters. Hooks run shell commands automatically after operations like adding or removing icons, ensuring your generated code stays formatted and lint-free.
Available Tools
ESLint
Pluggable JavaScript linter
Prettier
Opinionated code formatter
Biome
Fast all-in-one toolchain
Ultracite
Zero-config Biome preset
Oxlint
High-performance Rust linter
Oxfmt
Oxc project formatter
Available Hooks
Denji supports the following lifecycle hooks:
preAdd- Before adding iconspostAdd- After adding icons (most common)preRemove- Before removing iconspostRemove- After removing iconspreClear- Before clearing all iconspostClear- After clearing all iconspreList- Before listing iconspostList- After listing icons
The postAdd hook is the most commonly used, as it formats the generated icons file after new icons are added.
Configuration Format
Hooks are configured in your denji.json file:
{
"output": "./src/icons.tsx",
"framework": "react",
"typescript": true,
"hooks": {
"postAdd": [
"npx biome check --write ./src/icons.tsx"
]
}
}Each hook accepts an array of shell commands that run sequentially. If any command fails (exits with non-zero code), subsequent commands in that hook won't run.
Quick Examples
{
"hooks": {
"postAdd": [
"npx @biomejs/biome check --write ./src/icons.tsx"
]
}
}{
"hooks": {
"postAdd": [
"npx eslint --fix ./src/icons.tsx",
"npx prettier --write ./src/icons.tsx"
]
}
}{
"hooks": {
"postAdd": [
"npx ultracite fix ./src/icons.tsx"
]
}
}{
"hooks": {
"postAdd": [
"npx oxlint@latest ./src/icons.tsx",
"npx oxc@latest fmt ./src/icons.tsx"
]
}
}Best Practices
- Keep hooks fast - Hooks run after every operation, so use focused commands
- Use
postAddfor formatting - This is the most common use case - Avoid side effects - Hooks should only operate on the icons file
- Test your hooks - Run
denji addwith a test icon to verify hooks work - Use consistent tools - Don't mix conflicting formatters (e.g., Prettier + Biome)
- Commit your config - Share hook configuration with your team via version control
Running multiple formatters (like Prettier and Biome) can cause conflicts. Choose one formatter and stick with it.
Package Manager Support
Denji hooks work with any package manager. Adjust commands based on your setup:
{
"hooks": {
"postAdd": ["npx biome check --write ./src/icons.tsx"]
}
}{
"hooks": {
"postAdd": ["pnpm exec biome check --write ./src/icons.tsx"]
}
}{
"hooks": {
"postAdd": ["yarn exec biome check --write ./src/icons.tsx"]
}
}{
"hooks": {
"postAdd": ["bunx biome check --write ./src/icons.tsx"]
}
}Next Steps
Choose a tool from the list above to see detailed integration instructions and examples.