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