@ethima/commitlint-config 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +23 -16
  2. package/package.json +6 -6
  3. package/src/index.js +16 -2
package/README.md CHANGED
@@ -10,22 +10,28 @@ adjustments as detailed below.
10
10
 
11
11
  ### More lenient rules regarding long lines in bodies and footers
12
12
 
13
- When referencing URIs in commit messages, which is a common scenario when
14
- referencing code on source hosting platforms, etc., it is trivial to trigger
15
- the `{body,footer}-max-line-length` rules.
16
-
17
- To ensure URIs like these can be included in commit messages, this
18
- configuration replaces the `{body,footer}-max-line-length` rules with the
19
- `{body,footer}-max-line-length-with-footnote-exemption` rules. These rules
20
- allow long lines in either the body or the footer of commit messages if they
21
- are written as Markdown footnotes, e.g. `[^1]: <long line>`,
22
- `[^named-footnote]: <long line>`. These footnotes can then be referenced
23
- elsewhere in the commit message and most hosting platforms will render these
24
- footnotes with proper links, etc.
25
-
26
- Both the `body-` and `footer-` rules are replaced as some URIs may trigger the
27
- footer detection in the commit meesage parser, particularly when a URI includes
28
- a `#`.
13
+ When referencing URIs in commit messages it is trivial to trigger the
14
+ `{body,footer}-max-line-length` rules. This is a common scenario when
15
+ referencing code, commits, etc. on source hosting platforms.
16
+
17
+ One scenario in which long URIs in a commit message are common are release
18
+ commits of the semantic release process. Specifically linking to source commits
19
+ for changelog entries, see [the initial release of this configuration for an
20
+ example][ethima-commitlint-config-initial-release-commit-url]. These commits,
21
+ assumed to have a header of the form `build|chore(release): v<x.y.z>`, are
22
+ exempt from any checks.
23
+
24
+ Other long URI references can be included in commit messages by writing them as
25
+ Markdown footnotes, e.g. `[^1]: <long URI>`, `[^named-footnote]: <long URI>` at
26
+ the end of the commit message and referencing them from the body. Most hosting
27
+ platforms will render these footnotes with proper links, etc. in various places
28
+ in their UI. To support this functionality, this configuration replaces the
29
+ `{body,footer}-max-line-length` rules with the
30
+ `{body,footer}-max-line-length-with-footnote-exemption` rules. Apart from the
31
+ exemption, these rules behave the same as the original rules and accept the
32
+ same configuration. Both the `body-` and `footer-` rules are replaced as some
33
+ URIs may trigger the footer detection in the commit message parser,
34
+ particularly when a URI includes a `#`.
29
35
 
30
36
  ### Stricter rules on merge and `fixup!`/`squash!` commits
31
37
 
@@ -54,4 +60,5 @@ into (pre)release branches.
54
60
  [commitlint-is-ignored-wildcards-url]: https://github.com/conventional-changelog/commitlint/blob/3bc4726f0dddfa051bc75f6af7b7ca076b04a839/%40commitlint/is-ignored/src/defaults.ts#L17-L29
55
61
  [commitlint-url]: https://commitlint.js.org
56
62
  [conventional-commits-url]: https://conventionalcommits.org/
63
+ [ethima-commitlint-config-initial-release-commit-url]: https://gitlab.com/ethima/commitlint-config/-/commit/3c32023a5647f8bf4090e1158a3d1f4fa9279324
57
64
  [ethima-url]: https://gitlab.com/ethima/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethima/commitlint-config",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "A shareable Commitlint configuration for the Ethima organization",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -22,12 +22,12 @@
22
22
  },
23
23
  "homepage": "https://gitlab.com/ethima/commitlint-config",
24
24
  "dependencies": {
25
- "@commitlint/config-conventional": "18.1.0",
26
- "@commitlint/is-ignored": "18.1.0"
25
+ "@commitlint/config-conventional": "18.4.3",
26
+ "@commitlint/is-ignored": "18.4.3"
27
27
  },
28
28
  "devDependencies": {
29
- "@commitlint/lint": "18.1.0",
30
- "@commitlint/load": "18.2.0",
31
- "ava": "5.3.1"
29
+ "@commitlint/lint": "18.4.3",
30
+ "@commitlint/load": "18.4.3",
31
+ "ava": "6.0.1"
32
32
  }
33
33
  }
package/src/index.js CHANGED
@@ -5,6 +5,12 @@ const {
5
5
 
6
6
  const footnoteMatcher = new RegExp("^\\[\\^.+?\\]:");
7
7
 
8
+ // Matches the header of commits representing semantic releases
9
+ const semanticReleaseCommitMatcher = new RegExp(
10
+ "^(build|chore)\\(release\\):\\s*v?\\d+(\\.\\d+){2}.*$",
11
+ "m",
12
+ );
13
+
8
14
  // When referencing URIs in commit messages, it is very common to hit
9
15
  // `max-line-length` restrictions. As a work-around, these URIs may be added as
10
16
  // Markdown footnotes which can then be detected and given an exemption
@@ -37,18 +43,26 @@ const buildMaxLineLengthWithFootnoteExemption = (section) => {
37
43
  //
38
44
  // Instead of duplicating these function definitions, it is more
39
45
  // straightforward to obtain them from the defaults
40
- const ignores = defaultIgnoreFunctions.filter(
46
+ const applicableDefaultIgnoreFunctions = defaultIgnoreFunctions.filter(
41
47
  (ignoreFunction) =>
42
48
  ignoreFunction("Revert ") || ignoreFunction("Merge 'x' into 'y' "),
43
49
  );
44
50
 
51
+ // Ignore functions specific to this commitlint configuration
52
+ const configurationSpecificIgnoreFunctions = [
53
+ semanticReleaseCommitMatcher.test.bind(semanticReleaseCommitMatcher),
54
+ ];
55
+
45
56
  module.exports = {
46
57
  // Do not use the default ignore patterns as they allow patterns, e.g.
47
58
  // `fixup!` and `squash!` commits, that should be blocked in the workflows
48
59
  // primarily supported by this configuration
49
60
  defaultIgnores: false,
50
61
  extends: ["@commitlint/config-conventional"],
51
- ignores,
62
+ ignores: [
63
+ ...applicableDefaultIgnoreFunctions,
64
+ ...configurationSpecificIgnoreFunctions,
65
+ ],
52
66
  plugins: [
53
67
  {
54
68
  rules: {