Skip to content

Commit

Permalink
Merge pull request #207 from vidavidorra/beta
Browse files Browse the repository at this point in the history
Beta
  • Loading branch information
jdbruijn authored Jun 22, 2023
2 parents 1e924b8 + 8362f48 commit 2e6058d
Show file tree
Hide file tree
Showing 17 changed files with 9,153 additions and 6,034 deletions.
57 changes: 0 additions & 57 deletions .eslintrc.js

This file was deleted.

9 changes: 5 additions & 4 deletions .github/lint-staged.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module.exports = {
const config = {
'*.{ts,tsx,js,jsx}': [
'prettier --write',
'npm run lint-es:file:fix',
() => 'npm run test',
'xo --fix',
() => 'ava'
],
'*.{vue,css,less,scss,html,htm,json,md,markdown,yml,yaml}':
'prettier --write',
};

export default config;
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
nodeVersion: [16, 18, 19]
nodeVersion: [16, 18, 20]
uses: vidavidorra/.github/.github/workflows/node-build.yml@831cdfeaf21957af495b3d518c1a877d5ffd3253 # v2.1.1
with:
nodeVersion: ${{ matrix.nodeVersion }}
Expand All @@ -23,7 +23,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [16, 18, 19]
node: [16, 18, 20]
uses: vidavidorra/.github/.github/workflows/node-test.yml@831cdfeaf21957af495b3d518c1a877d5ffd3253 # v2.1.1
with:
nodeVersion: ${{ matrix.node }}
Expand Down
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
## [2.0.1-beta.3](https://github.com/vidavidorra/commitlint-plugin-function-rules/compare/v2.0.1-beta.2...v2.0.1-beta.3) (2023-06-22)

### Styles

- use bold link for branding in header ([5bb540f](https://github.com/vidavidorra/commitlint-plugin-function-rules/commit/5bb540f95a23b63fa3083c3604ba12067b0981d1))

### Continuous Integration

- include Node.js v20 in testing and drop, almost EOL, v19 ([55a1856](https://github.com/vidavidorra/commitlint-plugin-function-rules/commit/55a185616bf0c7c315aaf3c81701e9125865325a))

## [2.0.1-beta.2](https://github.com/vidavidorra/commitlint-plugin-function-rules/compare/v2.0.1-beta.1...v2.0.1-beta.2) (2023-06-22)

### Build System

- change ESM import to plugin to prevent import errors ([c185ce3](https://github.com/vidavidorra/commitlint-plugin-function-rules/commit/c185ce3e4151fd943366bae022fede85828c8c48))

### Continuous Integration

- rename commitlint config to CommonJS to prevent commitlint module load error ([5c8627a](https://github.com/vidavidorra/commitlint-plugin-function-rules/commit/5c8627a73da97597176ca123f5ffc74ea0a99b78))

## [2.0.1-beta.1](https://github.com/vidavidorra/commitlint-plugin-function-rules/compare/v2.0.0...v2.0.1-beta.1) (2023-06-21)

### ⚠ BREAKING CHANGES

- change to ES module, export is still an CommonJS module as that's required by commitlint

### Code Refactoring

- change to ES module, export is still an CommonJS module as that's required by commitlint ([bf15a8a](https://github.com/vidavidorra/commitlint-plugin-function-rules/commit/bf15a8ab3f19c939ff5c69b45a274fc45ecddc5d))

## [2.0.0](https://github.com/vidavidorra/commitlint-plugin-function-rules/compare/v1.7.1...v2.0.0) (2023-06-19)

### ⚠ BREAKING CHANGES
Expand Down
35 changes: 13 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# commitlint plugin function rules
# [**commitlint**][commitlint] plugin function rules <!-- omit in toc -->

[commitlint][commitlint] plugin to use functions as rule value.
[**commitlint**][commitlint] plugin to use functions as rule value.

- Create custom function, `sync` or `async`, as rule value.
- Create rules that are based on the commit message.
- Write rules with regular expressions.
- Use the same rules that are [available](https://commitlint.js.org/#/reference-rules) in [commitlint][commitlint].
- Use the same rules that are [available in **commitlint**][commitlint].

---

Expand All @@ -17,28 +17,23 @@
[![Code coverage](https://img.shields.io/codecov/c/github/vidavidorra/commitlint-plugin-function-rules?logo=codecov&style=flat-square)](https://codecov.io/gh/vidavidorra/commitlint-plugin-function-rules)
[![License](https://img.shields.io/github/license/vidavidorra/commitlint-plugin-function-rules?style=flat-square)](LICENSE.md)

<a name="toc"></a>

## Table of contents

- [Install](#install)
- [Usage](#usage)
- [Documentation](#documentation)
- [Contributing](#contributing)
- [Security policy](#security-policy)
- [License](#license)

## Install

```shell
npm install --save-dev commitlint-plugin-function-rules @commitlint/cli
npm install --save-dev commitlint-plugin-function-rules @commitlint/cli @commitlint/config-conventional
```

## Usage

Use this plugin in your project's commitlint configuration by specifying it as item in the `plugins` array. All rules have same name as the [commitlint][commitlint] rules, but with the `function-rules` prefix.
Use this plugin in your project's [**commitlint**][commitlint] configuration by specifying it as item in the `plugins` array. All rules have same name as rules that are [available in **commitlint**][rules], but with the `function-rules` prefix. The example `commitlint.config.js`, or `commitlint.config.cjs` if the package is an ES module, shows the usage of a function rule.

> **_Note:_** The available rules are the same as in [commitlint][commitlint], so it is recommended to disable the [commitlint][commitlint] rule when specifying a function rule to avoid undefined behaviour.
> **Note** The available rules are the same as in [**commitlint**][commitlint], so it is recommended to disable the [**commitlint**][commitlint] rule when specifying a function rule to avoid undefined behaviour.
```js
module.exports = {
Expand All @@ -50,31 +45,26 @@ module.exports = {
2, // level: error
'always',
(parsed) => {
if (parsed.type === 'chore' && parsed.header.length < 20) {
// Allow longer headers for commits with "deps" scope.
if (parsed.scope === 'deps' && parsed.header.length <= 200) {
return [true];
}
return [false, 'chore header must not be longer than 120 characters'];
return [false, 'deps header must not be longer than 200 characters'];
},
],
},
};
```

## Documentation

## Contributing

Please [create an issue](https://github.com/vidavidorra/commitlint-plugin-function-rules/issues/new/choose) if you have a bug report, feature proposal or question that does not yet exist.

Please give this project a star ⭐ if you like it and consider becoming a [sponsor](https://github.com/sponsors/jdbruijn) to support this project.
Please [create an issue](https://github.com/vidavidorra/commitlint-plugin-function-rules/issues/new/choose) if you have a bug report or feature proposal, or [create a discussion](https://github.com/vidavidorra/commitlint-plugin-function-rules/discussions) if you have a question. If you like this project, please consider giving it a star ⭐ and/or become a [sponsor](https://github.com/sponsors/jdbruijn) to support my work.

Refer to the [contributing guide](https://github.com/vidavidorra/.github/blob/main/CONTRIBUTING.md) detailed information about other contributions, like pull requests.

[![Conventional Commits: 1.0.0](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow?style=flat-square)](https://conventionalcommits.org)
[![XO code style](https://shields.io/badge/code_style-5ed9c7?logo=xo&labelColor=gray&style=flat-square)](https://github.com/xojs/xo)
[![Code style](https://img.shields.io/badge/code_style-Prettier-ff69b4?logo=prettier&style=flat-square)](https://github.com/prettier/prettier)
[![Linting](https://img.shields.io/badge/linting-ESLint-lightgrey?logo=eslint&style=flat-square)](https://eslint.org)
[![Lint commit messages](https://img.shields.io/github/workflow/status/vidavidorra/commitlint-plugin-function-rules/Lint%20commit%20messages?logo=github&label=Lint%20commit%20messages&style=flat-square)](https://github.com/vidavidorra/commitlint-plugin-function-rules/actions)
[![Build](https://img.shields.io/github/workflow/status/vidavidorra/commitlint-plugin-function-rules/Build?logo=github&label=Build&style=flat-square)](https://github.com/vidavidorra/commitlint-plugin-function-rules/actions)

## Security policy

Expand All @@ -86,7 +76,7 @@ This project is licensed under the [GPLv3 license](https://www.gnu.org/licenses/

Copyright © 2020-2023 Jeroen de Bruijn

<details><summary>License details.</summary>
<details><summary>License notice</summary>
<p>

This program is free software: you can redistribute it and/or modify
Expand All @@ -109,3 +99,4 @@ The full text of the license is available in the [LICENSE](LICENSE.md) file in t
<!-- References -->

[commitlint]: https://commitlint.js.org/
[rules]: https://commitlint.js.org/#/reference-rules
38 changes: 38 additions & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
plugins: [
{
rules: {
'function-rules/header-max-length'(parsed) {
const {length} = parsed.header;
const maxLength = 100;
const maxDepsLength = 200;
const isDepsCommit =
/^(chore|fix)/.test(parsed.type) && parsed.scope === 'deps';
if (
(isDepsCommit && length > maxDepsLength) ||
(!isDepsCommit && length > maxLength)
) {
const type = isDepsCommit ? 'for dependency commits ' : '';
const maxCharacters = isDepsCommit ? maxDepsLength : maxLength;
return [
false,
[
`header ${type}must not be longer than ${maxCharacters}`,
`characters, current length is ${length}`,
].join(' '),
];
}

return [true];
},
},
},
],
rules: {
'body-max-line-length': [0],
'footer-max-line-length': [0],
'header-max-length': [0],
'function-rules/header-max-length': [2, 'always'],
},
};
57 changes: 0 additions & 57 deletions commitlint.config.js

This file was deleted.

Loading

0 comments on commit 2e6058d

Please sign in to comment.