@techninja/clearstack 0.4.12 → 0.4.13

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 (2) hide show
  1. package/lib/spec-scan.js +12 -5
  2. package/package.json +1 -1
package/lib/spec-scan.js CHANGED
@@ -37,20 +37,25 @@ export function countFiles(root, extensions, ignoreDirs) {
37
37
  return findFiles(root, extensions, ignoreDirs, root).length;
38
38
  }
39
39
 
40
+ /** @param {string} f @param {string | string[]} pat */
41
+ function matchesPat(f, pat) {
42
+ return Array.isArray(pat) ? pat.some((p) => f.includes(p) || f.endsWith(p)) : f.endsWith(pat);
43
+ }
44
+
40
45
  /**
41
46
  * @param {string} root
42
47
  * @param {string[]} extensions
43
48
  * @param {number} max
44
49
  * @param {string[]} ignoreDirs
45
50
  * @param {string} label
46
- * @param {{ exclude?: string, include?: string, localeMax?: number, quiet?: boolean }} [filter]
51
+ * @param {{ exclude?: string | string[], include?: string | string[], localeMax?: number, quiet?: boolean }} [filter]
47
52
  * @returns {CheckResult & { violations?: LineViolation[] }}
48
53
  */
49
54
  export function checkFileLines(root, extensions, max, ignoreDirs, label, filter) {
50
55
  const start = performance.now();
51
56
  let files = findFiles(root, extensions, ignoreDirs, root);
52
- if (filter?.exclude) files = files.filter((f) => !f.endsWith(filter.exclude));
53
- if (filter?.include) files = files.filter((f) => f.endsWith(filter.include));
57
+ if (filter?.exclude) files = files.filter((f) => !matchesPat(f, filter.exclude));
58
+ if (filter?.include) files = files.filter((f) => matchesPat(f, filter.include));
54
59
  const localeMax = filter?.localeMax || max * 5;
55
60
  const violations = [];
56
61
  for (const file of files) {
@@ -74,13 +79,15 @@ export function checkFileLines(root, extensions, max, ignoreDirs, label, filter)
74
79
  * @param {string} root
75
80
  * @param {string[]} ignoreDirs
76
81
  * @param {string} label
77
- * @param {{ quiet?: boolean }} [opts]
82
+ * @param {{ quiet?: boolean, ignore?: string[] }} [opts]
78
83
  * @returns {CheckResult & { violations?: ImportViolation[] }}
79
84
  */
80
85
  export function checkImports(root, ignoreDirs, label, opts) {
81
86
  const start = performance.now();
87
+ const extraIgnore = opts?.ignore ?? [];
82
88
  const files = findFiles(root, ['.js'], ignoreDirs, root)
83
- .filter((f) => f.startsWith('src/') && !f.includes('vendor/') && !f.includes('api/') && !f.endsWith('.test.js') && !f.endsWith('server.js'));
89
+ .filter((f) => f.startsWith('src/') && !f.includes('vendor/') && !f.includes('api/') && !f.endsWith('.test.js') && !f.endsWith('server.js'))
90
+ .filter((f) => !extraIgnore.some((p) => f.includes(p)));
84
91
  const violations = [];
85
92
  const importRe = /(?:^|\n)\s*import\s.*?from\s+['"](\.\.[^'"]*)['"]/g;
86
93
  for (const file of files) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@techninja/clearstack",
3
- "version": "0.4.12",
3
+ "version": "0.4.13",
4
4
  "type": "module",
5
5
  "description": "A no-build web component framework specification — scaffold, validate, and evolve spec-compliant projects",
6
6
  "bin": {