Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions docs/guides/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@ deno add -D npm:@commitlint/cli npm:@commitlint/config-conventional

Configure commitlint to use conventional config

```sh
::: code-group

```sh [Linux / macOS]
echo "export default { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
```

> [!NOTE]
> **Windows users:** The `echo` command in PowerShell and `cmd.exe` may create the config file with a non-UTF-8 encoding (e.g. UTF-16LE or the system's default ANSI code page), which can cause commitlint to fail to read the configuration. To avoid this, create `commitlint.config.js` manually in your editor, or use PowerShell with explicit encoding:
>
> ```powershell
> "export default { extends: ['@commitlint/config-conventional'] };" | Out-File -Encoding utf8 commitlint.config.js
> ```
```sh [Windows]
# Here we use the node command to avoid encoding issue on Windows.
node -e "fs.writeFileSync('commitlint.config.js', process.argv[1])" "export default { extends: ['@commitlint/config-conventional'] };"
Comment thread
escapedcat marked this conversation as resolved.
```

:::

> [!WARNING]
> Node v24 changes the way that modules are loaded, and this includes the commitlint config file. If your project does not contain a `package.json`, commitlint may fail to load the config, resulting in a `Please add rules to your commitlint.config.js` error message. This can be fixed by doing either of the following:
Expand Down
116 changes: 103 additions & 13 deletions docs/guides/local-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ You can find complete setup instructions on the [official documentation](https:/
> The following instructions are meant to `husky@v9` if you are using a different version
> consult the official documentation of your version.

> [!WARNING]
> For Windows users: ensure all `husky` files are `UTF-8` enconded. If any other format is used an error may be thrown at runtime such as [cannot execute binary file](https://github.com/typicode/husky/issues/1426).

---

::::tabs
=== Linux / macOS

:::tabs
== npm

Expand All @@ -38,8 +38,6 @@ npx husky install

# Add commit message linting to commit-msg hook
echo "npx --no -- commitlint --edit \$1" > .husky/commit-msg
# Windows users should use ` to escape dollar signs
echo "npx --no -- commitlint --edit `$1`" > .husky/commit-msg
```

As an alternative you can create a script inside `package.json`
Expand All @@ -61,8 +59,6 @@ yarn husky install

# Add commit message linting to commit-msg hook
echo "yarn commitlint --edit \$1" > .husky/commit-msg
# Windows users should use ` to escape dollar signs
echo "yarn commitlint --edit `$1`" > .husky/commit-msg
```

As an alternative you can create a script inside `package.json`
Expand All @@ -87,8 +83,6 @@ pnpm husky install

# Add commit message linting to commit-msg hook
echo "pnpm dlx commitlint --edit \$1" > .husky/commit-msg
# Windows users should use ` to escape dollar signs
echo "pnpm dlx commitlint --edit `$1`" > .husky/commit-msg
```

As an alternative you can create a script inside `package.json`
Expand All @@ -110,8 +104,6 @@ bunx husky install

# Add commit message linting to commit-msg hook
echo "bunx commitlint --edit \$1" > .husky/commit-msg
# Windows users should use ` to escape dollar signs
echo "bunx commitlint --edit `$1`" > .husky/commit-msg
```

== deno
Expand All @@ -126,12 +118,110 @@ deno task --eval husky install

# Add commit message linting to commit-msg hook
echo "deno task --eval commitlint --edit \$1" > .husky/commit-msg
# Windows users should use ` to escape dollar signs
echo "deno task --eval commitlint --edit `$1`" > .husky/commit-msg
```

:::

=== Windows

:::tabs
== npm

```sh
npm install --save-dev husky

# husky@v9
npx husky init
# husky@v8 or lower
npx husky install

# Add commit message linting to commit-msg hook
node -e "fs.writeFileSync('.husky/commit-msg', 'npx --no -- commitlint --edit $'+'1\n')"
Comment thread
festoney8 marked this conversation as resolved.
```

As an alternative you can create a script inside `package.json`

```sh
npm pkg set scripts.commitlint="commitlint --edit"
node -e "fs.writeFileSync('.husky/commit-msg', 'npm run commitlint $'+'{1}\n')"
Comment thread
festoney8 marked this conversation as resolved.
```

== yarn

```sh
yarn add --dev husky

# husky@v9
yarn husky init
# husky@v8 or lower
yarn husky install

# Add commit message linting to commit-msg hook
node -e "fs.writeFileSync('.husky/commit-msg', 'yarn commitlint --edit $'+'1\n')"
Comment thread
festoney8 marked this conversation as resolved.
```

As an alternative you can create a script inside `package.json`

```sh
npm pkg set scripts.commitlint="commitlint --edit"
node -e "fs.writeFileSync('.husky/commit-msg', 'yarn commitlint $'+'{1}\n')"
Comment thread
festoney8 marked this conversation as resolved.
```

> [!WARNING]
> Please note that currently @commitlint/cli doesn't support yarn v2 Plug'n'Play (using yarn > v2 with `nodeLinker: node-modules` in your .yarnrc.yml file may work sometimes)

== pnpm

```sh
pnpm add --save-dev husky

# husky@v9
pnpm husky init
# husky@v8 or lower
pnpm husky install

# Add commit message linting to commit-msg hook
node -e "fs.writeFileSync('.husky/commit-msg', 'pnpm dlx commitlint --edit $'+'1\n')"
Comment thread
festoney8 marked this conversation as resolved.
```

As an alternative you can create a script inside `package.json`

```sh
npm pkg set scripts.commitlint="commitlint --edit"
node -e "fs.writeFileSync('.husky/commit-msg', 'pnpm commitlint $'+'{1}\n')"
Comment thread
festoney8 marked this conversation as resolved.
```

== bun

```sh
bun add --dev husky

# husky@v9
bunx husky init
# husky@v8 or lower
bunx husky install

# Add commit message linting to commit-msg hook
node -e "fs.writeFileSync('.husky/commit-msg', 'bunx commitlint --edit $'+'1\n')"
Comment thread
festoney8 marked this conversation as resolved.
```

== deno

```sh
deno add --dev husky

# husky@v9
deno task --eval husky init
# husky@v8 or lower
deno task --eval husky install

# Add commit message linting to commit-msg hook
node -e "fs.writeFileSync('.husky/commit-msg', 'deno task --eval commitlint --edit $'+'1\n')"
Comment thread
festoney8 marked this conversation as resolved.
```

:::
::::

---

### Using git hooks
Expand Down