# seven-rule-msg

> Minimal, opinionated commit message validator

Latest version **1.0.0** (published 2019-07-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install seven-rule-msg
pnpm add seven-rule-msg
yarn add seven-rule-msg
bun add seven-rule-msg
```

Provides the command `seven-rule-msg`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-07-24 |
| First published | 2019-01-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=10.1.0 |
| Dependencies | 6 |
| Unpacked size | 13.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Shreyas Minocha |
| Maintainers | shreyasminocha |
| Keywords | commit-msg, commitlint, git, sevenrules |

## Links

- npm: https://www.npmjs.com/package/seven-rule-msg
- Repository: https://github.com/shreyasminocha/seven-rule-msg
- Homepage: https://github.com/shreyasminocha/seven-rule-msg#readme
- Issues: https://github.com/shreyasminocha/seven-rule-msg/issues
- npm.io page: https://npm.io/package/seven-rule-msg

## Dependencies (6)

- [meow](https://npm.io/package/meow.md) ^5.0.0
- [chalk](https://npm.io/package/chalk.md) ^2.4.2
- [get-stdin](https://npm.io/package/get-stdin.md) ^7.0.0
- [@types/meow](https://npm.io/package/@types/meow.md) ^5.0.0
- [@types/node](https://npm.io/package/@types/node.md) ^12.6.8
- [log-symbols](https://npm.io/package/log-symbols.md) ^2.2.0

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2019-07-24
- 0.1.0 — 2019-01-13

## README

# seven-rule-msg

[![Build status](https://img.shields.io/travis/com/shreyasminocha/seven-rule-msg/master.svg)](//travis-ci.org/shreyasminocha/seven-rule-msg)
[![Npm version](https://img.shields.io/npm/v/seven-rule-msg.svg)](//npmjs.com/package/seven-rule-msg)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](//shreyas.mit-license.org/2019)
[![Commit message style](https://img.shields.io/badge/commit%20messages-seven%20rules-blue.svg)](//chris.beams.io/posts/git-commit)

![seven-rule-msg in action](https://raw.githubusercontent.com/shreyasminocha/seven-rule-msg/master/media/demo.jpg)

Minimal, opinionated commit message validator.

## Rules

All rules are inspired from [Chris' post and its predecessors](https://chris.beams.io/posts/git-commit).

1. [Separate subject from body with a blank line](https://chris.beams.io/posts/git-commit/#separate)
2. [Limit the subject line to 50 characters](https://chris.beams.io/posts/git-commit/#limit-50)
3. [Capitalize the subject line](https://chris.beams.io/posts/git-commit/#capitalize)
4. [Do not end the subject line with a period](https://chris.beams.io/posts/git-commit/#end)
5. [Use the imperative mood in the subject line](https://chris.beams.io/posts/git-commit/#imperative) (not checked)
6. [Wrap the body at 72 characters](https://chris.beams.io/posts/git-commit/#wrap-72)
7. [Use the body to explain what and why vs. how](https://chris.beams.io/posts/git-commit/#why-not-how) (not checked)

## Features

- No configuration required
- Beautiful output
- Read from `$1`
- Read from file
- Read from `STDIN`
- Verbose mode
- Silent mode

## Installation

Assuming you have [`npm`](//npmjs.com) installed,

```sh
npm install --global seven-rule-msg-cli
```

## Usage

### From CLI

See also: [`usage.txt`](usage.txt).

#### CLI Argument

```sh
seven-rule-msg 'Fix all the stuff'
```

#### File

```sh
seven-rule-msg [--file|-f] <path-to-file>
```

#### `STDIN`

```sh
echo 'Fix all the stuff' | seven-rule-msg
```

### As git hook

`.git/hooks/commit-msg`:

```sh
!/bin/sh

seven-rule-msg -f "$1"
```

### Using the node.js API

```js
import validate from 'seven-rule-msg';

const results = validate('A nice lil commit message');
```

#### `validate(commitMessage: string)`

- Return value: `Result[]`
    - Length: `7`

The `i`th element of the returned array corresponds to the `i + 1`th rule.

```ts
interface Result {
    readonly rule: Rule,
    readonly type: ResultType
}
```

```ts
interface Rule {
    readonly message: string,
    readonly test?: (commitMessage: string) => boolean;
}
```

`Rule`s without `test` methods are informative only. In other words, they cannot be reliably checked programmatically.

```ts
enum ResultType {
    pass = 'pass',
    fail = 'fail',
    info = 'info'
}
```

## Badge

Here's a badge to show the world that you follow the seven rules of commit messages.

```md
[![Commit message style](https://img.shields.io/badge/commit%20messages-seven%20rules-blue.svg)](https://chris.beams.io/posts/git-commit)
```

## License

Licensed under the [MIT License](//shreyas.mit-license.org/2019).

---
_Source: https://npm.io/package/seven-rule-msg · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
