@empline/preflight 1.1.36 → 1.1.38
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/checks/code-quality/unused-lib-detection.d.ts +18 -3
- package/dist/checks/code-quality/unused-lib-detection.d.ts.map +1 -1
- package/dist/checks/code-quality/unused-lib-detection.js +333 -109
- package/dist/checks/code-quality/unused-lib-detection.js.map +1 -1
- package/dist/checks/ui/section-header-spacing.d.ts +24 -0
- package/dist/checks/ui/section-header-spacing.d.ts.map +1 -0
- package/dist/checks/ui/section-header-spacing.js +231 -0
- package/dist/checks/ui/section-header-spacing.js.map +1 -0
- package/package.json +1 -1
|
@@ -8,13 +8,28 @@
|
|
|
8
8
|
* - Increases maintenance burden
|
|
9
9
|
* - Creates confusion about which implementation to use
|
|
10
10
|
*
|
|
11
|
-
* NON-BLOCKING
|
|
11
|
+
* IMPORTANT: This check is NON-BLOCKING and ADVISORY ONLY.
|
|
12
|
+
* DO NOT auto-delete files based on this report - many files have
|
|
13
|
+
* legitimate uses that are hard to detect statically:
|
|
14
|
+
* - Dynamic imports
|
|
15
|
+
* - Conditional imports based on environment
|
|
16
|
+
* - Files used by external tools/scripts
|
|
17
|
+
* - Files imported by tests
|
|
18
|
+
* - Worker files
|
|
19
|
+
* - Entry points for scheduled jobs
|
|
20
|
+
*
|
|
21
|
+
* Always manually verify before removing any files!
|
|
12
22
|
*/
|
|
13
23
|
export declare const id = "code-quality/unused-lib-detection";
|
|
14
24
|
export declare const name = "Unused Library File Detection";
|
|
15
|
-
export declare const description = "Detects lib/ files that
|
|
25
|
+
export declare const description = "Detects lib/ files that may not be imported - ADVISORY ONLY, verify manually before cleanup";
|
|
16
26
|
export declare const category = "code-quality";
|
|
17
27
|
export declare const blocking = false;
|
|
18
28
|
export declare const tags: string[];
|
|
19
|
-
export declare
|
|
29
|
+
export declare const requires: string[];
|
|
30
|
+
export declare function run(): Promise<{
|
|
31
|
+
success: boolean;
|
|
32
|
+
errors: number;
|
|
33
|
+
warnings: number;
|
|
34
|
+
}>;
|
|
20
35
|
//# sourceMappingURL=unused-lib-detection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unused-lib-detection.d.ts","sourceRoot":"","sources":["../../../src/checks/code-quality/unused-lib-detection.ts"],"names":[],"mappings":";AAEA
|
|
1
|
+
{"version":3,"file":"unused-lib-detection.d.ts","sourceRoot":"","sources":["../../../src/checks/code-quality/unused-lib-detection.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AAOH,eAAO,MAAM,EAAE,sCAAsC,CAAC;AACtD,eAAO,MAAM,IAAI,kCAAkC,CAAC;AACpD,eAAO,MAAM,WAAW,gGACuE,CAAC;AAChG,eAAO,MAAM,QAAQ,iBAAiB,CAAC;AACvC,eAAO,MAAM,QAAQ,QAAQ,CAAC;AAC9B,eAAO,MAAM,IAAI,UAAoE,CAAC;AACtF,eAAO,MAAM,QAAQ,UAA0B,CAAC;AAwahD,wBAAsB,GAAG,IAAI,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAuG3F"}
|
|
@@ -9,57 +9,171 @@
|
|
|
9
9
|
* - Increases maintenance burden
|
|
10
10
|
* - Creates confusion about which implementation to use
|
|
11
11
|
*
|
|
12
|
-
* NON-BLOCKING
|
|
12
|
+
* IMPORTANT: This check is NON-BLOCKING and ADVISORY ONLY.
|
|
13
|
+
* DO NOT auto-delete files based on this report - many files have
|
|
14
|
+
* legitimate uses that are hard to detect statically:
|
|
15
|
+
* - Dynamic imports
|
|
16
|
+
* - Conditional imports based on environment
|
|
17
|
+
* - Files used by external tools/scripts
|
|
18
|
+
* - Files imported by tests
|
|
19
|
+
* - Worker files
|
|
20
|
+
* - Entry points for scheduled jobs
|
|
21
|
+
*
|
|
22
|
+
* Always manually verify before removing any files!
|
|
13
23
|
*/
|
|
14
24
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
26
|
};
|
|
17
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.tags = exports.blocking = exports.category = exports.description = exports.name = exports.id = void 0;
|
|
28
|
+
exports.requires = exports.tags = exports.blocking = exports.category = exports.description = exports.name = exports.id = void 0;
|
|
19
29
|
exports.run = run;
|
|
20
30
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
21
31
|
const node_path_1 = __importDefault(require("node:path"));
|
|
22
32
|
const console_chars_1 = require("../../utils/console-chars");
|
|
23
|
-
const universal_progress_reporter_1 = require("../system/universal-progress-reporter");
|
|
24
33
|
// METADATA - Required for plugin loader discovery
|
|
25
34
|
exports.id = "code-quality/unused-lib-detection";
|
|
26
35
|
exports.name = "Unused Library File Detection";
|
|
27
|
-
exports.description = "Detects lib/ files that
|
|
36
|
+
exports.description = "Detects lib/ files that may not be imported - ADVISORY ONLY, verify manually before cleanup";
|
|
28
37
|
exports.category = "code-quality";
|
|
29
38
|
exports.blocking = false;
|
|
30
|
-
exports.tags = ["dead-code", "cleanup", "ai-clarity", "maintenance"];
|
|
31
|
-
|
|
32
|
-
//
|
|
33
|
-
|
|
39
|
+
exports.tags = ["dead-code", "cleanup", "ai-clarity", "maintenance", "advisory"];
|
|
40
|
+
exports.requires = ["trading-card-system"];
|
|
41
|
+
// =============================================================================
|
|
42
|
+
// EXCLUSIONS - Files that should NEVER be flagged as unused
|
|
43
|
+
// =============================================================================
|
|
44
|
+
/**
|
|
45
|
+
* Explicit file exclusions - these are known to be used in ways
|
|
46
|
+
* that static analysis can't easily detect
|
|
47
|
+
*/
|
|
48
|
+
const EXCLUDED_FILES = new Set([
|
|
34
49
|
// Entry points and exports
|
|
35
50
|
"lib/index.ts",
|
|
36
51
|
"lib/types.ts",
|
|
37
|
-
//
|
|
38
|
-
"lib/recognition/index.ts",
|
|
39
|
-
"lib/images/index.ts",
|
|
40
|
-
"lib/constants/index.ts",
|
|
41
|
-
// Environment/config
|
|
52
|
+
// Environment/config (loaded at startup)
|
|
42
53
|
"lib/env-loader.ts",
|
|
43
54
|
"lib/logger.ts",
|
|
44
|
-
|
|
55
|
+
"lib/debug-logger.ts",
|
|
56
|
+
// DB/Prisma (imported dynamically or at startup)
|
|
45
57
|
"lib/prisma.ts",
|
|
46
58
|
"lib/db.ts",
|
|
59
|
+
// Auth (used by middleware/edge functions)
|
|
60
|
+
"lib/auth.ts",
|
|
61
|
+
"lib/auth-server.ts",
|
|
62
|
+
"lib/auth-utils.ts",
|
|
63
|
+
"lib/auth-fetch.ts",
|
|
64
|
+
"lib/auth-server-utils.ts",
|
|
65
|
+
"lib/simple-auth.ts",
|
|
66
|
+
"lib/mock-auth-service.ts",
|
|
67
|
+
]);
|
|
68
|
+
/**
|
|
69
|
+
* Directory patterns to exclude entirely
|
|
70
|
+
*/
|
|
71
|
+
const EXCLUDED_DIRS = [
|
|
72
|
+
"__mocks__", // Jest mocks - used by test framework
|
|
73
|
+
"__tests__", // Test files
|
|
74
|
+
"examples", // Example/documentation code
|
|
75
|
+
"workers", // Web workers - loaded dynamically
|
|
76
|
+
"scrapers", // Often run as separate scripts
|
|
77
|
+
];
|
|
78
|
+
/**
|
|
79
|
+
* File patterns to exclude (regex)
|
|
80
|
+
*/
|
|
81
|
+
const EXCLUDED_PATTERNS = [
|
|
82
|
+
// Index/barrel files - they re-export other files
|
|
83
|
+
/\/index\.ts$/,
|
|
84
|
+
// Worker files - loaded dynamically by bundler
|
|
85
|
+
/\.worker\.ts$/,
|
|
86
|
+
// Type definition files
|
|
87
|
+
/\.d\.ts$/,
|
|
88
|
+
// Test files
|
|
89
|
+
/\.test\.tsx?$/,
|
|
90
|
+
/\.spec\.tsx?$/,
|
|
91
|
+
// Mock files anywhere in the path
|
|
92
|
+
/__mocks__\//,
|
|
93
|
+
// Example files
|
|
94
|
+
/examples?\//,
|
|
95
|
+
// Migration/seed files - run by CLI tools
|
|
96
|
+
/migrations?\//,
|
|
97
|
+
/seeds?\//,
|
|
98
|
+
// Config files that might be imported dynamically
|
|
99
|
+
/-config\.ts$/,
|
|
100
|
+
/\.config\.ts$/,
|
|
47
101
|
];
|
|
48
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Files that are commonly used in ways static analysis misses
|
|
104
|
+
* These get "low confidence" instead of being flagged as unused
|
|
105
|
+
*/
|
|
106
|
+
const LOW_CONFIDENCE_PATTERNS = [
|
|
107
|
+
// Integration adapters - often imported dynamically based on user config
|
|
108
|
+
/adapters?\//,
|
|
109
|
+
/integrations?\//,
|
|
110
|
+
// Catalog helpers - may be imported conditionally by category
|
|
111
|
+
/-catalog-helpers?\.ts$/,
|
|
112
|
+
// Database utilities - often loaded conditionally
|
|
113
|
+
/database\//,
|
|
114
|
+
/connection/,
|
|
115
|
+
/sharding/,
|
|
116
|
+
/query-retry/,
|
|
117
|
+
// OCR/AI utilities - may be conditionally loaded
|
|
118
|
+
/ocr/i,
|
|
119
|
+
/recognition/,
|
|
120
|
+
/-ai-/,
|
|
121
|
+
/ai-/,
|
|
122
|
+
// Image processing - often in workers or conditional
|
|
123
|
+
/image-/,
|
|
124
|
+
/-image/,
|
|
125
|
+
// Webhook/notification services - triggered by external events
|
|
126
|
+
/webhook/,
|
|
127
|
+
/notification/,
|
|
128
|
+
/trigger/,
|
|
129
|
+
// Cache/performance utilities - often loaded conditionally
|
|
130
|
+
/cache/,
|
|
131
|
+
/warming/,
|
|
132
|
+
/monitoring/,
|
|
133
|
+
// SEO/sitemap generators - often run as build scripts
|
|
134
|
+
/sitemap/,
|
|
135
|
+
/schema-org/,
|
|
136
|
+
/seo-/,
|
|
137
|
+
// Market data - may be loaded conditionally
|
|
138
|
+
/market-/,
|
|
139
|
+
// Validation utilities - may be imported dynamically
|
|
140
|
+
/validation/,
|
|
141
|
+
/anti-workaround/,
|
|
142
|
+
// 2FA/security - conditionally loaded
|
|
143
|
+
/2fa/,
|
|
144
|
+
/sms\.ts$/,
|
|
145
|
+
// Platform/haptics - conditionally loaded based on platform
|
|
146
|
+
/haptics/,
|
|
147
|
+
/platform-/,
|
|
148
|
+
// Learning/ML utilities - conditionally loaded
|
|
149
|
+
/learning/,
|
|
150
|
+
/confidence/,
|
|
151
|
+
// Field mapping utilities - used by import adapters
|
|
152
|
+
/field-mapping/,
|
|
153
|
+
/woocommerce-/,
|
|
154
|
+
// Theme/styling utilities - may be imported by build tools
|
|
155
|
+
/theme-/,
|
|
156
|
+
/tokens/,
|
|
157
|
+
];
|
|
158
|
+
// =============================================================================
|
|
159
|
+
// IMPORT CHECK DIRECTORIES
|
|
160
|
+
// =============================================================================
|
|
49
161
|
const IMPORT_CHECK_DIRS = [
|
|
50
162
|
"app",
|
|
51
163
|
"components",
|
|
52
164
|
"hooks",
|
|
53
165
|
"lib",
|
|
54
166
|
"pages",
|
|
55
|
-
"scripts
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/lib\/constants\/.*\.ts$/,
|
|
167
|
+
"scripts", // All scripts, not just active
|
|
168
|
+
"middleware",
|
|
169
|
+
"instrumentation",
|
|
170
|
+
"e2e", // E2E tests may import lib files
|
|
171
|
+
"tests", // Unit tests
|
|
172
|
+
"__tests__",
|
|
62
173
|
];
|
|
174
|
+
// =============================================================================
|
|
175
|
+
// HELPERS
|
|
176
|
+
// =============================================================================
|
|
63
177
|
function getAllLibFiles(dir) {
|
|
64
178
|
const files = [];
|
|
65
179
|
function traverse(currentDir) {
|
|
@@ -68,10 +182,15 @@ function getAllLibFiles(dir) {
|
|
|
68
182
|
const entries = node_fs_1.default.readdirSync(currentDir, { withFileTypes: true });
|
|
69
183
|
for (const entry of entries) {
|
|
70
184
|
const fullPath = node_path_1.default.join(currentDir, entry.name);
|
|
185
|
+
// Skip excluded directories
|
|
71
186
|
if (entry.isDirectory()) {
|
|
72
|
-
|
|
187
|
+
if (!EXCLUDED_DIRS.includes(entry.name)) {
|
|
188
|
+
traverse(fullPath);
|
|
189
|
+
}
|
|
190
|
+
continue;
|
|
73
191
|
}
|
|
74
|
-
|
|
192
|
+
// Only check .ts/.tsx files
|
|
193
|
+
if (entry.isFile() &&
|
|
75
194
|
(entry.name.endsWith(".ts") || entry.name.endsWith(".tsx")) &&
|
|
76
195
|
!entry.name.endsWith(".test.ts") &&
|
|
77
196
|
!entry.name.endsWith(".test.tsx") &&
|
|
@@ -91,24 +210,51 @@ function getImportableNames(filePath) {
|
|
|
91
210
|
// Remove lib/ prefix and extension
|
|
92
211
|
const withoutLib = relativePath.replace(/^lib\//, "");
|
|
93
212
|
const withoutExt = withoutLib.replace(/\.(ts|tsx)$/, "");
|
|
94
|
-
|
|
213
|
+
const basename = node_path_1.default.basename(withoutExt);
|
|
214
|
+
const dirname = node_path_1.default.dirname(withoutExt);
|
|
215
|
+
// @/ alias imports
|
|
95
216
|
names.push(`@/lib/${withoutExt}`);
|
|
96
|
-
names.push(
|
|
97
|
-
names.push(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
217
|
+
names.push(`"@/lib/${withoutExt}"`);
|
|
218
|
+
names.push(`'@/lib/${withoutExt}'`);
|
|
219
|
+
// Relative imports from various depths
|
|
220
|
+
for (let i = 1; i <= 6; i++) {
|
|
221
|
+
const prefix = "../".repeat(i);
|
|
222
|
+
names.push(`${prefix}lib/${withoutExt}`);
|
|
223
|
+
names.push(`"${prefix}lib/${withoutExt}"`);
|
|
224
|
+
names.push(`'${prefix}lib/${withoutExt}'`);
|
|
225
|
+
}
|
|
226
|
+
// Same-directory imports (from within lib/)
|
|
227
|
+
names.push(`./${basename}`);
|
|
228
|
+
names.push(`"./${basename}"`);
|
|
229
|
+
names.push(`'./${basename}'`);
|
|
230
|
+
names.push(`"../${dirname}/${basename}"`);
|
|
231
|
+
names.push(`'../${dirname}/${basename}'`);
|
|
232
|
+
// Handle index files - can be imported as directory
|
|
103
233
|
if (withoutExt.endsWith("/index")) {
|
|
104
234
|
const dir = withoutExt.replace(/\/index$/, "");
|
|
105
235
|
names.push(`@/lib/${dir}`);
|
|
106
|
-
names.push(
|
|
236
|
+
names.push(`"@/lib/${dir}"`);
|
|
237
|
+
names.push(`'@/lib/${dir}'`);
|
|
107
238
|
}
|
|
239
|
+
// Dynamic imports
|
|
240
|
+
names.push(`import("@/lib/${withoutExt}")`);
|
|
241
|
+
names.push(`import('@/lib/${withoutExt}')`);
|
|
242
|
+
names.push(`require("@/lib/${withoutExt}")`);
|
|
243
|
+
names.push(`require('@/lib/${withoutExt}')`);
|
|
244
|
+
// Re-exports from barrel files (check for the export name)
|
|
245
|
+
names.push(`from "./${basename}"`);
|
|
246
|
+
names.push(`from './${basename}'`);
|
|
247
|
+
names.push(`export * from "./${basename}"`);
|
|
248
|
+
names.push(`export * from './${basename}'`);
|
|
108
249
|
return names;
|
|
109
250
|
}
|
|
110
|
-
function isFileImported(filePath, allSourceFiles) {
|
|
251
|
+
function isFileImported(filePath, allSourceFiles, barrelExports) {
|
|
111
252
|
const importableNames = getImportableNames(filePath);
|
|
253
|
+
const relativePath = node_path_1.default
|
|
254
|
+
.relative(process.cwd(), filePath)
|
|
255
|
+
.replace(/\\/g, "/");
|
|
256
|
+
const basename = node_path_1.default.basename(relativePath, node_path_1.default.extname(relativePath));
|
|
257
|
+
// Check direct imports
|
|
112
258
|
for (const [_, content] of allSourceFiles) {
|
|
113
259
|
for (const importName of importableNames) {
|
|
114
260
|
if (content.includes(importName)) {
|
|
@@ -116,6 +262,20 @@ function isFileImported(filePath, allSourceFiles) {
|
|
|
116
262
|
}
|
|
117
263
|
}
|
|
118
264
|
}
|
|
265
|
+
// Check if exported from a barrel file
|
|
266
|
+
for (const [barrelPath, exports] of barrelExports) {
|
|
267
|
+
if (exports.has(basename) || exports.has(relativePath)) {
|
|
268
|
+
// The barrel file exports this - check if barrel is imported
|
|
269
|
+
const barrelImportNames = getImportableNames(barrelPath);
|
|
270
|
+
for (const [_, content] of allSourceFiles) {
|
|
271
|
+
for (const importName of barrelImportNames) {
|
|
272
|
+
if (content.includes(importName)) {
|
|
273
|
+
return true;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
119
279
|
return false;
|
|
120
280
|
}
|
|
121
281
|
function loadSourceFiles(dirs) {
|
|
@@ -125,52 +285,114 @@ function loadSourceFiles(dirs) {
|
|
|
125
285
|
if (!node_fs_1.default.existsSync(fullDir))
|
|
126
286
|
continue;
|
|
127
287
|
function traverse(currentDir) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
else if (entry.isFile() &&
|
|
135
|
-
(entry.name.endsWith(".ts") ||
|
|
136
|
-
entry.name.endsWith(".tsx") ||
|
|
137
|
-
entry.name.endsWith(".js") ||
|
|
138
|
-
entry.name.endsWith(".jsx") ||
|
|
139
|
-
entry.name.endsWith(".md"))) {
|
|
140
|
-
try {
|
|
141
|
-
files.set(fullPath, node_fs_1.default.readFileSync(fullPath, "utf-8"));
|
|
288
|
+
try {
|
|
289
|
+
const entries = node_fs_1.default.readdirSync(currentDir, { withFileTypes: true });
|
|
290
|
+
for (const entry of entries) {
|
|
291
|
+
const fullPath = node_path_1.default.join(currentDir, entry.name);
|
|
292
|
+
if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") {
|
|
293
|
+
traverse(fullPath);
|
|
142
294
|
}
|
|
143
|
-
|
|
144
|
-
|
|
295
|
+
else if (entry.isFile() &&
|
|
296
|
+
(entry.name.endsWith(".ts") ||
|
|
297
|
+
entry.name.endsWith(".tsx") ||
|
|
298
|
+
entry.name.endsWith(".js") ||
|
|
299
|
+
entry.name.endsWith(".jsx") ||
|
|
300
|
+
entry.name.endsWith(".mjs") ||
|
|
301
|
+
entry.name.endsWith(".md") ||
|
|
302
|
+
entry.name.endsWith(".json"))) {
|
|
303
|
+
try {
|
|
304
|
+
files.set(fullPath, node_fs_1.default.readFileSync(fullPath, "utf-8"));
|
|
305
|
+
}
|
|
306
|
+
catch {
|
|
307
|
+
// Skip unreadable files
|
|
308
|
+
}
|
|
145
309
|
}
|
|
146
310
|
}
|
|
147
311
|
}
|
|
312
|
+
catch {
|
|
313
|
+
// Skip unreadable directories
|
|
314
|
+
}
|
|
148
315
|
}
|
|
149
316
|
traverse(fullDir);
|
|
150
317
|
}
|
|
151
318
|
return files;
|
|
152
319
|
}
|
|
320
|
+
function findBarrelExports(libDir) {
|
|
321
|
+
const barrels = new Map();
|
|
322
|
+
function findIndexFiles(dir) {
|
|
323
|
+
if (!node_fs_1.default.existsSync(dir))
|
|
324
|
+
return;
|
|
325
|
+
const entries = node_fs_1.default.readdirSync(dir, { withFileTypes: true });
|
|
326
|
+
for (const entry of entries) {
|
|
327
|
+
const fullPath = node_path_1.default.join(dir, entry.name);
|
|
328
|
+
if (entry.isDirectory()) {
|
|
329
|
+
findIndexFiles(fullPath);
|
|
330
|
+
}
|
|
331
|
+
else if (entry.name === "index.ts" || entry.name === "index.tsx") {
|
|
332
|
+
// Parse barrel file for re-exports
|
|
333
|
+
try {
|
|
334
|
+
const content = node_fs_1.default.readFileSync(fullPath, "utf-8");
|
|
335
|
+
const exports = new Set();
|
|
336
|
+
// Match: export * from "./something"
|
|
337
|
+
const reExportPattern = /export\s+\*\s+from\s+["']\.\/([^"']+)["']/g;
|
|
338
|
+
let match;
|
|
339
|
+
while ((match = reExportPattern.exec(content)) !== null) {
|
|
340
|
+
exports.add(match[1]);
|
|
341
|
+
}
|
|
342
|
+
// Match: export { x, y } from "./something"
|
|
343
|
+
const namedExportPattern = /export\s+\{[^}]+\}\s+from\s+["']\.\/([^"']+)["']/g;
|
|
344
|
+
while ((match = namedExportPattern.exec(content)) !== null) {
|
|
345
|
+
exports.add(match[1]);
|
|
346
|
+
}
|
|
347
|
+
if (exports.size > 0) {
|
|
348
|
+
barrels.set(fullPath, exports);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
catch {
|
|
352
|
+
// Skip unreadable files
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
findIndexFiles(libDir);
|
|
358
|
+
return barrels;
|
|
359
|
+
}
|
|
153
360
|
function isExcluded(filePath) {
|
|
154
361
|
const relativePath = node_path_1.default
|
|
155
362
|
.relative(process.cwd(), filePath)
|
|
156
363
|
.replace(/\\/g, "/");
|
|
157
364
|
// Check explicit exclusions
|
|
158
|
-
if (EXCLUDED_FILES.
|
|
365
|
+
if (EXCLUDED_FILES.has(relativePath)) {
|
|
159
366
|
return true;
|
|
160
367
|
}
|
|
161
|
-
// Check
|
|
162
|
-
for (const pattern of
|
|
368
|
+
// Check pattern exclusions
|
|
369
|
+
for (const pattern of EXCLUDED_PATTERNS) {
|
|
163
370
|
if (pattern.test(relativePath)) {
|
|
164
371
|
return true;
|
|
165
372
|
}
|
|
166
373
|
}
|
|
167
374
|
return false;
|
|
168
375
|
}
|
|
376
|
+
function getLowConfidenceReason(filePath) {
|
|
377
|
+
const relativePath = node_path_1.default
|
|
378
|
+
.relative(process.cwd(), filePath)
|
|
379
|
+
.replace(/\\/g, "/");
|
|
380
|
+
for (const pattern of LOW_CONFIDENCE_PATTERNS) {
|
|
381
|
+
if (pattern.test(relativePath)) {
|
|
382
|
+
return "File matches pattern that's often dynamically imported or conditionally used";
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return null;
|
|
386
|
+
}
|
|
169
387
|
async function run() {
|
|
170
|
-
const reporter = (0, universal_progress_reporter_1.createUniversalProgressReporter)(exports.name);
|
|
171
388
|
const libDir = node_path_1.default.join(process.cwd(), "lib");
|
|
389
|
+
const unusedFiles = [];
|
|
390
|
+
if (!node_fs_1.default.existsSync(libDir)) {
|
|
391
|
+
console.log(`${console_chars_1.emoji.info} No lib/ directory found - skipping check`);
|
|
392
|
+
return { success: true, errors: 0, warnings: 0 };
|
|
393
|
+
}
|
|
172
394
|
console.log((0, console_chars_1.createDivider)());
|
|
173
|
-
console.log(`${console_chars_1.emoji.search} Checking for unused lib/ files...`);
|
|
395
|
+
console.log(`${console_chars_1.emoji.search} Checking for potentially unused lib/ files...`);
|
|
174
396
|
console.log();
|
|
175
397
|
// Get all lib files
|
|
176
398
|
const libFiles = getAllLibFiles(libDir);
|
|
@@ -179,6 +401,10 @@ async function run() {
|
|
|
179
401
|
console.log(`Loading source files from: ${IMPORT_CHECK_DIRS.join(", ")}`);
|
|
180
402
|
const sourceFiles = loadSourceFiles(IMPORT_CHECK_DIRS);
|
|
181
403
|
console.log(`Loaded ${sourceFiles.size} source files`);
|
|
404
|
+
// Find barrel exports
|
|
405
|
+
console.log(`Scanning for barrel exports...`);
|
|
406
|
+
const barrelExports = findBarrelExports(libDir);
|
|
407
|
+
console.log(`Found ${barrelExports.size} barrel files with re-exports`);
|
|
182
408
|
console.log();
|
|
183
409
|
// Check each lib file
|
|
184
410
|
for (const libFile of libFiles) {
|
|
@@ -188,75 +414,73 @@ async function run() {
|
|
|
188
414
|
if (isExcluded(libFile)) {
|
|
189
415
|
continue;
|
|
190
416
|
}
|
|
191
|
-
if (!isFileImported(libFile, sourceFiles)) {
|
|
192
|
-
|
|
193
|
-
let reason = "Not imported in any source file";
|
|
194
|
-
let suggestion = "Consider archiving or removing";
|
|
195
|
-
let severity = "warning";
|
|
196
|
-
// Check for specific patterns
|
|
197
|
-
if (relativePath.includes("rotation")) {
|
|
198
|
-
reason = "Unused rotation detection implementation";
|
|
199
|
-
suggestion =
|
|
200
|
-
"Multiple rotation algorithms exist - consolidate to one primary implementation";
|
|
201
|
-
}
|
|
202
|
-
else if (relativePath.includes("border")) {
|
|
203
|
-
reason = "Unused border processing implementation";
|
|
204
|
-
suggestion =
|
|
205
|
-
"Multiple border removal implementations exist - consolidate to one";
|
|
206
|
-
}
|
|
207
|
-
else if (relativePath.includes("recognition")) {
|
|
208
|
-
reason = "Unused recognition component";
|
|
209
|
-
suggestion = "Check if this was replaced by another implementation";
|
|
210
|
-
}
|
|
211
|
-
else if (relativePath.includes("debug")) {
|
|
212
|
-
reason = "Debug utility not imported";
|
|
213
|
-
suggestion = "Move to scripts/archived/ or remove";
|
|
214
|
-
severity = "info";
|
|
215
|
-
}
|
|
417
|
+
if (!isFileImported(libFile, sourceFiles, barrelExports)) {
|
|
418
|
+
const lowConfidenceReason = getLowConfidenceReason(libFile);
|
|
216
419
|
unusedFiles.push({
|
|
217
420
|
file: relativePath,
|
|
218
|
-
reason,
|
|
219
|
-
|
|
220
|
-
severity,
|
|
421
|
+
reason: lowConfidenceReason || "Not found in any import statement",
|
|
422
|
+
confidence: lowConfidenceReason ? "low" : "medium",
|
|
221
423
|
});
|
|
222
424
|
}
|
|
223
425
|
}
|
|
224
426
|
// Report findings
|
|
225
427
|
if (unusedFiles.length === 0) {
|
|
226
|
-
console.log(`${console_chars_1.emoji.success} No unused lib/ files detected`);
|
|
428
|
+
console.log(`${console_chars_1.emoji.success} No potentially unused lib/ files detected`);
|
|
429
|
+
console.log((0, console_chars_1.createDivider)());
|
|
430
|
+
return { success: true, errors: 0, warnings: 0 };
|
|
227
431
|
}
|
|
228
|
-
|
|
229
|
-
|
|
432
|
+
// Sort by confidence
|
|
433
|
+
const lowConfidence = unusedFiles.filter((f) => f.confidence === "low");
|
|
434
|
+
const mediumConfidence = unusedFiles.filter((f) => f.confidence === "medium");
|
|
435
|
+
console.log(`${console_chars_1.emoji.warning} Found ${unusedFiles.length} potentially unused lib/ files:`);
|
|
436
|
+
console.log();
|
|
437
|
+
if (mediumConfidence.length > 0) {
|
|
438
|
+
console.log(`${console_chars_1.chars.warning} Medium confidence (${mediumConfidence.length}) - verify before cleanup:`);
|
|
439
|
+
for (const file of mediumConfidence.slice(0, 20)) {
|
|
440
|
+
console.log(` ${console_chars_1.chars.bullet} ${file.file}`);
|
|
441
|
+
}
|
|
442
|
+
if (mediumConfidence.length > 20) {
|
|
443
|
+
console.log(` ... and ${mediumConfidence.length - 20} more`);
|
|
444
|
+
}
|
|
230
445
|
console.log();
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
console.log(` ${console_chars_1.chars.arrow} ${file.reason}`);
|
|
238
|
-
console.log(` ${console_chars_1.chars.arrow} ${file.suggestion}`);
|
|
239
|
-
}
|
|
240
|
-
console.log();
|
|
446
|
+
}
|
|
447
|
+
if (lowConfidence.length > 0) {
|
|
448
|
+
console.log(`${console_chars_1.chars.info} Low confidence (${lowConfidence.length}) - likely false positives:`);
|
|
449
|
+
for (const file of lowConfidence.slice(0, 10)) {
|
|
450
|
+
console.log(` ${console_chars_1.chars.bullet} ${file.file}`);
|
|
451
|
+
console.log(` ${console_chars_1.chars.arrow} ${file.reason}`);
|
|
241
452
|
}
|
|
242
|
-
if (
|
|
243
|
-
console.log(
|
|
244
|
-
for (const file of infos) {
|
|
245
|
-
console.log(` ${console_chars_1.chars.bullet} ${file.file}`);
|
|
246
|
-
console.log(` ${console_chars_1.chars.arrow} ${file.reason}`);
|
|
247
|
-
}
|
|
248
|
-
console.log();
|
|
453
|
+
if (lowConfidence.length > 10) {
|
|
454
|
+
console.log(` ... and ${lowConfidence.length - 10} more`);
|
|
249
455
|
}
|
|
250
|
-
console.log(
|
|
251
|
-
console.log("Recommendations for AI clarity:");
|
|
252
|
-
console.log(" 1. Archive unused rotation/border implementations to scripts/archived/");
|
|
253
|
-
console.log(" 2. Add comments to remaining files explaining which is the primary implementation");
|
|
254
|
-
console.log(' 3. Update lib/recognition/index.ts to clearly document the "happy path"');
|
|
456
|
+
console.log();
|
|
255
457
|
}
|
|
256
458
|
console.log((0, console_chars_1.createDivider)());
|
|
459
|
+
console.log(`${console_chars_1.emoji.warning} IMPORTANT: This is ADVISORY ONLY!`);
|
|
460
|
+
console.log();
|
|
461
|
+
console.log(" DO NOT auto-delete these files. Many have legitimate uses that");
|
|
462
|
+
console.log(" static analysis cannot detect:");
|
|
463
|
+
console.log(" - Dynamic imports (import() expressions)");
|
|
464
|
+
console.log(" - Conditional imports based on environment");
|
|
465
|
+
console.log(" - Files used by external tools/scripts");
|
|
466
|
+
console.log(" - Worker files loaded by bundler");
|
|
467
|
+
console.log(" - Integration adapters loaded by configuration");
|
|
468
|
+
console.log(" - Files imported by tests not in standard locations");
|
|
469
|
+
console.log();
|
|
470
|
+
console.log(" Always verify manually before removing any files!");
|
|
471
|
+
console.log((0, console_chars_1.createDivider)());
|
|
472
|
+
// Return success (non-blocking) but report warning count
|
|
473
|
+
return { success: true, errors: 0, warnings: mediumConfidence.length };
|
|
257
474
|
}
|
|
258
475
|
// Allow direct execution
|
|
259
476
|
if (require.main === module) {
|
|
260
|
-
run()
|
|
477
|
+
run()
|
|
478
|
+
.then((result) => {
|
|
479
|
+
process.exit(result.success ? 0 : 1);
|
|
480
|
+
})
|
|
481
|
+
.catch((err) => {
|
|
482
|
+
console.error(err);
|
|
483
|
+
process.exit(1);
|
|
484
|
+
});
|
|
261
485
|
}
|
|
262
486
|
//# sourceMappingURL=unused-lib-detection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unused-lib-detection.js","sourceRoot":"","sources":["../../../src/checks/code-quality/unused-lib-detection.ts"],"names":[],"mappings":";;AAEA;;;;;;;;;;GAUG;;;;;;AA4LH,kBA0GC;AApSD,sDAAyB;AACzB,0DAA6B;AAC7B,6DAAwE;AACxE,uFAAwF;AAExF,kDAAkD;AACrC,QAAA,EAAE,GAAG,mCAAmC,CAAC;AACzC,QAAA,IAAI,GAAG,+BAA+B,CAAC;AACvC,QAAA,WAAW,GACtB,sFAAsF,CAAC;AAC5E,QAAA,QAAQ,GAAG,cAAc,CAAC;AAC1B,QAAA,QAAQ,GAAG,KAAK,CAAC;AACjB,QAAA,IAAI,GAAG,CAAC,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;AAS1E,MAAM,WAAW,GAAiB,EA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AAG,CAAC,iCAAiC,CAAC,CAAC;QAC/C,OAAO,CAAC,GAAG,CACT,0EAA0E,CAC3E,CAAC;QACF,OAAO,CAAC,GAAG,CACT,qFAAqF,CACtF,CAAC;QACF,OAAO,CAAC,GAAG,CACT,2EAA2E,CAC5E,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,IAAA,6BAAa,GAAE,CAAC,CAAC;AAC/B,CAAC;AAED,yBAAyB;AACzB,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC"}
|
|
1
|
+
{"version":3,"file":"unused-lib-detection.js","sourceRoot":"","sources":["../../../src/checks/code-quality/unused-lib-detection.ts"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;AAsbH,kBAuGC;AA3hBD,sDAAyB;AACzB,0DAA6B;AAC7B,6DAAwE;AAExE,kDAAkD;AACrC,QAAA,EAAE,GAAG,mCAAmC,CAAC;AACzC,QAAA,IAAI,GAAG,+BAA+B,CAAC;AACvC,QAAA,WAAW,GACtB,6FAA6F,CAAC;AACnF,QAAA,QAAQ,GAAG,cAAc,CAAC;AAC1B,QAAA,QAAQ,GAAG,KAAK,CAAC;AACjB,QAAA,IAAI,GAAG,CAAC,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;AACzE,QAAA,QAAQ,GAAG,CAAC,qBAAqB,CAAC,CAAC;AAQhD,gFAAgF;AAChF,4DAA4D;AAC5D,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,2BAA2B;IAC3B,cAAc;IACd,cAAc;IAEd,yCAAyC;IACzC,mBAAmB;IACnB,eAAe;IACf,qBAAqB;IAErB,iDAAiD;IACjD,eAAe;IACf,WAAW;IAEX,2CAA2C;IAC3C,aAA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,CAAC,qDAAqD,CAAC,CAAC;IACnE,OAAO,CAAC,GAAG,CAAC,IAAA,6BAAa,GAAE,CAAC,CAAC;IAE7B,yDAAyD;IACzD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,gBAAgB,CAAC,MAAM,EAAE,CAAC;AACzE,CAAC;AAED,yBAAyB;AACzB,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,GAAG,EAAE;SACF,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACf,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Section Header Spacing Preflight
|
|
3
|
+
*
|
|
4
|
+
* Ensures proper spacing around section headers (h2, h3) and their
|
|
5
|
+
* accompanying descriptive text. Without proper spacing, sections
|
|
6
|
+
* look cramped and unprofessional.
|
|
7
|
+
*
|
|
8
|
+
* RULES:
|
|
9
|
+
* 1. Container pattern check: When a div contains only heading (h2/h3) + paragraph,
|
|
10
|
+
* it MUST have flex/gap or mb-* spacing classes
|
|
11
|
+
* 2. Section header margin: Header containers should have bottom margin (mb-*)
|
|
12
|
+
* before grid/content follows
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* pnpm preflight:ui-spacing:section-headers
|
|
16
|
+
*/
|
|
17
|
+
export declare const id = "ui/section-header-spacing";
|
|
18
|
+
export declare const name = "Section Header Spacing";
|
|
19
|
+
export declare const category = "ui";
|
|
20
|
+
export declare const blocking = true;
|
|
21
|
+
export declare const description = "Ensures proper spacing around section headers";
|
|
22
|
+
export declare const tags: string[];
|
|
23
|
+
export declare function run(): Promise<void>;
|
|
24
|
+
//# sourceMappingURL=section-header-spacing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-header-spacing.d.ts","sourceRoot":"","sources":["../../../src/checks/ui/section-header-spacing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAQH,eAAO,MAAM,EAAE,8BAA8B,CAAC;AAC9C,eAAO,MAAM,IAAI,2BAA2B,CAAC;AAC7C,eAAO,MAAM,QAAQ,OAAO,CAAC;AAC7B,eAAO,MAAM,QAAQ,OAAO,CAAC;AAC7B,eAAO,MAAM,WAAW,kDAAkD,CAAC;AAC3E,eAAO,MAAM,IAAI,UAAoB,CAAC;AA8BtC,wBAAsB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAsLzC"}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Section Header Spacing Preflight
|
|
4
|
+
*
|
|
5
|
+
* Ensures proper spacing around section headers (h2, h3) and their
|
|
6
|
+
* accompanying descriptive text. Without proper spacing, sections
|
|
7
|
+
* look cramped and unprofessional.
|
|
8
|
+
*
|
|
9
|
+
* RULES:
|
|
10
|
+
* 1. Container pattern check: When a div contains only heading (h2/h3) + paragraph,
|
|
11
|
+
* it MUST have flex/gap or mb-* spacing classes
|
|
12
|
+
* 2. Section header margin: Header containers should have bottom margin (mb-*)
|
|
13
|
+
* before grid/content follows
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* pnpm preflight:ui-spacing:section-headers
|
|
17
|
+
*/
|
|
18
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
21
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
22
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
23
|
+
}
|
|
24
|
+
Object.defineProperty(o, k2, desc);
|
|
25
|
+
}) : (function(o, m, k, k2) {
|
|
26
|
+
if (k2 === undefined) k2 = k;
|
|
27
|
+
o[k2] = m[k];
|
|
28
|
+
}));
|
|
29
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
30
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
31
|
+
}) : function(o, v) {
|
|
32
|
+
o["default"] = v;
|
|
33
|
+
});
|
|
34
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
35
|
+
var ownKeys = function(o) {
|
|
36
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
37
|
+
var ar = [];
|
|
38
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
39
|
+
return ar;
|
|
40
|
+
};
|
|
41
|
+
return ownKeys(o);
|
|
42
|
+
};
|
|
43
|
+
return function (mod) {
|
|
44
|
+
if (mod && mod.__esModule) return mod;
|
|
45
|
+
var result = {};
|
|
46
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
47
|
+
__setModuleDefault(result, mod);
|
|
48
|
+
return result;
|
|
49
|
+
};
|
|
50
|
+
})();
|
|
51
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
|
+
exports.tags = exports.description = exports.blocking = exports.category = exports.name = exports.id = void 0;
|
|
53
|
+
exports.run = run;
|
|
54
|
+
const fs = __importStar(require("fs"));
|
|
55
|
+
const file_cache_1 = require("../../shared/file-cache");
|
|
56
|
+
const glob_patterns_1 = require("../../shared/glob-patterns");
|
|
57
|
+
const console_chars_1 = require("../../utils/console-chars");
|
|
58
|
+
// Check metadata
|
|
59
|
+
exports.id = "ui/section-header-spacing";
|
|
60
|
+
exports.name = "Section Header Spacing";
|
|
61
|
+
exports.category = "ui";
|
|
62
|
+
exports.blocking = true;
|
|
63
|
+
exports.description = "Ensures proper spacing around section headers";
|
|
64
|
+
exports.tags = ["ui", "spacing"];
|
|
65
|
+
const EXCLUDED = (0, glob_patterns_1.extendExcludes)(glob_patterns_1.STANDARD_EXCLUDES_WITH_TESTS, [
|
|
66
|
+
"**/scripts/**",
|
|
67
|
+
"**/test-results/**",
|
|
68
|
+
"**/packages/**",
|
|
69
|
+
]);
|
|
70
|
+
// Pattern 1: Div containing h2/h3 followed by p without gap class
|
|
71
|
+
// This catches: <div className="text-center"><h3>...</h3><p>...</p></div>
|
|
72
|
+
// with no gap-* or flex in the className
|
|
73
|
+
const HEADER_CONTAINER_PATTERN = /<div\s+(?:style=\{[^}]*\}\s+)?className="([^"]*)">\s*\n?\s*<h[23][^>]*>[\s\S]*?<\/h[23]>\s*\n?\s*<p[^>]*>/g;
|
|
74
|
+
// Pattern 2: Header containers that transition directly to grids without margin
|
|
75
|
+
// This catches content like: </div>\n\n<div className="grid"
|
|
76
|
+
const HEADER_TO_GRID_PATTERN = /<\/div>\s*\n?\s*(?:\{\/\*[^*]*\*\/\})?\s*\n?\s*<div\s+className="(?!.*mb-)([^"]*(?:grid|flex)[^"]*)"/g;
|
|
77
|
+
async function run() {
|
|
78
|
+
console.log(`\n${console_chars_1.emoji.search} Section Header Spacing Check\n`);
|
|
79
|
+
console.log("Rules:");
|
|
80
|
+
console.log(` ${console_chars_1.emoji.error} Section header containers (div with h2/h3 + p) must have gap-* or flex gap`);
|
|
81
|
+
console.log(` ${console_chars_1.emoji.error} Section header containers before grids must have mb-* for separation`);
|
|
82
|
+
console.log("");
|
|
83
|
+
const allFiles = await file_cache_1.fileCache.getAllTsTsx();
|
|
84
|
+
// Filter for component files
|
|
85
|
+
const files = allFiles.filter((file) => {
|
|
86
|
+
const normalizedPath = file.replace(/\\/g, "/");
|
|
87
|
+
return (!normalizedPath.includes("/scripts/") &&
|
|
88
|
+
!normalizedPath.includes("/tests/") &&
|
|
89
|
+
!normalizedPath.includes("/packages/") &&
|
|
90
|
+
!normalizedPath.includes("/test-results/") &&
|
|
91
|
+
(normalizedPath.includes("/components/") || normalizedPath.includes("/app/")));
|
|
92
|
+
});
|
|
93
|
+
const issues = [];
|
|
94
|
+
for (const file of files) {
|
|
95
|
+
const content = fs.readFileSync(file, "utf8");
|
|
96
|
+
const lines = content.split("\n");
|
|
97
|
+
// Skip files with preflight-ignore at file level
|
|
98
|
+
if (content.includes("// preflight-file-ignore: section-header-spacing"))
|
|
99
|
+
continue;
|
|
100
|
+
// Check Pattern 1: Header container without gap
|
|
101
|
+
// Look for multi-line patterns with div > h2/h3 > p
|
|
102
|
+
for (let i = 0; i < lines.length - 3; i++) {
|
|
103
|
+
const line = lines[i];
|
|
104
|
+
// Skip if line has preflight-ignore
|
|
105
|
+
if (line.includes("preflight-ignore"))
|
|
106
|
+
continue;
|
|
107
|
+
// Look for opening div with className (but not containing gap- or flex)
|
|
108
|
+
const divMatch = line.match(/<div\s+className="([^"]*)"\s*>/);
|
|
109
|
+
if (divMatch) {
|
|
110
|
+
const className = divMatch[1];
|
|
111
|
+
// Skip if it already has gap-* or flex with gap
|
|
112
|
+
if (className.includes("gap-") || (className.includes("flex") && className.includes("gap")))
|
|
113
|
+
continue;
|
|
114
|
+
// Check next few lines for h2/h3 followed by p (section header pattern)
|
|
115
|
+
const nextLines = lines.slice(i, i + 6).join("\n");
|
|
116
|
+
const isHeaderPattern = /<h[23][^>]*>[\s\S]*?<\/h[23]>\s*\n?\s*<p[^>]*>[\s\S]*?<\/p>/.test(nextLines);
|
|
117
|
+
if (isHeaderPattern) {
|
|
118
|
+
// Check if container has mb-* for spacing below
|
|
119
|
+
const hasBottomMargin = className.match(/\bmb-\d+\b/);
|
|
120
|
+
// Check if it has flex flex-col gap-*
|
|
121
|
+
const hasFlexGap = (className.includes("flex") || className.includes("flex-col")) &&
|
|
122
|
+
className.includes("gap-");
|
|
123
|
+
if (!hasBottomMargin && !hasFlexGap) {
|
|
124
|
+
issues.push({
|
|
125
|
+
file,
|
|
126
|
+
line: i + 1,
|
|
127
|
+
column: line.indexOf("className") + 1,
|
|
128
|
+
type: "error",
|
|
129
|
+
rule: "section-header-container-spacing",
|
|
130
|
+
message: 'Section header container (div with h2/h3 + p) lacks spacing. Add "flex flex-col gap-2" for internal spacing and "mb-6" for separation from following content.',
|
|
131
|
+
snippet: line.trim(),
|
|
132
|
+
suggestion: 'Add className="mb-6 flex flex-col items-center gap-2 text-center" for proper spacing',
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// Check Pattern 2: Header block followed by grid without margin
|
|
139
|
+
// Look for lines where a closing tag is followed by a grid without mb-*
|
|
140
|
+
for (let i = 0; i < lines.length - 2; i++) {
|
|
141
|
+
const line = lines[i];
|
|
142
|
+
const nextLine = lines[i + 1] || "";
|
|
143
|
+
const nextNextLine = lines[i + 2] || "";
|
|
144
|
+
// Skip if commented
|
|
145
|
+
if (line.trim().startsWith("//") || line.trim().startsWith("/*"))
|
|
146
|
+
continue;
|
|
147
|
+
// Check for: </div> on one line, followed by a line with {/* Comment */} or blank,
|
|
148
|
+
// then a grid div without mb-*
|
|
149
|
+
if (line.includes("</div>")) {
|
|
150
|
+
// Check next 2-3 lines for a grid
|
|
151
|
+
const upcoming = [nextLine, nextNextLine].join("\n");
|
|
152
|
+
const gridMatch = upcoming.match(/<div\s+className="([^"]*\bgrid\b[^"]*)"/);
|
|
153
|
+
if (gridMatch) {
|
|
154
|
+
// Check if the previous line's container had mb-* (look back for the header container)
|
|
155
|
+
const prevLines = lines.slice(Math.max(0, i - 10), i).join("\n");
|
|
156
|
+
const isAfterHeader = prevLines.includes("<h2") || prevLines.includes("<h3");
|
|
157
|
+
if (isAfterHeader) {
|
|
158
|
+
// Check if the header container had mb-*
|
|
159
|
+
const headerContainerMatch = prevLines.match(/<div\s+className="([^"]*)"\s*>/);
|
|
160
|
+
if (headerContainerMatch) {
|
|
161
|
+
const containerClass = headerContainerMatch[1];
|
|
162
|
+
if (!containerClass.includes("mb-")) {
|
|
163
|
+
issues.push({
|
|
164
|
+
file,
|
|
165
|
+
line: i + 1,
|
|
166
|
+
column: 1,
|
|
167
|
+
type: "warning",
|
|
168
|
+
rule: "section-header-margin-before-grid",
|
|
169
|
+
message: "Section header container before grid lacks bottom margin. Content may appear cramped.",
|
|
170
|
+
snippet: lines.slice(Math.max(0, i - 2), i + 2).join("\n").trim(),
|
|
171
|
+
suggestion: 'Add "mb-6" to the header container for proper separation',
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// Deduplicate issues by file+line
|
|
181
|
+
const uniqueIssues = issues.filter((issue, index, self) => index === self.findIndex((i) => i.file === issue.file && i.line === issue.line));
|
|
182
|
+
// Report results
|
|
183
|
+
const errors = uniqueIssues.filter((i) => i.type === "error");
|
|
184
|
+
const warnings = uniqueIssues.filter((i) => i.type === "warning");
|
|
185
|
+
if (errors.length > 0) {
|
|
186
|
+
console.log(`\n${console_chars_1.emoji.error} BLOCKING ERRORS (${errors.length}):\n`);
|
|
187
|
+
errors.slice(0, 20).forEach((issue) => {
|
|
188
|
+
console.log(` ${issue.file}:${issue.line}:${issue.column}`);
|
|
189
|
+
console.log(` Rule: ${issue.rule}`);
|
|
190
|
+
console.log(` ${issue.message}`);
|
|
191
|
+
if (issue.suggestion) {
|
|
192
|
+
console.log(` ${console_chars_1.emoji.hint} ${issue.suggestion}`);
|
|
193
|
+
}
|
|
194
|
+
console.log("");
|
|
195
|
+
});
|
|
196
|
+
if (errors.length > 20) {
|
|
197
|
+
console.log(` ... and ${errors.length - 20} more errors\n`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (warnings.length > 0) {
|
|
201
|
+
console.log(`\n${console_chars_1.emoji.warning} WARNINGS (${warnings.length}):\n`);
|
|
202
|
+
warnings.slice(0, 10).forEach((issue) => {
|
|
203
|
+
console.log(` ${issue.file}:${issue.line} - ${issue.message}`);
|
|
204
|
+
});
|
|
205
|
+
if (warnings.length > 10) {
|
|
206
|
+
console.log(` ... and ${warnings.length - 10} more warnings`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// Summary
|
|
210
|
+
console.log("\n" + (0, console_chars_1.createDivider)(60, "light"));
|
|
211
|
+
console.log(`${console_chars_1.emoji.chart} Summary: ${errors.length} errors, ${warnings.length} warnings`);
|
|
212
|
+
if (errors.length > 0) {
|
|
213
|
+
console.log(`\n${console_chars_1.emoji.warning} ADVISORY: Found ${errors.length} section header spacing issues`);
|
|
214
|
+
console.log("\nFix guide:");
|
|
215
|
+
console.log(` ${console_chars_1.chars.bullet} Header containers with h2/h3 + p need gap-2 for internal spacing`);
|
|
216
|
+
console.log(` ${console_chars_1.chars.bullet} Header containers before grids need mb-6 for separation`);
|
|
217
|
+
console.log(` ${console_chars_1.chars.bullet} Standard pattern: className="mb-6 flex flex-col items-center gap-2 text-center"`);
|
|
218
|
+
console.log(`\n${console_chars_1.emoji.hint} This check is advisory. Pre-existing issues won't block the build.`);
|
|
219
|
+
}
|
|
220
|
+
else if (warnings.length > 0) {
|
|
221
|
+
console.log(`\n${console_chars_1.emoji.warning} Section header spacing check passed with ${warnings.length} advisory warnings.`);
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
console.log(`\n${console_chars_1.emoji.success} Section header spacing check passed!`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
// Allow direct execution
|
|
228
|
+
if (require.main === module) {
|
|
229
|
+
run().catch(console.error);
|
|
230
|
+
}
|
|
231
|
+
//# sourceMappingURL=section-header-spacing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-header-spacing.js","sourceRoot":"","sources":["../../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