@code-pushup/eslint-plugin 0.8.19 → 0.8.21

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 +12 -23
  2. package/index.js +13 -24
  3. package/package.json +3 -43
package/bin.js CHANGED
@@ -16,59 +16,48 @@ var MAX_DESCRIPTION_LENGTH = 65536;
16
16
  var MAX_ISSUE_MESSAGE_LENGTH = 1024;
17
17
 
18
18
  // packages/models/src/lib/implementation/utils.ts
19
- var slugRegex = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
19
+ var slugRegex = /^[a-z\d]+(?:-[a-z\d]+)*$/;
20
20
  var filenameRegex = /^(?!.*[ \\/:*?"<>|]).+$/;
21
21
  function hasDuplicateStrings(strings) {
22
- const uniqueStrings = Array.from(new Set(strings));
23
- const duplicatedStrings = strings.filter(
24
- /* @__PURE__ */ ((i) => (v) => uniqueStrings[i] !== v || !++i)(0)
22
+ const sortedStrings = [...strings].sort();
23
+ const duplStrings = sortedStrings.filter(
24
+ (item, index) => index !== 0 && item === sortedStrings[index - 1]
25
25
  );
26
- return duplicatedStrings.length === 0 ? false : duplicatedStrings;
26
+ return duplStrings.length === 0 ? false : [...new Set(duplStrings)];
27
27
  }
28
28
  function hasMissingStrings(toCheck, existing) {
29
29
  const nonExisting = toCheck.filter((s) => !existing.includes(s));
30
30
  return nonExisting.length === 0 ? false : nonExisting;
31
31
  }
32
- function errorItems(items, transform = (items2) => items2.join(", ")) {
33
- const paredItems = items ? items : [];
34
- return transform(paredItems);
32
+ function errorItems(items, transform = (itemArr) => itemArr.join(", ")) {
33
+ return transform(items || []);
35
34
  }
36
35
  function exists(value) {
37
36
  return value != null;
38
37
  }
39
38
  function getMissingRefsForCategories(categories, plugins) {
40
- const missingRefs = [];
41
39
  const auditRefsFromCategory = categories.flatMap(
42
40
  ({ refs }) => refs.filter(({ type }) => type === "audit").map(({ plugin, slug }) => `${plugin}/${slug}`)
43
41
  );
44
42
  const auditRefsFromPlugins = plugins.flatMap(
45
- ({ audits, slug: pluginSlug }) => {
46
- return audits.map(({ slug }) => `${pluginSlug}/${slug}`);
47
- }
43
+ ({ audits, slug: pluginSlug }) => audits.map(({ slug }) => `${pluginSlug}/${slug}`)
48
44
  );
49
45
  const missingAuditRefs = hasMissingStrings(
50
46
  auditRefsFromCategory,
51
47
  auditRefsFromPlugins
52
48
  );
53
- if (Array.isArray(missingAuditRefs) && missingAuditRefs.length > 0) {
54
- missingRefs.push(...missingAuditRefs);
55
- }
56
49
  const groupRefsFromCategory = categories.flatMap(
57
50
  ({ refs }) => refs.filter(({ type }) => type === "group").map(({ plugin, slug }) => `${plugin}#${slug} (group)`)
58
51
  );
59
52
  const groupRefsFromPlugins = plugins.flatMap(
60
- ({ groups, slug: pluginSlug }) => {
61
- return Array.isArray(groups) ? groups.map(({ slug }) => `${pluginSlug}#${slug} (group)`) : [];
62
- }
53
+ ({ groups, slug: pluginSlug }) => Array.isArray(groups) ? groups.map(({ slug }) => `${pluginSlug}#${slug} (group)`) : []
63
54
  );
64
55
  const missingGroupRefs = hasMissingStrings(
65
56
  groupRefsFromCategory,
66
57
  groupRefsFromPlugins
67
58
  );
68
- if (Array.isArray(missingGroupRefs) && missingGroupRefs.length > 0) {
69
- missingRefs.push(...missingGroupRefs);
70
- }
71
- return missingRefs.length ? missingRefs : false;
59
+ const missingRefs = [missingAuditRefs, missingGroupRefs].filter((refs) => Array.isArray(refs) && refs.length > 0).flat();
60
+ return missingRefs.length > 0 ? missingRefs : false;
72
61
  }
73
62
  function missingRefsForCategoriesErrorMsg(categories, plugins) {
74
63
  const missingRefs = getMissingRefsForCategories(categories, plugins);
@@ -112,7 +101,7 @@ function metaSchema(options) {
112
101
  titleDescription,
113
102
  docsUrlDescription,
114
103
  description
115
- } = options || {};
104
+ } = options ?? {};
116
105
  return z.object(
117
106
  {
118
107
  title: titleSchema(titleDescription),
package/index.js CHANGED
@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";
5
5
 
6
6
  // packages/plugin-eslint/package.json
7
7
  var name = "@code-pushup/eslint-plugin";
8
- var version = "0.8.19";
8
+ var version = "0.8.21";
9
9
 
10
10
  // packages/plugin-eslint/src/lib/config.ts
11
11
  import { z } from "zod";
@@ -38,59 +38,48 @@ var MAX_DESCRIPTION_LENGTH = 65536;
38
38
  var MAX_ISSUE_MESSAGE_LENGTH = 1024;
39
39
 
40
40
  // packages/models/src/lib/implementation/utils.ts
41
- var slugRegex = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
41
+ var slugRegex = /^[a-z\d]+(?:-[a-z\d]+)*$/;
42
42
  var filenameRegex = /^(?!.*[ \\/:*?"<>|]).+$/;
43
43
  function hasDuplicateStrings(strings) {
44
- const uniqueStrings = Array.from(new Set(strings));
45
- const duplicatedStrings = strings.filter(
46
- /* @__PURE__ */ ((i) => (v) => uniqueStrings[i] !== v || !++i)(0)
44
+ const sortedStrings = [...strings].sort();
45
+ const duplStrings = sortedStrings.filter(
46
+ (item, index) => index !== 0 && item === sortedStrings[index - 1]
47
47
  );
48
- return duplicatedStrings.length === 0 ? false : duplicatedStrings;
48
+ return duplStrings.length === 0 ? false : [...new Set(duplStrings)];
49
49
  }
50
50
  function hasMissingStrings(toCheck, existing) {
51
51
  const nonExisting = toCheck.filter((s) => !existing.includes(s));
52
52
  return nonExisting.length === 0 ? false : nonExisting;
53
53
  }
54
- function errorItems(items, transform = (items2) => items2.join(", ")) {
55
- const paredItems = items ? items : [];
56
- return transform(paredItems);
54
+ function errorItems(items, transform = (itemArr) => itemArr.join(", ")) {
55
+ return transform(items || []);
57
56
  }
58
57
  function exists(value) {
59
58
  return value != null;
60
59
  }
61
60
  function getMissingRefsForCategories(categories, plugins) {
62
- const missingRefs = [];
63
61
  const auditRefsFromCategory = categories.flatMap(
64
62
  ({ refs }) => refs.filter(({ type }) => type === "audit").map(({ plugin, slug }) => `${plugin}/${slug}`)
65
63
  );
66
64
  const auditRefsFromPlugins = plugins.flatMap(
67
- ({ audits, slug: pluginSlug }) => {
68
- return audits.map(({ slug }) => `${pluginSlug}/${slug}`);
69
- }
65
+ ({ audits, slug: pluginSlug }) => audits.map(({ slug }) => `${pluginSlug}/${slug}`)
70
66
  );
71
67
  const missingAuditRefs = hasMissingStrings(
72
68
  auditRefsFromCategory,
73
69
  auditRefsFromPlugins
74
70
  );
75
- if (Array.isArray(missingAuditRefs) && missingAuditRefs.length > 0) {
76
- missingRefs.push(...missingAuditRefs);
77
- }
78
71
  const groupRefsFromCategory = categories.flatMap(
79
72
  ({ refs }) => refs.filter(({ type }) => type === "group").map(({ plugin, slug }) => `${plugin}#${slug} (group)`)
80
73
  );
81
74
  const groupRefsFromPlugins = plugins.flatMap(
82
- ({ groups, slug: pluginSlug }) => {
83
- return Array.isArray(groups) ? groups.map(({ slug }) => `${pluginSlug}#${slug} (group)`) : [];
84
- }
75
+ ({ groups, slug: pluginSlug }) => Array.isArray(groups) ? groups.map(({ slug }) => `${pluginSlug}#${slug} (group)`) : []
85
76
  );
86
77
  const missingGroupRefs = hasMissingStrings(
87
78
  groupRefsFromCategory,
88
79
  groupRefsFromPlugins
89
80
  );
90
- if (Array.isArray(missingGroupRefs) && missingGroupRefs.length > 0) {
91
- missingRefs.push(...missingGroupRefs);
92
- }
93
- return missingRefs.length ? missingRefs : false;
81
+ const missingRefs = [missingAuditRefs, missingGroupRefs].filter((refs) => Array.isArray(refs) && refs.length > 0).flat();
82
+ return missingRefs.length > 0 ? missingRefs : false;
94
83
  }
95
84
  function missingRefsForCategoriesErrorMsg(categories, plugins) {
96
85
  const missingRefs = getMissingRefsForCategories(categories, plugins);
@@ -134,7 +123,7 @@ function metaSchema(options) {
134
123
  titleDescription,
135
124
  docsUrlDescription,
136
125
  description
137
- } = options || {};
126
+ } = options ?? {};
138
127
  return z2.object(
139
128
  {
140
129
  title: titleSchema(titleDescription),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/eslint-plugin",
3
- "version": "0.8.19",
3
+ "version": "0.8.21",
4
4
  "dependencies": {
5
5
  "@code-pushup/utils": "*",
6
6
  "@code-pushup/models": "*",
@@ -14,45 +14,5 @@
14
14
  "@nx/devkit": {
15
15
  "optional": true
16
16
  }
17
- },
18
- "license": "MIT",
19
- "homepage": "https://github.com/code-pushup/cli#readme",
20
- "bugs": {
21
- "url": "https://github.com/code-pushup/cli/issues"
22
- },
23
- "repository": {
24
- "type": "git",
25
- "url": "https://github.com/code-pushup/cli.git",
26
- "directory": "packages/plugin-eslint"
27
- },
28
- "contributors": [
29
- {
30
- "name": "Igor Katsuba",
31
- "email": "igor@katsuba.dev",
32
- "url": "https://katsuba.dev"
33
- },
34
- {
35
- "name": "Kateřina Pilátová",
36
- "email": "katerina.pilatova@flowup.cz",
37
- "url": "https://github.com/Tlacenka"
38
- },
39
- {
40
- "name": "Matěj Chalk",
41
- "email": "matej.chalk@flowup.cz",
42
- "url": "https://github.com/matejchalk"
43
- },
44
- {
45
- "name": "Michael Hladky",
46
- "email": "michael.hladky@push-based.io",
47
- "url": "https://push-based.io"
48
- },
49
- {
50
- "name": "Michael Seredenko",
51
- "email": "misha.seredenko@push-based.io",
52
- "url": "https://github.com/MishaSeredenkoPushBased"
53
- }
54
- ],
55
- "type": "module",
56
- "main": "./index.js",
57
- "types": "./src/index.d.ts"
58
- }
17
+ }
18
+ }