@empline/preflight 1.1.50 → 1.1.51
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.
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* Preflight: Turbopack Safe Expressions
|
|
4
|
+
*
|
|
5
|
+
* Detects JavaScript expression patterns in JSX that can cause runtime errors
|
|
6
|
+
* when compiled by Turbopack (Next.js 13+). These patterns often result in
|
|
7
|
+
* cryptic "_ref is not defined" or similar errors.
|
|
8
|
+
*
|
|
9
|
+
* Known problematic patterns:
|
|
10
|
+
* 1. Nested optional chaining in template literals: ${a?.b?.c}
|
|
11
|
+
* 2. Optional chaining + nullish coalescing in JSX: ${a?.b ?? c}
|
|
12
|
+
* 3. Complex computed property access: obj[a?.b]
|
|
13
|
+
* 4. Optional chaining in function calls within JSX: ${fn(a?.b)}
|
|
14
|
+
*
|
|
15
|
+
* These patterns compile to temporary _ref variables that can become
|
|
16
|
+
* undefined in edge cases, causing runtime ReferenceErrors.
|
|
17
|
+
*
|
|
18
|
+
* BLOCKING: These cause runtime crashes that are hard to debug
|
|
19
|
+
*/
|
|
20
|
+
export declare const id = "react/turbopack-safe-expressions";
|
|
21
|
+
export declare const name = "Turbopack Safe Expressions";
|
|
22
|
+
export declare const category = "react";
|
|
23
|
+
export declare const blocking = true;
|
|
24
|
+
export declare const description = "Detects JSX expression patterns that cause Turbopack runtime errors";
|
|
25
|
+
export declare const tags: string[];
|
|
26
|
+
export declare function run(): Promise<{
|
|
27
|
+
passed: boolean;
|
|
28
|
+
findings: any[];
|
|
29
|
+
duration: number;
|
|
30
|
+
metadata?: undefined;
|
|
31
|
+
} | {
|
|
32
|
+
passed: boolean;
|
|
33
|
+
findings: {
|
|
34
|
+
message: string;
|
|
35
|
+
level: "error" | "warning";
|
|
36
|
+
file: string;
|
|
37
|
+
line: number;
|
|
38
|
+
code: string;
|
|
39
|
+
suggestion: string;
|
|
40
|
+
}[];
|
|
41
|
+
duration: number;
|
|
42
|
+
metadata: {
|
|
43
|
+
filesScanned: number;
|
|
44
|
+
errors: number;
|
|
45
|
+
warnings: number;
|
|
46
|
+
byRule: Record<string, number>;
|
|
47
|
+
};
|
|
48
|
+
}>;
|
|
49
|
+
//# sourceMappingURL=turbopack-safe-expressions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turbopack-safe-expressions.d.ts","sourceRoot":"","sources":["../../../src/checks/react/turbopack-safe-expressions.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;GAiBG;AAQH,eAAO,MAAM,EAAE,qCAAqC,CAAC;AACrD,eAAO,MAAM,IAAI,+BAA+B,CAAC;AACjD,eAAO,MAAM,QAAQ,UAAU,CAAC;AAChC,eAAO,MAAM,QAAQ,OAAO,CAAC;AAC7B,eAAO,MAAM,WAAW,wEAAwE,CAAC;AACjG,eAAO,MAAM,IAAI,UAAqE,CAAC;AAkUvF,wBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;;;GA+IxB"}
|
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* Preflight: Turbopack Safe Expressions
|
|
5
|
+
*
|
|
6
|
+
* Detects JavaScript expression patterns in JSX that can cause runtime errors
|
|
7
|
+
* when compiled by Turbopack (Next.js 13+). These patterns often result in
|
|
8
|
+
* cryptic "_ref is not defined" or similar errors.
|
|
9
|
+
*
|
|
10
|
+
* Known problematic patterns:
|
|
11
|
+
* 1. Nested optional chaining in template literals: ${a?.b?.c}
|
|
12
|
+
* 2. Optional chaining + nullish coalescing in JSX: ${a?.b ?? c}
|
|
13
|
+
* 3. Complex computed property access: obj[a?.b]
|
|
14
|
+
* 4. Optional chaining in function calls within JSX: ${fn(a?.b)}
|
|
15
|
+
*
|
|
16
|
+
* These patterns compile to temporary _ref variables that can become
|
|
17
|
+
* undefined in edge cases, causing runtime ReferenceErrors.
|
|
18
|
+
*
|
|
19
|
+
* BLOCKING: These cause runtime crashes that are hard to debug
|
|
20
|
+
*/
|
|
21
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
24
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
25
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
26
|
+
}
|
|
27
|
+
Object.defineProperty(o, k2, desc);
|
|
28
|
+
}) : (function(o, m, k, k2) {
|
|
29
|
+
if (k2 === undefined) k2 = k;
|
|
30
|
+
o[k2] = m[k];
|
|
31
|
+
}));
|
|
32
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
33
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
34
|
+
}) : function(o, v) {
|
|
35
|
+
o["default"] = v;
|
|
36
|
+
});
|
|
37
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
38
|
+
var ownKeys = function(o) {
|
|
39
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
40
|
+
var ar = [];
|
|
41
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
42
|
+
return ar;
|
|
43
|
+
};
|
|
44
|
+
return ownKeys(o);
|
|
45
|
+
};
|
|
46
|
+
return function (mod) {
|
|
47
|
+
if (mod && mod.__esModule) return mod;
|
|
48
|
+
var result = {};
|
|
49
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
50
|
+
__setModuleDefault(result, mod);
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
})();
|
|
54
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
|
+
exports.tags = exports.description = exports.blocking = exports.category = exports.name = exports.id = void 0;
|
|
56
|
+
exports.run = run;
|
|
57
|
+
const fs = __importStar(require("fs"));
|
|
58
|
+
const path = __importStar(require("path"));
|
|
59
|
+
const glob_1 = require("glob");
|
|
60
|
+
const console_chars_1 = require("../../utils/console-chars");
|
|
61
|
+
// Check metadata
|
|
62
|
+
exports.id = "react/turbopack-safe-expressions";
|
|
63
|
+
exports.name = "Turbopack Safe Expressions";
|
|
64
|
+
exports.category = "react";
|
|
65
|
+
exports.blocking = true;
|
|
66
|
+
exports.description = "Detects JSX expression patterns that cause Turbopack runtime errors";
|
|
67
|
+
exports.tags = ["turbopack", "nextjs", "runtime", "optional-chaining", "bundler"];
|
|
68
|
+
// =============================================================================
|
|
69
|
+
// CONFIGURATION
|
|
70
|
+
// =============================================================================
|
|
71
|
+
const FILE_PATTERNS = [
|
|
72
|
+
"app/**/*.{tsx,jsx}",
|
|
73
|
+
"src/**/*.{tsx,jsx}",
|
|
74
|
+
"pages/**/*.{tsx,jsx}",
|
|
75
|
+
"components/**/*.{tsx,jsx}",
|
|
76
|
+
];
|
|
77
|
+
const EXCLUDE_PATTERNS = [
|
|
78
|
+
"node_modules/**",
|
|
79
|
+
"**/*.test.{ts,tsx}",
|
|
80
|
+
"**/*.spec.{ts,tsx}",
|
|
81
|
+
"**/*.stories.{tsx}",
|
|
82
|
+
"**/*.d.ts",
|
|
83
|
+
".next/**",
|
|
84
|
+
"dist/**",
|
|
85
|
+
];
|
|
86
|
+
// =============================================================================
|
|
87
|
+
// DETECTION PATTERNS
|
|
88
|
+
// =============================================================================
|
|
89
|
+
/**
|
|
90
|
+
* Detect nested optional chaining in template literals within JSX
|
|
91
|
+
* Pattern: ${a?.b?.c} or ${a?.b?.c?.d}
|
|
92
|
+
*/
|
|
93
|
+
function detectNestedOptionalChaining(content, filePath) {
|
|
94
|
+
const findings = [];
|
|
95
|
+
const lines = content.split("\n");
|
|
96
|
+
// Track if we're in JSX context
|
|
97
|
+
let inJSX = false;
|
|
98
|
+
let jsxDepth = 0;
|
|
99
|
+
for (let i = 0; i < lines.length; i++) {
|
|
100
|
+
const line = lines[i];
|
|
101
|
+
// Simple JSX detection (not perfect but catches most cases)
|
|
102
|
+
const jsxOpens = (line.match(/<[A-Z][a-zA-Z]*|<[a-z]+\s/g) || []).length;
|
|
103
|
+
const jsxCloses = (line.match(/\/>/g) || []).length + (line.match(/<\/[a-zA-Z]+>/g) || []).length;
|
|
104
|
+
jsxDepth += jsxOpens - jsxCloses;
|
|
105
|
+
inJSX = jsxDepth > 0 || jsxOpens > 0;
|
|
106
|
+
// Look for template literals with nested optional chaining
|
|
107
|
+
// Pattern: `...${something?.nested?.property}...`
|
|
108
|
+
const templateMatches = line.matchAll(/\$\{([^}]+)\}/g);
|
|
109
|
+
for (const match of templateMatches) {
|
|
110
|
+
const expression = match[1];
|
|
111
|
+
const columnIndex = match.index || 0;
|
|
112
|
+
// Count optional chaining operators
|
|
113
|
+
const optionalChainCount = (expression.match(/\?\./g) || []).length;
|
|
114
|
+
if (optionalChainCount >= 2) {
|
|
115
|
+
// Nested optional chaining detected
|
|
116
|
+
findings.push({
|
|
117
|
+
file: filePath,
|
|
118
|
+
line: i + 1,
|
|
119
|
+
column: columnIndex,
|
|
120
|
+
rule: "turbopack-nested-optional",
|
|
121
|
+
severity: "error",
|
|
122
|
+
message: `Nested optional chaining in template literal can cause "_ref is not defined" runtime error`,
|
|
123
|
+
code: expression.trim(),
|
|
124
|
+
suggestion: `Extract to variable: const value = ${expression.trim()}; then use \${value}`,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
// Check for optional chaining + nullish coalescing
|
|
128
|
+
if (expression.includes("?.") && expression.includes("??")) {
|
|
129
|
+
findings.push({
|
|
130
|
+
file: filePath,
|
|
131
|
+
line: i + 1,
|
|
132
|
+
column: columnIndex,
|
|
133
|
+
rule: "turbopack-optional-nullish",
|
|
134
|
+
severity: "error",
|
|
135
|
+
message: `Optional chaining with nullish coalescing in template literal can cause Turbopack runtime errors`,
|
|
136
|
+
code: expression.trim(),
|
|
137
|
+
suggestion: `Extract to variable: const value = ${expression.trim()}; then use \${value}`,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return findings;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Detect optional chaining in JSX attribute values (non-template)
|
|
146
|
+
* Pattern: prop={a?.b?.c ?? d}
|
|
147
|
+
*/
|
|
148
|
+
function detectOptionalChainingInJSXProps(content, filePath) {
|
|
149
|
+
const findings = [];
|
|
150
|
+
const lines = content.split("\n");
|
|
151
|
+
for (let i = 0; i < lines.length; i++) {
|
|
152
|
+
const line = lines[i];
|
|
153
|
+
// Match JSX prop assignments with complex expressions
|
|
154
|
+
// Pattern: propName={expression}
|
|
155
|
+
const propMatches = line.matchAll(/(\w+)=\{([^}]+)\}/g);
|
|
156
|
+
for (const match of propMatches) {
|
|
157
|
+
const propName = match[1];
|
|
158
|
+
const expression = match[2];
|
|
159
|
+
const columnIndex = match.index || 0;
|
|
160
|
+
// Skip simple expressions
|
|
161
|
+
if (!expression.includes("?."))
|
|
162
|
+
continue;
|
|
163
|
+
// Check for nested optional chaining with nullish coalescing
|
|
164
|
+
const hasNestedOptional = (expression.match(/\?\./g) || []).length >= 2;
|
|
165
|
+
const hasNullishCoalescing = expression.includes("??");
|
|
166
|
+
if (hasNestedOptional && hasNullishCoalescing) {
|
|
167
|
+
findings.push({
|
|
168
|
+
file: filePath,
|
|
169
|
+
line: i + 1,
|
|
170
|
+
column: columnIndex,
|
|
171
|
+
rule: "turbopack-complex-prop",
|
|
172
|
+
severity: "error",
|
|
173
|
+
message: `Complex expression in JSX prop "${propName}" can cause Turbopack runtime errors`,
|
|
174
|
+
code: expression.trim(),
|
|
175
|
+
suggestion: `Extract to variable above JSX: const ${propName}Value = ${expression.trim()};`,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
// Check for optional chaining in computed property access
|
|
179
|
+
if (/\[[^\]]*\?\.[^\]]*\]/.test(expression)) {
|
|
180
|
+
findings.push({
|
|
181
|
+
file: filePath,
|
|
182
|
+
line: i + 1,
|
|
183
|
+
column: columnIndex,
|
|
184
|
+
rule: "turbopack-computed-optional",
|
|
185
|
+
severity: "error",
|
|
186
|
+
message: `Optional chaining in computed property access can cause runtime errors`,
|
|
187
|
+
code: expression.trim(),
|
|
188
|
+
suggestion: `Extract the optional chain: const key = a?.b; then use obj[key]`,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return findings;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Detect optional chaining in callback arguments within JSX
|
|
197
|
+
* Pattern: onClick={() => fn(a?.b?.c)}
|
|
198
|
+
*/
|
|
199
|
+
function detectOptionalChainingInCallbacks(content, filePath) {
|
|
200
|
+
const findings = [];
|
|
201
|
+
const lines = content.split("\n");
|
|
202
|
+
for (let i = 0; i < lines.length; i++) {
|
|
203
|
+
const line = lines[i];
|
|
204
|
+
// Match arrow functions in JSX with function calls containing optional chaining
|
|
205
|
+
// Pattern: () => fn(a?.b?.c) or (e) => fn(e, a?.b?.c)
|
|
206
|
+
const callbackMatches = line.matchAll(/=>\s*\w+\(([^)]+)\)/g);
|
|
207
|
+
for (const match of callbackMatches) {
|
|
208
|
+
const args = match[1];
|
|
209
|
+
const columnIndex = match.index || 0;
|
|
210
|
+
// Check for nested optional chaining in function arguments
|
|
211
|
+
const optionalChainCount = (args.match(/\?\./g) || []).length;
|
|
212
|
+
if (optionalChainCount >= 2) {
|
|
213
|
+
findings.push({
|
|
214
|
+
file: filePath,
|
|
215
|
+
line: i + 1,
|
|
216
|
+
column: columnIndex,
|
|
217
|
+
rule: "turbopack-callback-optional",
|
|
218
|
+
severity: "warning",
|
|
219
|
+
message: `Nested optional chaining in callback argument may cause issues`,
|
|
220
|
+
code: args.trim(),
|
|
221
|
+
suggestion: `Extract to variable inside callback: const value = ${args.split(",")[0].trim()}; fn(value)`,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return findings;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Detect spread with optional chaining in JSX
|
|
230
|
+
* Pattern: {...obj?.nested?.props}
|
|
231
|
+
*/
|
|
232
|
+
function detectOptionalSpread(content, filePath) {
|
|
233
|
+
const findings = [];
|
|
234
|
+
const lines = content.split("\n");
|
|
235
|
+
for (let i = 0; i < lines.length; i++) {
|
|
236
|
+
const line = lines[i];
|
|
237
|
+
// Match spread with optional chaining
|
|
238
|
+
const spreadMatches = line.matchAll(/\{\s*\.\.\.([^}]+\?\.[^}]+)\}/g);
|
|
239
|
+
for (const match of spreadMatches) {
|
|
240
|
+
const expression = match[1];
|
|
241
|
+
const columnIndex = match.index || 0;
|
|
242
|
+
if ((expression.match(/\?\./g) || []).length >= 1) {
|
|
243
|
+
findings.push({
|
|
244
|
+
file: filePath,
|
|
245
|
+
line: i + 1,
|
|
246
|
+
column: columnIndex,
|
|
247
|
+
rule: "turbopack-optional-spread",
|
|
248
|
+
severity: "error",
|
|
249
|
+
message: `Spread with optional chaining can cause runtime errors when undefined`,
|
|
250
|
+
code: `{...${expression.trim()}}`,
|
|
251
|
+
suggestion: `Use conditional: {...(obj?.nested?.props ?? {})} or extract: const props = obj?.nested?.props ?? {}; {...props}`,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return findings;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Detect chained method calls with optional chaining
|
|
260
|
+
* Pattern: ${arr?.filter(...)?.map(...)}
|
|
261
|
+
*/
|
|
262
|
+
function detectChainedMethodsWithOptional(content, filePath) {
|
|
263
|
+
const findings = [];
|
|
264
|
+
const lines = content.split("\n");
|
|
265
|
+
for (let i = 0; i < lines.length; i++) {
|
|
266
|
+
const line = lines[i];
|
|
267
|
+
// Match template literals containing chained optional method calls
|
|
268
|
+
const templateMatches = line.matchAll(/\$\{([^}]*\?\.\w+\([^)]*\)\?\.[^}]+)\}/g);
|
|
269
|
+
for (const match of templateMatches) {
|
|
270
|
+
const expression = match[1];
|
|
271
|
+
const columnIndex = match.index || 0;
|
|
272
|
+
findings.push({
|
|
273
|
+
file: filePath,
|
|
274
|
+
line: i + 1,
|
|
275
|
+
column: columnIndex,
|
|
276
|
+
rule: "turbopack-chained-methods",
|
|
277
|
+
severity: "error",
|
|
278
|
+
message: `Chained optional method calls in template literal can cause Turbopack runtime errors`,
|
|
279
|
+
code: expression.trim(),
|
|
280
|
+
suggestion: `Extract chain: const result = ${expression.trim()}; then use \${result}`,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return findings;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Detect ternary with optional chaining in JSX
|
|
288
|
+
* Pattern: {a?.b ? x : y} where a?.b?.c is used
|
|
289
|
+
*/
|
|
290
|
+
function detectTernaryWithNestedOptional(content, filePath) {
|
|
291
|
+
const findings = [];
|
|
292
|
+
const lines = content.split("\n");
|
|
293
|
+
for (let i = 0; i < lines.length; i++) {
|
|
294
|
+
const line = lines[i];
|
|
295
|
+
// Match ternary expressions with nested optional chaining
|
|
296
|
+
const ternaryMatches = line.matchAll(/\{([^}]*\?\.[^}]*\?\.[^}]*\?[^:}]+:[^}]+)\}/g);
|
|
297
|
+
for (const match of ternaryMatches) {
|
|
298
|
+
const expression = match[1];
|
|
299
|
+
const columnIndex = match.index || 0;
|
|
300
|
+
// Only flag if there's nested optional chaining before the ternary
|
|
301
|
+
const beforeTernary = expression.split("?")[0] + "?." + (expression.split("?.")[1]?.split("?")[0] || "");
|
|
302
|
+
if ((beforeTernary.match(/\?\./g) || []).length >= 2) {
|
|
303
|
+
findings.push({
|
|
304
|
+
file: filePath,
|
|
305
|
+
line: i + 1,
|
|
306
|
+
column: columnIndex,
|
|
307
|
+
rule: "turbopack-ternary-optional",
|
|
308
|
+
severity: "warning",
|
|
309
|
+
message: `Ternary with nested optional chaining may cause Turbopack issues`,
|
|
310
|
+
code: expression.trim().substring(0, 60) + (expression.length > 60 ? "..." : ""),
|
|
311
|
+
suggestion: `Extract condition: const hasValue = Boolean(a?.b?.c); then {hasValue ? x : y}`,
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return findings;
|
|
317
|
+
}
|
|
318
|
+
// =============================================================================
|
|
319
|
+
// MAIN
|
|
320
|
+
// =============================================================================
|
|
321
|
+
function createDivider(length) {
|
|
322
|
+
return "═".repeat(length);
|
|
323
|
+
}
|
|
324
|
+
async function run() {
|
|
325
|
+
const startTime = Date.now();
|
|
326
|
+
const allFindings = [];
|
|
327
|
+
console.log(`\n${console_chars_1.emoji.lightning} TURBOPACK SAFE EXPRESSIONS CHECK`);
|
|
328
|
+
console.log(createDivider(65));
|
|
329
|
+
console.log(`\n${console_chars_1.emoji.info} Detects patterns that cause "_ref is not defined" runtime errors`);
|
|
330
|
+
// Find all files
|
|
331
|
+
const allFiles = [];
|
|
332
|
+
for (const pattern of FILE_PATTERNS) {
|
|
333
|
+
const matches = await (0, glob_1.glob)(pattern, {
|
|
334
|
+
cwd: process.cwd(),
|
|
335
|
+
ignore: EXCLUDE_PATTERNS,
|
|
336
|
+
});
|
|
337
|
+
allFiles.push(...matches);
|
|
338
|
+
}
|
|
339
|
+
const uniqueFiles = [...new Set(allFiles)];
|
|
340
|
+
if (uniqueFiles.length === 0) {
|
|
341
|
+
console.log(`${console_chars_1.emoji.skip} No React/JSX files found`);
|
|
342
|
+
return {
|
|
343
|
+
passed: true,
|
|
344
|
+
findings: [],
|
|
345
|
+
duration: Date.now() - startTime,
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
console.log(`\n${console_chars_1.emoji.search} Scanning ${uniqueFiles.length} files for unsafe patterns...`);
|
|
349
|
+
// Analyze each file
|
|
350
|
+
for (const relativePath of uniqueFiles) {
|
|
351
|
+
const filePath = path.join(process.cwd(), relativePath);
|
|
352
|
+
if (!fs.existsSync(filePath))
|
|
353
|
+
continue;
|
|
354
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
355
|
+
// Skip files with ignore comment
|
|
356
|
+
if (content.includes("turbopack-safe-ignore") || content.includes("preflight-ignore-turbopack")) {
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
allFindings.push(...detectNestedOptionalChaining(content, relativePath));
|
|
360
|
+
allFindings.push(...detectOptionalChainingInJSXProps(content, relativePath));
|
|
361
|
+
allFindings.push(...detectOptionalChainingInCallbacks(content, relativePath));
|
|
362
|
+
allFindings.push(...detectOptionalSpread(content, relativePath));
|
|
363
|
+
allFindings.push(...detectChainedMethodsWithOptional(content, relativePath));
|
|
364
|
+
allFindings.push(...detectTernaryWithNestedOptional(content, relativePath));
|
|
365
|
+
}
|
|
366
|
+
// Group by severity
|
|
367
|
+
const errors = allFindings.filter((f) => f.severity === "error");
|
|
368
|
+
const warnings = allFindings.filter((f) => f.severity === "warning");
|
|
369
|
+
// Group by rule
|
|
370
|
+
const byRule = allFindings.reduce((acc, f) => {
|
|
371
|
+
acc[f.rule] = (acc[f.rule] || 0) + 1;
|
|
372
|
+
return acc;
|
|
373
|
+
}, {});
|
|
374
|
+
// Summary
|
|
375
|
+
console.log(`\n${console_chars_1.emoji.chart} Summary:`);
|
|
376
|
+
console.log(` Files scanned: ${uniqueFiles.length}`);
|
|
377
|
+
console.log(` Errors: ${errors.length} (blocking)`);
|
|
378
|
+
console.log(` Warnings: ${warnings.length}`);
|
|
379
|
+
if (Object.keys(byRule).length > 0) {
|
|
380
|
+
console.log(`\n By rule:`);
|
|
381
|
+
for (const [rule, count] of Object.entries(byRule)) {
|
|
382
|
+
console.log(` ${rule}: ${count}`);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
if (allFindings.length === 0) {
|
|
386
|
+
console.log(`\n${console_chars_1.emoji.success} TURBOPACK SAFE EXPRESSIONS CHECK PASSED`);
|
|
387
|
+
console.log(`\nNo unsafe expression patterns detected.`);
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
// Show errors first
|
|
391
|
+
if (errors.length > 0) {
|
|
392
|
+
console.log(`\n${console_chars_1.emoji.error} BLOCKING: Unsafe Patterns Detected`);
|
|
393
|
+
console.log(`\nThese patterns WILL cause runtime errors with Turbopack:\n`);
|
|
394
|
+
for (const f of errors.slice(0, 15)) {
|
|
395
|
+
console.log(` ${console_chars_1.emoji.error} ${f.file}:${f.line}:${f.column}`);
|
|
396
|
+
console.log(` Rule: ${f.rule}`);
|
|
397
|
+
console.log(` Code: ${f.code}`);
|
|
398
|
+
console.log(` Fix: ${f.suggestion}`);
|
|
399
|
+
console.log();
|
|
400
|
+
}
|
|
401
|
+
if (errors.length > 15) {
|
|
402
|
+
console.log(` ... and ${errors.length - 15} more errors\n`);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
// Show warnings
|
|
406
|
+
if (warnings.length > 0) {
|
|
407
|
+
console.log(`${console_chars_1.emoji.warning} Warnings (${warnings.length}):`);
|
|
408
|
+
for (const f of warnings.slice(0, 5)) {
|
|
409
|
+
console.log(` ${f.file}:${f.line} [${f.rule}]`);
|
|
410
|
+
console.log(` ${f.message}`);
|
|
411
|
+
}
|
|
412
|
+
if (warnings.length > 5) {
|
|
413
|
+
console.log(` ... and ${warnings.length - 5} more warnings`);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
console.log(`\n${console_chars_1.emoji.hint} How to fix:`);
|
|
417
|
+
console.log(` 1. Extract complex expressions to variables BEFORE the JSX return`);
|
|
418
|
+
console.log(` 2. Use simple variable references in template literals: \${value}`);
|
|
419
|
+
console.log(` 3. Avoid nested optional chaining (?.) in JSX expressions`);
|
|
420
|
+
console.log(`\n Example fix:`);
|
|
421
|
+
console.log(` ${console_chars_1.emoji.error} BEFORE: alt={\`Image: \${obj?.nested?.name ?? 'default'}\`}`);
|
|
422
|
+
console.log(` ${console_chars_1.emoji.success} AFTER: const altText = obj?.nested?.name ?? 'default';`);
|
|
423
|
+
console.log(` alt={\`Image: \${altText}\`}`);
|
|
424
|
+
const status = errors.length > 0 ? "FAILED" : "PASSED WITH WARNINGS";
|
|
425
|
+
console.log(`\n${errors.length > 0 ? console_chars_1.emoji.error : console_chars_1.emoji.warning} TURBOPACK SAFE EXPRESSIONS ${status}`);
|
|
426
|
+
}
|
|
427
|
+
return {
|
|
428
|
+
passed: errors.length === 0,
|
|
429
|
+
findings: allFindings.map((f) => ({
|
|
430
|
+
message: `[${f.rule}] ${f.message}`,
|
|
431
|
+
level: f.severity,
|
|
432
|
+
file: f.file,
|
|
433
|
+
line: f.line,
|
|
434
|
+
code: f.rule,
|
|
435
|
+
suggestion: f.suggestion,
|
|
436
|
+
})),
|
|
437
|
+
duration: Date.now() - startTime,
|
|
438
|
+
metadata: {
|
|
439
|
+
filesScanned: uniqueFiles.length,
|
|
440
|
+
errors: errors.length,
|
|
441
|
+
warnings: warnings.length,
|
|
442
|
+
byRule,
|
|
443
|
+
},
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
// Standalone execution
|
|
447
|
+
if (require.main === module) {
|
|
448
|
+
run().then((result) => process.exit(result.passed ? 0 : 1));
|
|
449
|
+
}
|
|
450
|
+
//# sourceMappingURL=turbopack-safe-expressions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turbopack-safe-expressions.js","sourceRoot":"","sources":["../../../src/checks/react/turbopack-safe-expressions.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+UH,kBA+IC;AA5dD,uCAAyB;AACzB,2CAA6B;AAC7B,+BAA4B;AAC5B,6DAAkD;AAElD,iBAAiB;AACJ,QAAA,EAAE,GAAG,kCAAkC,CAAC;AACxC,QAAA,IAAI,GAAG,4BAA4B,CAAC;A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