@crowdstrike/commitlint 8.0.2 → 8.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.
package/bin/index.js CHANGED
@@ -15,10 +15,18 @@ const { argv } = require('yargs')
15
15
  default: defaultBranch,
16
16
  description: `Use a different branch point other than ${defaultBranch}`,
17
17
  },
18
+ 'lint-every-commit': {
19
+ type: 'boolean',
20
+ default: false,
21
+ description: 'lint every commit including normally ignored errors',
22
+ },
18
23
  });
19
24
 
20
25
  (async () => {
21
- let formatted = await commitlint(argv);
26
+ let formatted = await commitlint({
27
+ ...argv,
28
+ shouldLintEveryCommit: argv['lint-every-commit'],
29
+ });
22
30
 
23
31
  console.log(formatted);
24
32
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdstrike/commitlint",
3
- "version": "8.0.2",
3
+ "version": "8.1.0",
4
4
  "description": "commitlint settings for CrowdStrike",
5
5
  "bin": {
6
6
  "commitlint": "bin/index.js"
@@ -41,11 +41,11 @@
41
41
  "node": ">=18.12"
42
42
  },
43
43
  "dependencies": {
44
- "@commitlint/config-conventional": "^18.0.0",
45
- "@commitlint/format": "^18.0.0",
46
- "@commitlint/lint": "^18.0.0",
47
- "@commitlint/load": "^18.0.0",
48
- "@commitlint/read": "^18.0.0",
44
+ "@commitlint/config-conventional": "^19.0.0",
45
+ "@commitlint/format": "^19.0.0",
46
+ "@commitlint/lint": "^19.0.0",
47
+ "@commitlint/load": "^19.0.0",
48
+ "@commitlint/read": "^19.0.0",
49
49
  "commitlint-format-junit": "^1.1.4",
50
50
  "debug": "^4.1.1",
51
51
  "execa": "^9.0.0",
package/src/index.js CHANGED
@@ -1,9 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const load = require('@commitlint/load').default;
4
- const read = require('@commitlint/read').default;
5
- const lint = require('@commitlint/lint').default;
6
- const { format } = require('@commitlint/format');
7
3
  const formatJunit = require('commitlint-format-junit');
8
4
  const {
9
5
  getCurrentBranch,
@@ -22,7 +18,11 @@ function doesReportMatchErrorSchema(report, schema) {
22
18
  && report.errors.every(error => schema.includes(error.name));
23
19
  }
24
20
 
25
- async function runCommitLint(commit) {
21
+ async function runCommitLint(commit, { shouldLintEveryCommit }) {
22
+ const { default: load } = await import('@commitlint/load');
23
+ const { default: read } = await import('@commitlint/read');
24
+ const { default: lint } = await import('@commitlint/lint');
25
+
26
26
  let { rules, parserPreset } = await load();
27
27
 
28
28
  let opts = parserPreset ? { parserOpts: parserPreset.parserOpts } : {};
@@ -46,7 +46,7 @@ async function runCommitLint(commit) {
46
46
  if (report.valid) {
47
47
  hasValidReports = true;
48
48
  orderedValidAndErrorReports.push(report);
49
- } else if (!doesReportMatchErrorSchema(report, IGNORED_ERROR_REPORT_SCHEMA)) {
49
+ } else if (shouldLintEveryCommit || !doesReportMatchErrorSchema(report, IGNORED_ERROR_REPORT_SCHEMA)) {
50
50
  hasErrorReports = true;
51
51
  orderedValidAndErrorReports.push(report);
52
52
  errorCount++;
@@ -64,7 +64,7 @@ async function runCommitLint(commit) {
64
64
  process.exitCode = 1;
65
65
  }
66
66
 
67
- return _format({
67
+ return await _format({
68
68
  valid: !didFailLinting,
69
69
  errorCount,
70
70
  warningCount: 0,
@@ -72,7 +72,9 @@ async function runCommitLint(commit) {
72
72
  });
73
73
  }
74
74
 
75
- function _format(payload) {
75
+ async function _format(payload) {
76
+ const { default: format } = await import('@commitlint/format');
77
+
76
78
  let _format;
77
79
  if (process.env.COMMITLINT_REPORTER === 'junit') {
78
80
  _format = formatJunit;
@@ -100,9 +102,7 @@ async function succeedWithLatestCommit() {
100
102
  });
101
103
  }
102
104
 
103
- async function commitlint({
104
- defaultBranch,
105
- }) {
105
+ async function commitlint({ defaultBranch, shouldLintEveryCommit } = {}) {
106
106
  let currentBranch = await getCurrentBranch();
107
107
  if (currentBranch === defaultBranch) {
108
108
  return await succeedWithLatestCommit();
@@ -123,8 +123,7 @@ async function commitlint({
123
123
  return await succeedWithLatestCommit();
124
124
  }
125
125
 
126
- let formatted = await runCommitLint(commitSinceBranchPoint);
127
-
126
+ let formatted = await runCommitLint(commitSinceBranchPoint, { shouldLintEveryCommit });
128
127
  return formatted;
129
128
  }
130
129