@code-pushup/eslint-plugin 0.2.0 → 0.3.1

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/bin.js +9 -4
  2. package/index.js +25 -7
  3. package/package.json +1 -1
package/bin.js CHANGED
@@ -9,6 +9,11 @@ import { z as z2 } from "zod";
9
9
  import { z } from "zod";
10
10
  import { MATERIAL_ICONS } from "@code-pushup/portal-client";
11
11
 
12
+ // packages/models/src/lib/implementation/limits.ts
13
+ var MAX_SLUG_LENGTH = 128;
14
+ var MAX_TITLE_LENGTH = 256;
15
+ var MAX_DESCRIPTION_LENGTH = 65536;
16
+
12
17
  // packages/models/src/lib/implementation/utils.ts
13
18
  var slugRegex = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
14
19
  var filenameRegex = /^(?!.*[ \\/:*?"<>|]).+$/;
@@ -44,12 +49,12 @@ function executionMetaSchema(options = {
44
49
  function slugSchema(description = "Unique ID (human-readable, URL-safe)") {
45
50
  return z.string({ description }).regex(slugRegex, {
46
51
  message: "The slug has to follow the pattern [0-9a-z] followed by multiple optional groups of -[0-9a-z]. e.g. my-slug"
47
- }).max(128, {
48
- message: "slug can be max 128 characters long"
52
+ }).max(MAX_SLUG_LENGTH, {
53
+ message: `slug can be max ${MAX_SLUG_LENGTH} characters long`
49
54
  });
50
55
  }
51
56
  function descriptionSchema(description = "Description (markdown)") {
52
- return z.string({ description }).max(65536).optional();
57
+ return z.string({ description }).max(MAX_DESCRIPTION_LENGTH).optional();
53
58
  }
54
59
  function docsUrlSchema(description = "Documentation site") {
55
60
  return urlSchema(description).optional().or(z.string().max(0));
@@ -58,7 +63,7 @@ function urlSchema(description) {
58
63
  return z.string({ description }).url();
59
64
  }
60
65
  function titleSchema(description = "Descriptive name") {
61
- return z.string({ description }).max(256);
66
+ return z.string({ description }).max(MAX_TITLE_LENGTH);
62
67
  }
63
68
  function metaSchema(options) {
64
69
  const {
package/index.js CHANGED
@@ -5,7 +5,7 @@ import { fileURLToPath } from "url";
5
5
 
6
6
  // packages/plugin-eslint/package.json
7
7
  var name = "@code-pushup/eslint-plugin";
8
- var version = "0.2.0";
8
+ var version = "0.3.1";
9
9
 
10
10
  // packages/plugin-eslint/src/lib/config.ts
11
11
  import { z } from "zod";
@@ -31,6 +31,11 @@ import { z as z3 } from "zod";
31
31
  import { z as z2 } from "zod";
32
32
  import { MATERIAL_ICONS } from "@code-pushup/portal-client";
33
33
 
34
+ // packages/models/src/lib/implementation/limits.ts
35
+ var MAX_SLUG_LENGTH = 128;
36
+ var MAX_TITLE_LENGTH = 256;
37
+ var MAX_DESCRIPTION_LENGTH = 65536;
38
+
34
39
  // packages/models/src/lib/implementation/utils.ts
35
40
  var slugRegex = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
36
41
  var filenameRegex = /^(?!.*[ \\/:*?"<>|]).+$/;
@@ -66,12 +71,12 @@ function executionMetaSchema(options = {
66
71
  function slugSchema(description = "Unique ID (human-readable, URL-safe)") {
67
72
  return z2.string({ description }).regex(slugRegex, {
68
73
  message: "The slug has to follow the pattern [0-9a-z] followed by multiple optional groups of -[0-9a-z]. e.g. my-slug"
69
- }).max(128, {
70
- message: "slug can be max 128 characters long"
74
+ }).max(MAX_SLUG_LENGTH, {
75
+ message: `slug can be max ${MAX_SLUG_LENGTH} characters long`
71
76
  });
72
77
  }
73
78
  function descriptionSchema(description = "Description (markdown)") {
74
- return z2.string({ description }).max(65536).optional();
79
+ return z2.string({ description }).max(MAX_DESCRIPTION_LENGTH).optional();
75
80
  }
76
81
  function docsUrlSchema(description = "Documentation site") {
77
82
  return urlSchema(description).optional().or(z2.string().max(0));
@@ -80,7 +85,7 @@ function urlSchema(description) {
80
85
  return z2.string({ description }).url();
81
86
  }
82
87
  function titleSchema(description = "Descriptive name") {
83
- return z2.string({ description }).max(256);
88
+ return z2.string({ description }).max(MAX_TITLE_LENGTH);
84
89
  }
85
90
  function metaSchema(options) {
86
91
  const {
@@ -558,6 +563,19 @@ import { join } from "path";
558
563
  function slugify(text) {
559
564
  return text.trim().toLowerCase().replace(/\s+|\//g, "-").replace(/[^a-z0-9-]/g, "");
560
565
  }
566
+ function truncateText(text, maxChars) {
567
+ if (text.length <= maxChars) {
568
+ return text;
569
+ }
570
+ const ellipsis = "...";
571
+ return text.slice(0, maxChars - ellipsis.length) + ellipsis;
572
+ }
573
+ function truncateTitle(text) {
574
+ return truncateText(text, MAX_TITLE_LENGTH);
575
+ }
576
+ function truncateDescription(text) {
577
+ return truncateText(text, MAX_DESCRIPTION_LENGTH);
578
+ }
561
579
 
562
580
  // packages/utils/src/lib/file-system.ts
563
581
  async function fileExists(path) {
@@ -790,8 +808,8 @@ function ruleToAudit({ ruleId, meta, options }) {
790
808
  ];
791
809
  return {
792
810
  slug: ruleIdToSlug(ruleId, options),
793
- title: meta.docs?.description ?? name2,
794
- description: lines.join("\n\n"),
811
+ title: truncateTitle(meta.docs?.description ?? name2),
812
+ description: truncateDescription(lines.join("\n\n")),
795
813
  ...meta.docs?.url && {
796
814
  docsUrl: meta.docs.url
797
815
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/eslint-plugin",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "dependencies": {
5
5
  "@code-pushup/utils": "*",
6
6
  "@code-pushup/models": "*",