Skip to content

Commit

Permalink
docs: updated README
Browse files Browse the repository at this point in the history
Explain changes from the original conventional-commit
  • Loading branch information
JohnCampionJr committed Apr 4, 2023
1 parent bfde3ba commit a319ec8
Show file tree
Hide file tree
Showing 2 changed files with 199 additions and 27 deletions.
225 changes: 199 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,220 @@
# @jcamp/starter-typescript
> Lint your conventional commits, extended for use with [changelogen](https://github.com/unjs/changelogen)
Setup an empty repo for TypeScript / NPM packages for an easy start for future projects.
# commitlint-config-unjs

# Integrations
Shareable `commitlint` config enforcing [conventional commits](https://conventionalcommits.org/).
Use with [@commitlint/cli](https://npm.im/@commitlint/cli) and [@commitlint/prompt-cli](https://npm.im/@commitlint/prompt-cli).

## [Changelogen](https://github.com/unjs/changelogen)
## Changes

Creates / updates CHANGELOG.md; has GH Action for automatic release creation on GitHub
Identical to [@commitlint/config-conventional](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional), with these changes:

Note for prerelease versions (0.x.x), considers the 0.x.0 as the major, with the 0.0.x as the minor.
- Added `examples`, `types` for compatibility with [changelogen](https://github.com/unjs/changelogen)
- Updated commitzen icons to match [changelogen](https://github.com/unjs/changelogen)
- Added a `wip` type for commits that should not hit the changelog

## [simple-git-hooks](https://github.com/toplenboren/simple-git-hooks)
## Getting started

Easily allows GitHub hooks in a project \
Used for commitlint and lintstaged below
```sh
npm install --save-dev @commitlint-config-unjs @commitlint/cli
echo "module.exports = {extends: ['unjs']};" > commitlint.config.js
```

## [commitlint](https://commitlint.js.org/#/)
## Rules

Ensures commit messages follow conventions
### Problems

## [lint-staged](https://github.com/okonet/lint-staged)
The following rules are considered problems for `commitlint-config-unjs` and will yield a non-zero exit code when not met.

Consult [docs/rules](https://conventional-changelog.github.io/commitlint/#/reference-rules) for a list of available rules.

Lints all staged files to ensure code formatting is consistent.
#### type-enum

## [Eslint Config](https://github.com/jcamp-code/eslint-config)
- **condition**: `type` is found in value
- **rule**: `always`
- **level**: `error`
- **value**

My preferred eslint / prettier setup; extends [@antfu's config](https://github.com/antfu/eslint-config)
```
[
'build',
'chore',
'ci',
'docs',
'examples',
'feat',
'fix',
'perf',
'refactor',
'revert',
'style',
'test',
'types',
'wip'
];
```

## [Prettier](https://prettier.io/)
```sh
echo "foo: some message" # fails
echo "fix: some message" # passes
```

Standardized code formatting
#### type-case

## [Netlify](https://www.netlify.com)
- **description**: `type` is in case `value`
- **rule**: `always`
- **level**: `error`
- **value**
```
'lowerCase'
```

Standard deploy file (obviously delete if not needed)
```sh
echo "FIX: some message" # fails
echo "fix: some message" # passes
```

## [Unbuild](https://github.com/unjs/unbuild)
#### type-empty

Easy to use unified build system
- **condition**: `type` is empty
- **rule**: `never`
- **level**: `error`

# Workflow
```sh
echo ": some message" # fails
echo "fix: some message" # passes
```

- Make changes
- push commits / merge branches
- `pnpm release` - updates changelog and release version, commits, tags and pushes; publishes too by default
- GitHub Action creates GitHub release from the version (`v*`) tag
#### subject-case

- **condition**: `subject` is in one of the cases `['sentence-case', 'start-case', 'pascal-case', 'upper-case']`
- **rule**: `never`
- **level**: `error`

```sh
echo "fix(SCOPE): Some message" # fails
echo "fix(SCOPE): Some Message" # fails
echo "fix(SCOPE): SomeMessage" # fails
echo "fix(SCOPE): SOMEMESSAGE" # fails
echo "fix(scope): some message" # passes
echo "fix(scope): some Message" # passes
```

#### subject-empty

- **condition**: `subject` is empty
- **rule**: `never`
- **level**: `error`

```sh
echo "fix:" # fails
echo "fix: some message" # passes
```

#### subject-full-stop

- **condition**: `subject` ends with `value`
- **rule**: `never`
- **level**: `error`
- **value**

```
'.'
```

```sh
echo "fix: some message." # fails
echo "fix: some message" # passes
```

#### header-max-length

- **condition**: `header` has `value` or less characters
- **rule**: `always`
- **level**: `error`
- **value**

```
100
```

```sh
echo "fix: some message that is way too long and breaks the line max-length by several characters" # fails
echo "fix: some message" # passes
```

#### footer-leading-blank

- **condition**: `footer` should have a leading blank line
- **rule**: `always`
- level: `warning`

```sh
echo "fix: some message
BREAKING CHANGE: It will be significant" # warning

echo "fix: some message
BREAKING CHANGE: It will be significant" # passes
```

#### footer-max-line-length

- **condition**: `footer` each line has `value` or less characters
- **rule**: `always`
- level: `error`
- **value**

```
100
```

```sh
echo "fix: some message
BREAKING CHANGE: footer with multiple lines
has a message that is way too long and will break the line rule 'line-max-length' by several characters" # fails

echo "fix: some message
BREAKING CHANGE: footer with multiple lines
but still no line is too long" # passes
```

#### body-leading-blank

- **condition**: `body` should have a leading blank line
- **rule**: `always`
- level: `warning`

```sh
echo "fix: some message
body" # warning

echo "fix: some message
body" # passes
```

#### body-max-line-length

- **condition**: `body` each line has `value` or less characters
- **rule**: `always`
- level: `error`
- **value**

```
100
```

```sh
echo "fix: some message
body with multiple lines
has a message that is way too long and will break the line rule 'line-max-length' by several characters" # fails

echo "fix: some message
body with multiple lines
but still no line is too long" # passes
```
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "commitlint-config-unjs",
"type": "module",
"version": "0.2.0",
"private": true,
"description": "A commitlint config for unjs's changelogen tool",
"author": "John Campion",
"license": "MIT",
Expand Down

0 comments on commit a319ec8

Please sign in to comment.