@kubb/ast 5.0.0-alpha.70 → 5.0.0-alpha.72
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/index.cjs +89 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +89 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -279,6 +279,93 @@ function pascalCase(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
|
279
279
|
//#endregion
|
|
280
280
|
//#region ../../internals/utils/src/reserved.ts
|
|
281
281
|
/**
|
|
282
|
+
* JavaScript and Java reserved words.
|
|
283
|
+
* @link https://github.com/jonschlinkert/reserved/blob/master/index.js
|
|
284
|
+
*/
|
|
285
|
+
const reservedWords = new Set([
|
|
286
|
+
"abstract",
|
|
287
|
+
"arguments",
|
|
288
|
+
"boolean",
|
|
289
|
+
"break",
|
|
290
|
+
"byte",
|
|
291
|
+
"case",
|
|
292
|
+
"catch",
|
|
293
|
+
"char",
|
|
294
|
+
"class",
|
|
295
|
+
"const",
|
|
296
|
+
"continue",
|
|
297
|
+
"debugger",
|
|
298
|
+
"default",
|
|
299
|
+
"delete",
|
|
300
|
+
"do",
|
|
301
|
+
"double",
|
|
302
|
+
"else",
|
|
303
|
+
"enum",
|
|
304
|
+
"eval",
|
|
305
|
+
"export",
|
|
306
|
+
"extends",
|
|
307
|
+
"false",
|
|
308
|
+
"final",
|
|
309
|
+
"finally",
|
|
310
|
+
"float",
|
|
311
|
+
"for",
|
|
312
|
+
"function",
|
|
313
|
+
"goto",
|
|
314
|
+
"if",
|
|
315
|
+
"implements",
|
|
316
|
+
"import",
|
|
317
|
+
"in",
|
|
318
|
+
"instanceof",
|
|
319
|
+
"int",
|
|
320
|
+
"interface",
|
|
321
|
+
"let",
|
|
322
|
+
"long",
|
|
323
|
+
"native",
|
|
324
|
+
"new",
|
|
325
|
+
"null",
|
|
326
|
+
"package",
|
|
327
|
+
"private",
|
|
328
|
+
"protected",
|
|
329
|
+
"public",
|
|
330
|
+
"return",
|
|
331
|
+
"short",
|
|
332
|
+
"static",
|
|
333
|
+
"super",
|
|
334
|
+
"switch",
|
|
335
|
+
"synchronized",
|
|
336
|
+
"this",
|
|
337
|
+
"throw",
|
|
338
|
+
"throws",
|
|
339
|
+
"transient",
|
|
340
|
+
"true",
|
|
341
|
+
"try",
|
|
342
|
+
"typeof",
|
|
343
|
+
"var",
|
|
344
|
+
"void",
|
|
345
|
+
"volatile",
|
|
346
|
+
"while",
|
|
347
|
+
"with",
|
|
348
|
+
"yield",
|
|
349
|
+
"Array",
|
|
350
|
+
"Date",
|
|
351
|
+
"hasOwnProperty",
|
|
352
|
+
"Infinity",
|
|
353
|
+
"isFinite",
|
|
354
|
+
"isNaN",
|
|
355
|
+
"isPrototypeOf",
|
|
356
|
+
"length",
|
|
357
|
+
"Math",
|
|
358
|
+
"name",
|
|
359
|
+
"NaN",
|
|
360
|
+
"Number",
|
|
361
|
+
"Object",
|
|
362
|
+
"prototype",
|
|
363
|
+
"String",
|
|
364
|
+
"toString",
|
|
365
|
+
"undefined",
|
|
366
|
+
"valueOf"
|
|
367
|
+
]);
|
|
368
|
+
/**
|
|
282
369
|
* Returns `true` when `name` is a syntactically valid JavaScript variable name.
|
|
283
370
|
*
|
|
284
371
|
* @example
|
|
@@ -289,12 +376,8 @@ function pascalCase(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
|
289
376
|
* ```
|
|
290
377
|
*/
|
|
291
378
|
function isValidVarName(name) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
} catch {
|
|
295
|
-
return false;
|
|
296
|
-
}
|
|
297
|
-
return true;
|
|
379
|
+
if (!name || reservedWords.has(name)) return false;
|
|
380
|
+
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
|
|
298
381
|
}
|
|
299
382
|
//#endregion
|
|
300
383
|
//#region ../../internals/utils/src/string.ts
|