Tired of manually configuring ESLint, Prettier, Commitlint, and other tools? This toolkit helps you set them up with a single command! It integrates the following commonly used tools with ready-to-use configurations:
- ESLint: Checks code quality and catches potential errors
- Prettier (optional): Enforces consistent code style
- czg + commitlint: Standardizes Git commit messages with conventional commit format
- lint-staged: Runs checks only on staged files for better performance
- husky: Uses Git hooks to automatically run checks before commits
You can either use the wizard-based automatic setup or manually configure each tool according to your project’s needs.
Run the following command in your project root, and all tools will be installed and configured automatically:
pnpm dlx @zanelab/lint-cli| Parameter | Description |
|---|---|
| No parameters | Installs and configures the full set of tools with default settings |
-I |
Interactive mode: lets you choose which tools to install/configure |
install |
Only installs the tools (does not generate config files) Add -I to interactively select which tools to install |
config |
Only generates configuration files (assumes tools are already installed) Add -I to interactively select which tools to configureAdd -f to force overwrite existing config files without prompting |
⚠️ Note: The wizard uses default settings to generate config files. If your project has special requirements, you can manually adjust them afterwards.
If you prefer finer control, follow these steps to install and configure each tool individually.
Our @zanelab/eslint-config is based on the powerful @antfu/eslint-config and adds some practical rules.
pnpm add -D eslint @zanelab/eslint-config eslint-plugin-formatCreate an eslint.config.js file in your project root:
For ES modules ("type": "module")
import { zanelab } from '@zanelab/eslint-config'
export default zanelab()For CommonJS ("type": "commonjs")
const { zanelab } = require('@zanelab/eslint-config')
module.exports = zanelab()- czg: Generates commit messages interactively following the Conventional Commits spec
- commitlint: Validates commit messages against the spec
pnpm add -D @commitlint/cli czg @zanelab/cz-configCreate a commitlint.config.js file:
ES modules
import { config } from '@zanelab/cz-config/commitlint'
export default configCommonJS
module.exports = require('@zanelab/cz-config')Works with husky to run checks only on files that are staged for commit, making it faster.
pnpm add -D lint-staged @zanelab/lint-stagedCreate a lint-staged.config.js file:
ES modules
import config from '@zanelab/lint-staged'
export default configCommonJS
module.exports = require('@zanelab/lint-staged')Used to run scripts automatically before Git operations (like commit, push).
- Follow the husky official documentation to install and initialize husky.
- Copy the hook scripts from
@zanelab/husky-configinto your.husky/directory. For example, you might runlint-stagedin thepre-commithook andcommitlintin thecommit-msghook.
We recommend using ESLint's formatting capabilities (following the philosophy of
@antfu/eslint-config), so Prettier is optional. If you're used to Prettier, you can install it separately.
pnpm add -D prettier @zanelab/prettier-configCreate a prettier.config.js file:
ES modules
import config from '@zanelab/prettier-config'
export default configCommonJS
module.exports = require('@zanelab/prettier-config')This toolkit's concepts and configurations draw inspiration from the following excellent projects:
Thanks to the authors of these projects for providing such convenient configuration solutions!