@html-validate/commitlint-config 4.3.2 → 4.4.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/dist/config.js CHANGED
@@ -32,6 +32,7 @@ var lib_default = {
32
32
  "body-max-line-length": [RuleConfigSeverity.Error, "always", 100],
33
33
  "footer-leading-blank": [RuleConfigSeverity.Warning, "always"],
34
34
  "footer-max-line-length": [RuleConfigSeverity.Error, "always", 100],
35
+ "header-breaking-change": [RuleConfigSeverity.Error, "never"],
35
36
  "header-max-length": [RuleConfigSeverity.Error, "always", 100],
36
37
  "header-trim": [RuleConfigSeverity.Error, "always"],
37
38
  "subject-case": [
@@ -154,14 +155,90 @@ var lib_default = {
154
155
  }
155
156
  };
156
157
 
158
+ // src/rules/header-backtick-balanced.ts
159
+ var headerBacktickBalanced = (parsed, when = "always") => {
160
+ const header = parsed.header ?? "";
161
+ const count = header.split("`").length - 1;
162
+ const balanced = count % 2 === 0;
163
+ const negated = when === "never";
164
+ return [
165
+ negated ? !balanced : balanced,
166
+ negated ? "header must contain unmatched backticks" : "header must not contain unmatched backticks"
167
+ ];
168
+ };
169
+
170
+ // src/rules/code-spans.ts
171
+ function findCodeSpans(text) {
172
+ const spans = [];
173
+ for (const match of text.matchAll(/`([^`]+)`/g)) {
174
+ const [full, content] = match;
175
+ spans.push({ content, start: match.index, end: match.index + full.length });
176
+ }
177
+ return spans;
178
+ }
179
+
180
+ // src/rules/header-backtick-boundary.ts
181
+ var wordCharacter = /[\p{L}\p{N}_]/u;
182
+ function isWordCharacter(ch) {
183
+ return ch !== void 0 && wordCharacter.test(ch);
184
+ }
185
+ function codePointBefore(text, index) {
186
+ return /.$/su.exec(text.slice(0, index))?.[0];
187
+ }
188
+ function codePointAt(text, index) {
189
+ const codePoint = text.codePointAt(index);
190
+ return codePoint !== void 0 ? String.fromCodePoint(codePoint) : void 0;
191
+ }
192
+ var headerBacktickBoundary = (parsed, when = "always") => {
193
+ const header = parsed.header ?? "";
194
+ const spans = findCodeSpans(header);
195
+ const separated = spans.every(({ start, end }) => {
196
+ const before = codePointBefore(header, start);
197
+ const after = codePointAt(header, end);
198
+ return !isWordCharacter(before) && !isWordCharacter(after);
199
+ });
200
+ const negated = when === "never";
201
+ return [
202
+ negated ? !separated : separated,
203
+ negated ? "code spans in header must not be separated from surrounding words" : "code spans in header must be separated from surrounding words"
204
+ ];
205
+ };
206
+
207
+ // src/rules/header-backtick-trim.ts
208
+ var headerBacktickTrim = (parsed, when = "always") => {
209
+ const header = parsed.header ?? "";
210
+ const spans = findCodeSpans(header);
211
+ const trimmed = spans.every(({ content }) => !/^\s|\s$/.test(content));
212
+ const negated = when === "never";
213
+ return [
214
+ negated ? !trimmed : trimmed,
215
+ negated ? "code spans in header must start or end with whitespace" : "code spans in header must not start or end with whitespace"
216
+ ];
217
+ };
218
+
219
+ // src/rules/index.ts
220
+ var rules = {
221
+ "header-backtick-balanced": headerBacktickBalanced,
222
+ "header-backtick-boundary": headerBacktickBoundary,
223
+ "header-backtick-trim": headerBacktickTrim
224
+ };
225
+
157
226
  // src/config.ts
158
227
  var config = {
159
228
  ...lib_default,
160
229
  parserPreset: fileURLToPath(new URL("parser-preset.js", import.meta.url)),
161
230
  formatter: fileURLToPath(new URL("formatter.js", import.meta.url)),
231
+ plugins: [{ rules }],
162
232
  rules: {
163
233
  ...lib_default.rules,
164
- "header-max-length": [2, "always", 120]
234
+ /* eslint-disable-next-line @typescript-eslint/no-unsafe-enum-assignment -- technical debt */
235
+ "header-max-length": [2, "always", 120],
236
+ /* eslint-disable-next-line @typescript-eslint/no-unsafe-enum-assignment -- technical debt */
237
+ "header-backtick-balanced": [2, "always"],
238
+ /* eslint-disable-next-line @typescript-eslint/no-unsafe-enum-assignment -- technical debt */
239
+ "header-backtick-trim": [2, "always"],
240
+ /* eslint-disable-next-line @typescript-eslint/no-unsafe-enum-assignment -- technical debt */
241
+ "header-backtick-boundary": [2, "always"]
165
242
  }
166
243
  };
167
244
  if (process.argv[1] === import.meta.filename) {
package/dist/install.js CHANGED
@@ -119,6 +119,11 @@ var require_vendors = __commonJS({
119
119
  ne: "false"
120
120
  }
121
121
  },
122
+ {
123
+ name: "Capawesome Cloud",
124
+ constant: "CAPAWESOME_CLOUD",
125
+ env: "CAPAWESOME_CLOUD"
126
+ },
122
127
  {
123
128
  name: "CircleCI",
124
129
  constant: "CIRCLE",
@@ -301,6 +306,11 @@ var require_vendors = __commonJS({
301
306
  IS_PULL_REQUEST: "true"
302
307
  }
303
308
  },
309
+ {
310
+ name: "RWX",
311
+ constant: "RWX",
312
+ env: "RWX"
313
+ },
304
314
  {
305
315
  name: "Sail CI",
306
316
  constant: "SAIL",
@@ -437,10 +447,10 @@ var require_ci_info = __commonJS({
437
447
  exports.isCI = !!(env.CI !== "false" && // Bypass all checks if CI env is explicitly set to 'false'
438
448
  (env.BUILD_ID || // Jenkins, Cloudbees
439
449
  env.BUILD_NUMBER || // Jenkins, TeamCity
440
- env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari, Cloudflare Pages/Workers
441
- env.CI_APP_ID || // Appflow
442
- env.CI_BUILD_ID || // Appflow
443
- env.CI_BUILD_NUMBER || // Appflow
450
+ env.CI || // Appveyor, Capawesome Cloud, CircleCI, Cirrus CI, Cloudflare Pages/Workers, CodeShip, dsari, Gitlab CI, RWX, Travis CI
451
+ env.CI_APP_ID || // Appflow, Capawesome Cloud
452
+ env.CI_BUILD_ID || // Appflow, Capawesome Cloud
453
+ env.CI_BUILD_NUMBER || // Appflow, Capawesome Cloud
444
454
  env.CI_NAME || // Codeship and others
445
455
  env.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI
446
456
  env.RUN_ID || // TaskCluster, dsari
@@ -12,23 +12,6 @@ var __export = (target, all) => {
12
12
  __defProp(target, name, { get: all[name], enumerable: true });
13
13
  };
14
14
 
15
- // node_modules/conventional-changelog-conventionalcommits/src/parser.js
16
- function createParserOpts(config) {
17
- return {
18
- headerPattern: /^(\w*)(?:\((.*)\))?!?: (.*)$/,
19
- breakingHeaderPattern: /^(\w*)(?:\((.*)\))?!: (.*)$/,
20
- headerCorrespondence: [
21
- "type",
22
- "scope",
23
- "subject"
24
- ],
25
- noteKeywords: ["BREAKING CHANGE", "BREAKING-CHANGE"],
26
- revertPattern: /^(?:Revert|revert:)\s"?([\s\S]+?)"?\s*This reverts commit (\w*)\./i,
27
- revertCorrespondence: ["header", "hash"],
28
- issuePrefixes: config?.issuePrefixes || ["#"]
29
- };
30
- }
31
-
32
15
  // node_modules/@conventional-changelog/template/dist/elements.js
33
16
  function toString(value) {
34
17
  return typeof value === "number" || value ? String(value) : "";
@@ -77,6 +60,72 @@ function url(...parts) {
77
60
  }, "");
78
61
  }
79
62
 
63
+ // node_modules/@conventional-changelog/template/dist/references.js
64
+ var protectedSegments = [
65
+ /\[(?:[^[\]]|\[[^[\]]*])*]\((?:[^()\n]|\([^()\n]*\))*\)/,
66
+ // [text](url)
67
+ // a text and a label end before the next not nested `[`,
68
+ // so a long run of brackets is not scanned to its end from every one of them
69
+ /\[(?:[^[\]]|\[[^[\]]*])*]\[[^[\]]*]/,
70
+ // [text][ref]
71
+ // the lookahead makes the delimiter length atomic, without it a long run
72
+ // of backticks makes the regex engine retry every possible delimiter length;
73
+ // as in CommonMark, the info string of backticks has no backticks, and a block
74
+ // without a closing fence lasts to the end, so the next fences don't scan it again
75
+ /^[ \t]*(?=(?<fence>`{3,}|~{3,}))\k<fence>(?:(?<=`)[^`\n]*|(?<=~)[^\n]*)$[\s\S]*?(?:^[ \t]*\k<fence>[ \t]*\r?$|(?![\s\S]))/,
76
+ // ```code block```
77
+ // as in CommonMark, whole runs of backticks of the same length open and close a span;
78
+ // only runs of up to 16 backticks open one, so at most 16 runs without a closing one
79
+ // scan the rest of a line
80
+ /(?<!`)(?=(?<code>`{1,16}(?!`)))\k<code>[^\n]*?(?<!`)\k<code>(?!`)/,
81
+ // `code span`
82
+ /https?:\/\/(?:[^\s()]|\([^\s()]*\))+/
83
+ // https://url
84
+ ];
85
+ var userMention = /\B@(?<user>[a-z0-9](?:-?[a-z0-9/]){0,38})/;
86
+ var defaultIssuePattern = /[a-z0-9]+/;
87
+ function escapeRegExp(string) {
88
+ return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
89
+ }
90
+ function referencesRegex(issuePrefixes = [], issuePattern = defaultIssuePattern) {
91
+ const prefixes = issuePrefixes.map((prefix) => typeof prefix === "string" ? escapeRegExp(prefix) : prefix.source).join("|");
92
+ const patterns = [
93
+ ...protectedSegments.map((segment) => segment.source),
94
+ // without prefixes every word would be matched as an issue reference
95
+ prefixes && `(?<prefix>${prefixes})(?<issue>${issuePattern.source})`,
96
+ userMention.source
97
+ ];
98
+ return new RegExp(patterns.filter(Boolean).join("|"), "gm");
99
+ }
100
+ function createReferencesFormatter(options) {
101
+ const regex = referencesRegex(options.issuePrefixes, options.issuePattern);
102
+ return (text, context, references) => text.replace(regex, (match, ...args) => {
103
+ const { prefix, issue, user } = args.at(-1);
104
+ if (issue) {
105
+ const issueUrl = options.formatIssueUrl(context, {
106
+ prefix,
107
+ issue
108
+ });
109
+ if (!issueUrl) {
110
+ return match;
111
+ }
112
+ references?.push(match);
113
+ return link(match, issueUrl);
114
+ }
115
+ if (user) {
116
+ if (user.includes("/")) {
117
+ return match;
118
+ }
119
+ const userUrl = options.formatUserUrl(context, user);
120
+ if (!userUrl) {
121
+ return match;
122
+ }
123
+ return link(match, userUrl);
124
+ }
125
+ return match;
126
+ });
127
+ }
128
+
80
129
  // node_modules/@conventional-changelog/template/dist/templates.js
81
130
  function repositoryUrl(context) {
82
131
  if (context.repository) {
@@ -96,13 +145,30 @@ function referenceRepositoryUrl(context, reference2) {
96
145
  function compareUrl(context) {
97
146
  const previousTag = encodeURIComponent(context.previousTag || "");
98
147
  const currentTag = encodeURIComponent(context.currentTag || "");
99
- return url(repositoryUrl(context), "compare", `${previousTag}...${currentTag}`);
148
+ return url(repositoryUrl(context), context.compare || "compare", `${previousTag}...${currentTag}`);
149
+ }
150
+ var BREAKING_CHANGE_KEYWORDS = ["BREAKING CHANGE", "BREAKING-CHANGE"];
151
+ var BREAKING_CHANGES_TITLE = "BREAKING CHANGES";
152
+ function noteTitle(title) {
153
+ const upperCaseTitle = title.toUpperCase();
154
+ return BREAKING_CHANGE_KEYWORDS.includes(upperCaseTitle) ? BREAKING_CHANGES_TITLE : upperCaseTitle;
155
+ }
156
+ function isBreakingNote(note) {
157
+ return noteTitle(note.title) === BREAKING_CHANGES_TITLE;
100
158
  }
101
159
  function reference(reference2) {
102
160
  return strings(reference2.owner && `${reference2.owner}/`, reference2.repository, reference2.issue && `${reference2.prefix || "#"}${reference2.issue}`);
103
161
  }
104
162
 
163
+ // node_modules/@conventional-changelog/template/dist/legacy.js
164
+ function createLegacyWriterGuard(preset) {
165
+ return {
166
+ mainTemplate: `{{[${preset} requires conventional-changelog-writer@9 or newer (conventional-changelog@8 or newer). Your changelog tooling loaded an older writer which cannot render this preset. Update the tooling or use an older major version of the preset.] true}}`
167
+ };
168
+ }
169
+
105
170
  // node_modules/conventional-changelog-conventionalcommits/src/constants.js
171
+ var BREAKING_HEADER_PATTERN = /^(\w*)(?:\((.*)\))?!: (.*)$/;
106
172
  var DEFAULT_COMMIT_TYPES = Object.freeze([
107
173
  {
108
174
  type: "feat",
@@ -166,7 +232,36 @@ var DEFAULT_COMMIT_TYPES = Object.freeze([
166
232
  }
167
233
  ].map(Object.freeze));
168
234
 
235
+ // node_modules/conventional-changelog-conventionalcommits/src/parser.js
236
+ function createParserOpts(config) {
237
+ return {
238
+ headerPattern: /^(\w*)(?:\((.*)\))?!?: (.*)$/,
239
+ breakingHeaderPattern: BREAKING_HEADER_PATTERN,
240
+ headerCorrespondence: [
241
+ "type",
242
+ "scope",
243
+ "subject"
244
+ ],
245
+ noteKeywords: BREAKING_CHANGE_KEYWORDS,
246
+ revertPattern: /^(?:Revert|revert:)\s"?([\s\S]+?)"?\s*This reverts commit (\w*)\./i,
247
+ revertCorrespondence: ["header", "hash"],
248
+ issuePrefixes: config?.issuePrefixes || ["#"]
249
+ };
250
+ }
251
+
169
252
  // node_modules/conventional-changelog-conventionalcommits/src/utils.js
253
+ function getNotes(commit) {
254
+ if (commit.notes.some(isBreakingNote) || !BREAKING_HEADER_PATTERN.test(commit.header || "")) {
255
+ return commit.notes;
256
+ }
257
+ return [
258
+ {
259
+ title: BREAKING_CHANGE_KEYWORDS[0],
260
+ text: commit.subject || ""
261
+ },
262
+ ...commit.notes
263
+ ];
264
+ }
170
265
  function hasIntersection(a, b) {
171
266
  if (!a || !b) {
172
267
  return false;
@@ -295,7 +390,7 @@ function template(context) {
295
390
  each(
296
391
  noteGroups,
297
392
  (group) => segments(
298
- heading(3, words("\u26A0", group.title)),
393
+ heading(3, words(this.formatNoteIcon(context, group.title), group.title)),
299
394
  list(
300
395
  group.notes,
301
396
  (note) => words(
@@ -327,12 +422,20 @@ __export(format_exports, {
327
422
  formatCommitUrl: () => formatCommitUrl,
328
423
  formatCompareUrl: () => formatCompareUrl,
329
424
  formatIssueUrl: () => formatIssueUrl,
425
+ formatNoteIcon: () => formatNoteIcon,
426
+ formatNoteTitle: () => formatNoteTitle,
330
427
  formatUserUrl: () => formatUserUrl
331
428
  });
429
+ function formatNoteTitle(context, title) {
430
+ return noteTitle(title);
431
+ }
432
+ function formatNoteIcon(context, title) {
433
+ return title === BREAKING_CHANGES_TITLE ? "\u26A0" : "";
434
+ }
332
435
  function formatIssueUrl(context, reference2) {
333
436
  return url(
334
437
  referenceRepositoryUrl(context, reference2),
335
- "issues",
438
+ context.issue || "issues",
336
439
  reference2.issue
337
440
  );
338
441
  }
@@ -360,8 +463,10 @@ function createWriterOpts(config) {
360
463
  ...config
361
464
  };
362
465
  const commitGroupOrder = finalConfig.types.map((t) => t.section).filter(Boolean);
466
+ const formatReferences = createReferencesFormatter(finalConfig);
363
467
  return {
364
- template,
468
+ ...createLegacyWriterGuard("conventional-changelog-conventionalcommits"),
469
+ template: template.bind(finalConfig),
365
470
  headerPartial: headerPartial.bind(finalConfig),
366
471
  preamblePartial: preamblePartial.bind(finalConfig),
367
472
  commitPartial: commitPartial.bind(finalConfig),
@@ -373,15 +478,16 @@ function createWriterOpts(config) {
373
478
  if (commit.footer && releaseAsRegex.test(commit.footer) || commit.body && releaseAsRegex.test(commit.body)) {
374
479
  discard = false;
375
480
  }
376
- const notes = commit.notes.map((note) => {
481
+ const notes = getNotes(commit).map((note) => {
377
482
  discard = false;
378
483
  return {
379
484
  ...note,
380
- title: "BREAKING CHANGES"
485
+ title: finalConfig.formatNoteTitle(context, note.title),
486
+ text: formatReferences(note.text, context)
381
487
  };
382
488
  });
383
489
  if (
384
- // breaking changes attached to any type are still displayed.
490
+ // notes attached to any type are still displayed.
385
491
  discard && (entry === void 0 || isTypeEffect(entry, "hidden")) || !matchScope(finalConfig, commit)
386
492
  ) {
387
493
  return void 0;
@@ -391,26 +497,7 @@ function createWriterOpts(config) {
391
497
  const shortHash = typeof commit.hash === "string" ? commit.hash.substring(0, COMMIT_HASH_LENGTH) : commit.shortHash;
392
498
  let { subject } = commit;
393
499
  if (typeof subject === "string") {
394
- const issueRegEx = `(${finalConfig.issuePrefixes.join("|")})([a-z0-9]+)`;
395
- const re = new RegExp(issueRegEx, "g");
396
- subject = subject.replace(re, (_, prefix, issue) => {
397
- issues.push(prefix + issue);
398
- const issueUrl = finalConfig.formatIssueUrl(context, {
399
- issue,
400
- prefix
401
- });
402
- return link(`${prefix}${issue}`, issueUrl);
403
- });
404
- subject = subject.replace(/`[^`]*`|\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (match, user) => {
405
- if (!user) {
406
- return match;
407
- }
408
- if (user.includes("/")) {
409
- return `@${user}`;
410
- }
411
- const usernameUrl = finalConfig.formatUserUrl(context, user);
412
- return link(`@${user}`, usernameUrl);
413
- });
500
+ subject = formatReferences(subject, context, issues);
414
501
  }
415
502
  const references = commit.references.filter((reference2) => !issues.includes(reference2.prefix + reference2.issue));
416
503
  return {
@@ -448,8 +535,9 @@ function createWhatBump(config = {}) {
448
535
  return;
449
536
  }
450
537
  const entry = findTypeEntry(types, commit);
451
- if (commit.notes.length > 0) {
452
- breakings += commit.notes.length;
538
+ const breakingNotes = getNotes(commit).filter(isBreakingNote);
539
+ if (breakingNotes.length > 0) {
540
+ breakings += breakingNotes.length;
453
541
  level = 0;
454
542
  } else if (entry && isTypeEffect(entry, "bump")) {
455
543
  if (level === null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@html-validate/commitlint-config",
3
- "version": "4.3.2",
3
+ "version": "4.4.0",
4
4
  "description": "Commitlint sharable config used by the various HTML-validate packages",
5
5
  "keywords": [
6
6
  "commitlint"