Skip to content

Commit 2e6058d

Browse files
authored
Merge pull request #207 from vidavidorra/beta
Beta
2 parents 1e924b8 + 8362f48 commit 2e6058d

17 files changed

+9153
-6034
lines changed

Diff for: .eslintrc.js

-57
This file was deleted.

Diff for: .github/lint-staged.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
module.exports = {
1+
const config = {
22
'*.{ts,tsx,js,jsx}': [
3-
'prettier --write',
4-
'npm run lint-es:file:fix',
5-
() => 'npm run test',
3+
'xo --fix',
4+
() => 'ava'
65
],
76
'*.{vue,css,less,scss,html,htm,json,md,markdown,yml,yaml}':
87
'prettier --write',
98
};
9+
10+
export default config;

Diff for: .github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
nodeVersion: [16, 18, 19]
17+
nodeVersion: [16, 18, 20]
1818
uses: vidavidorra/.github/.github/workflows/node-build.yml@831cdfeaf21957af495b3d518c1a877d5ffd3253 # v2.1.1
1919
with:
2020
nodeVersion: ${{ matrix.nodeVersion }}
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
fail-fast: false
2525
matrix:
26-
node: [16, 18, 19]
26+
node: [16, 18, 20]
2727
uses: vidavidorra/.github/.github/workflows/node-test.yml@831cdfeaf21957af495b3d518c1a877d5ffd3253 # v2.1.1
2828
with:
2929
nodeVersion: ${{ matrix.node }}

Diff for: CHANGELOG.md

+30
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
## [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)
2+
3+
### Styles
4+
5+
- use bold link for branding in header ([5bb540f](https://github.com/vidavidorra/commitlint-plugin-function-rules/commit/5bb540f95a23b63fa3083c3604ba12067b0981d1))
6+
7+
### Continuous Integration
8+
9+
- include Node.js v20 in testing and drop, almost EOL, v19 ([55a1856](https://github.com/vidavidorra/commitlint-plugin-function-rules/commit/55a185616bf0c7c315aaf3c81701e9125865325a))
10+
11+
## [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)
12+
13+
### Build System
14+
15+
- change ESM import to plugin to prevent import errors ([c185ce3](https://github.com/vidavidorra/commitlint-plugin-function-rules/commit/c185ce3e4151fd943366bae022fede85828c8c48))
16+
17+
### Continuous Integration
18+
19+
- rename commitlint config to CommonJS to prevent commitlint module load error ([5c8627a](https://github.com/vidavidorra/commitlint-plugin-function-rules/commit/5c8627a73da97597176ca123f5ffc74ea0a99b78))
20+
21+
## [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)
22+
23+
### ⚠ BREAKING CHANGES
24+
25+
- change to ES module, export is still an CommonJS module as that's required by commitlint
26+
27+
### Code Refactoring
28+
29+
- 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))
30+
131
## [2.0.0](https://github.com/vidavidorra/commitlint-plugin-function-rules/compare/v1.7.1...v2.0.0) (2023-06-19)
232

333
### ⚠ BREAKING CHANGES

Diff for: README.md

+13-22
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# commitlint plugin function rules
1+
# [**commitlint**][commitlint] plugin function rules <!-- omit in toc -->
22

3-
[commitlint][commitlint] plugin to use functions as rule value.
3+
[**commitlint**][commitlint] plugin to use functions as rule value.
44

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

1010
---
1111

@@ -17,28 +17,23 @@
1717
[![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)
1818
[![License](https://img.shields.io/github/license/vidavidorra/commitlint-plugin-function-rules?style=flat-square)](LICENSE.md)
1919

20-
<a name="toc"></a>
21-
22-
## Table of contents
23-
2420
- [Install](#install)
2521
- [Usage](#usage)
26-
- [Documentation](#documentation)
2722
- [Contributing](#contributing)
2823
- [Security policy](#security-policy)
2924
- [License](#license)
3025

3126
## Install
3227

3328
```shell
34-
npm install --save-dev commitlint-plugin-function-rules @commitlint/cli
29+
npm install --save-dev commitlint-plugin-function-rules @commitlint/cli @commitlint/config-conventional
3530
```
3631

3732
## Usage
3833

39-
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.
34+
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.
4035

41-
> **_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.
36+
> **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.
4237
4338
```js
4439
module.exports = {
@@ -50,31 +45,26 @@ module.exports = {
5045
2, // level: error
5146
'always',
5247
(parsed) => {
53-
if (parsed.type === 'chore' && parsed.header.length < 20) {
48+
// Allow longer headers for commits with "deps" scope.
49+
if (parsed.scope === 'deps' && parsed.header.length <= 200) {
5450
return [true];
5551
}
56-
return [false, 'chore header must not be longer than 120 characters'];
52+
return [false, 'deps header must not be longer than 200 characters'];
5753
},
5854
],
5955
},
6056
};
6157
```
6258

63-
## Documentation
64-
6559
## Contributing
6660

67-
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.
68-
69-
Please give this project a star ⭐ if you like it and consider becoming a [sponsor](https://github.com/sponsors/jdbruijn) to support this project.
61+
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.
7062

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

7365
[![Conventional Commits: 1.0.0](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow?style=flat-square)](https://conventionalcommits.org)
66+
[![XO code style](https://shields.io/badge/code_style-5ed9c7?logo=xo&labelColor=gray&style=flat-square)](https://github.com/xojs/xo)
7467
[![Code style](https://img.shields.io/badge/code_style-Prettier-ff69b4?logo=prettier&style=flat-square)](https://github.com/prettier/prettier)
75-
[![Linting](https://img.shields.io/badge/linting-ESLint-lightgrey?logo=eslint&style=flat-square)](https://eslint.org)
76-
[![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)
77-
[![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)
7868

7969
## Security policy
8070

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

8777
Copyright © 2020-2023 Jeroen de Bruijn
8878

89-
<details><summary>License details.</summary>
79+
<details><summary>License notice</summary>
9080
<p>
9181

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

111101
[commitlint]: https://commitlint.js.org/
102+
[rules]: https://commitlint.js.org/#/reference-rules

Diff for: commitlint.config.cjs

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
plugins: [
4+
{
5+
rules: {
6+
'function-rules/header-max-length'(parsed) {
7+
const {length} = parsed.header;
8+
const maxLength = 100;
9+
const maxDepsLength = 200;
10+
const isDepsCommit =
11+
/^(chore|fix)/.test(parsed.type) && parsed.scope === 'deps';
12+
if (
13+
(isDepsCommit && length > maxDepsLength) ||
14+
(!isDepsCommit && length > maxLength)
15+
) {
16+
const type = isDepsCommit ? 'for dependency commits ' : '';
17+
const maxCharacters = isDepsCommit ? maxDepsLength : maxLength;
18+
return [
19+
false,
20+
[
21+
`header ${type}must not be longer than ${maxCharacters}`,
22+
`characters, current length is ${length}`,
23+
].join(' '),
24+
];
25+
}
26+
27+
return [true];
28+
},
29+
},
30+
},
31+
],
32+
rules: {
33+
'body-max-line-length': [0],
34+
'footer-max-line-length': [0],
35+
'header-max-length': [0],
36+
'function-rules/header-max-length': [2, 'always'],
37+
},
38+
};

Diff for: commitlint.config.js

-57
This file was deleted.

0 commit comments

Comments
 (0)