@jsse/eslint-config 0.1.2 → 0.1.3
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/README.md +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +658 -602
- package/dist/index.d.cts +40 -25
- package/dist/index.d.ts +40 -25
- package/dist/index.js +689 -635
- package/package.json +12 -7
package/dist/index.cjs
CHANGED
|
@@ -118,8 +118,8 @@ var require_sort_keys_fix = __commonJS({
|
|
|
118
118
|
const isValidOrder = isValidOrders[order + (insensitive ? "I" : "") + (natural ? "N" : "")];
|
|
119
119
|
const minKeys = Number(options && options.minKeys) || 2;
|
|
120
120
|
let stack = null;
|
|
121
|
-
const SpreadElement = (
|
|
122
|
-
if (
|
|
121
|
+
const SpreadElement = (node) => {
|
|
122
|
+
if (node.parent.type === "ObjectExpression") {
|
|
123
123
|
stack.prevName = null;
|
|
124
124
|
}
|
|
125
125
|
};
|
|
@@ -136,27 +136,27 @@ var require_sort_keys_fix = __commonJS({
|
|
|
136
136
|
"ObjectExpression:exit"() {
|
|
137
137
|
stack = stack.upper;
|
|
138
138
|
},
|
|
139
|
-
Property(
|
|
140
|
-
if (
|
|
139
|
+
Property(node) {
|
|
140
|
+
if (node.parent.type === "ObjectPattern") {
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
|
-
if (
|
|
143
|
+
if (node.parent.properties.length < minKeys) {
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
146
|
const prevName = stack.prevName;
|
|
147
147
|
const prevNode = stack.prevNode;
|
|
148
|
-
const thisName = getPropertyName(
|
|
148
|
+
const thisName = getPropertyName(node);
|
|
149
149
|
if (thisName !== null) {
|
|
150
150
|
stack.prevName = thisName;
|
|
151
|
-
stack.prevNode =
|
|
151
|
+
stack.prevNode = node || prevNode;
|
|
152
152
|
}
|
|
153
153
|
if (prevName === null || thisName === null) {
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
156
156
|
if (!isValidOrder(prevName, thisName)) {
|
|
157
157
|
ctx.report({
|
|
158
|
-
node
|
|
159
|
-
loc:
|
|
158
|
+
node,
|
|
159
|
+
loc: node.key.loc,
|
|
160
160
|
messageId: "sortKeys",
|
|
161
161
|
data: {
|
|
162
162
|
thisName,
|
|
@@ -166,13 +166,13 @@ var require_sort_keys_fix = __commonJS({
|
|
|
166
166
|
natural: natural ? "natural " : ""
|
|
167
167
|
},
|
|
168
168
|
fix(fixer) {
|
|
169
|
-
if (
|
|
169
|
+
if (node.parent.__alreadySorted || node.parent.properties.__alreadySorted) {
|
|
170
170
|
return [];
|
|
171
171
|
}
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
node.parent.__alreadySorted = true;
|
|
173
|
+
node.parent.properties.__alreadySorted = true;
|
|
174
174
|
const src = ctx.getSourceCode();
|
|
175
|
-
const props =
|
|
175
|
+
const props = node.parent.properties;
|
|
176
176
|
const parts = [];
|
|
177
177
|
let part = [];
|
|
178
178
|
props.forEach((p) => {
|
|
@@ -243,21 +243,21 @@ var require_sort_keys_fix = __commonJS({
|
|
|
243
243
|
}
|
|
244
244
|
return fixes;
|
|
245
245
|
};
|
|
246
|
-
var findTokenPrevLine = (
|
|
247
|
-
let t = src.getTokenBefore(
|
|
246
|
+
var findTokenPrevLine = (node, src) => {
|
|
247
|
+
let t = src.getTokenBefore(node);
|
|
248
248
|
while (true) {
|
|
249
|
-
if (!t || t.range[0] <
|
|
249
|
+
if (!t || t.range[0] < node.parent.range[0]) {
|
|
250
250
|
return null;
|
|
251
251
|
}
|
|
252
|
-
if (t.loc.end.line <
|
|
252
|
+
if (t.loc.end.line < node.loc.start.line) {
|
|
253
253
|
return t;
|
|
254
254
|
}
|
|
255
255
|
t = src.getTokenBefore(t);
|
|
256
256
|
}
|
|
257
257
|
};
|
|
258
|
-
var findCommaSameLine = (
|
|
259
|
-
const t = src.getTokenAfter(
|
|
260
|
-
return t && t.value === "," &&
|
|
258
|
+
var findCommaSameLine = (node, src) => {
|
|
259
|
+
const t = src.getTokenAfter(node);
|
|
260
|
+
return t && t.value === "," && node.loc.end.line === t.loc.start.line ? t : null;
|
|
261
261
|
};
|
|
262
262
|
var isValidOrders = {
|
|
263
263
|
asc: (a, b) => a <= b,
|
|
@@ -269,15 +269,15 @@ var require_sort_keys_fix = __commonJS({
|
|
|
269
269
|
descN: (a, b) => isValidOrders.ascN(b, a),
|
|
270
270
|
descIN: (a, b) => isValidOrders.ascIN(b, a)
|
|
271
271
|
};
|
|
272
|
-
var getPropertyName = (
|
|
272
|
+
var getPropertyName = (node) => {
|
|
273
273
|
let prop;
|
|
274
|
-
switch (
|
|
274
|
+
switch (node && node.type) {
|
|
275
275
|
case "Property":
|
|
276
276
|
case "MethodDefinition":
|
|
277
|
-
prop =
|
|
277
|
+
prop = node.key;
|
|
278
278
|
break;
|
|
279
279
|
case "MemberExpression":
|
|
280
|
-
prop =
|
|
280
|
+
prop = node.property;
|
|
281
281
|
break;
|
|
282
282
|
}
|
|
283
283
|
switch (prop && prop.type) {
|
|
@@ -289,12 +289,12 @@ var require_sort_keys_fix = __commonJS({
|
|
|
289
289
|
}
|
|
290
290
|
break;
|
|
291
291
|
case "Identifier":
|
|
292
|
-
if (!
|
|
292
|
+
if (!node.computed) {
|
|
293
293
|
return prop.name;
|
|
294
294
|
}
|
|
295
295
|
break;
|
|
296
296
|
}
|
|
297
|
-
return
|
|
297
|
+
return node.key && node.key.name || null;
|
|
298
298
|
};
|
|
299
299
|
}
|
|
300
300
|
});
|
|
@@ -2345,6 +2345,7 @@ __export(src_exports, {
|
|
|
2345
2345
|
GLOB_TSX: () => GLOB_TSX,
|
|
2346
2346
|
GLOB_YAML: () => GLOB_YAML,
|
|
2347
2347
|
combine: () => combine,
|
|
2348
|
+
combineAsync: () => combineAsync,
|
|
2348
2349
|
comments: () => comments,
|
|
2349
2350
|
default: () => jsse,
|
|
2350
2351
|
eslintConfigPrettierRules: () => eslintConfigPrettierRules,
|
|
@@ -2359,10 +2360,11 @@ __export(src_exports, {
|
|
|
2359
2360
|
jsse: () => jsse,
|
|
2360
2361
|
jsseReact: () => jsseReact,
|
|
2361
2362
|
jssestd: () => jssestd,
|
|
2362
|
-
|
|
2363
|
+
n: () => n,
|
|
2363
2364
|
parserJsonc: () => import_jsonc_eslint_parser.default,
|
|
2364
2365
|
parserTs: () => parserTs,
|
|
2365
2366
|
perfectionist: () => perfectionist,
|
|
2367
|
+
pluginAntfu: () => import_eslint_plugin_antfu.default,
|
|
2366
2368
|
pluginEslintComments: () => import_eslint_plugin_eslint_comments.default,
|
|
2367
2369
|
pluginImport: () => pluginImport,
|
|
2368
2370
|
pluginJsdoc: () => import_eslint_plugin_jsdoc.default,
|
|
@@ -2398,42 +2400,41 @@ module.exports = __toCommonJS(src_exports);
|
|
|
2398
2400
|
var import_eslint_plugin = __toESM(require("@stylistic/eslint-plugin"), 1);
|
|
2399
2401
|
var import_eslint_plugin2 = __toESM(require("@typescript-eslint/eslint-plugin"), 1);
|
|
2400
2402
|
var parserTs = __toESM(require("@typescript-eslint/parser"), 1);
|
|
2403
|
+
var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
|
|
2401
2404
|
var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
|
|
2402
2405
|
var pluginImport = __toESM(require("eslint-plugin-i"), 1);
|
|
2403
2406
|
var import_eslint_plugin_jsdoc = __toESM(require("eslint-plugin-jsdoc"), 1);
|
|
2404
2407
|
var pluginJsonc = __toESM(require("eslint-plugin-jsonc"), 1);
|
|
2408
|
+
var import_eslint_plugin_markdown = __toESM(require("eslint-plugin-markdown"), 1);
|
|
2405
2409
|
var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
|
|
2406
2410
|
var import_eslint_plugin_no_only_tests = __toESM(require("eslint-plugin-no-only-tests"), 1);
|
|
2411
|
+
var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
|
|
2407
2412
|
var import_eslint_plugin_react = __toESM(require("eslint-plugin-react"), 1);
|
|
2408
2413
|
var import_eslint_plugin_react_hooks = __toESM(require("eslint-plugin-react-hooks"), 1);
|
|
2409
2414
|
var pluginReactRefresh = __toESM(require("eslint-plugin-react-refresh"), 1);
|
|
2410
2415
|
var pluginSortKeys = __toESM(require_eslint_plugin_sort_keys(), 1);
|
|
2416
|
+
var import_eslint_plugin_tailwindcss = __toESM(require("eslint-plugin-tailwindcss"), 1);
|
|
2411
2417
|
var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
2412
2418
|
var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
|
|
2413
|
-
var import_eslint_plugin_tailwindcss = __toESM(require("eslint-plugin-tailwindcss"), 1);
|
|
2414
2419
|
var import_eslint_plugin_vitest = __toESM(require("eslint-plugin-vitest"), 1);
|
|
2415
2420
|
var import_jsonc_eslint_parser = __toESM(require("jsonc-eslint-parser"), 1);
|
|
2416
|
-
var import_eslint_plugin_markdown = __toESM(require("eslint-plugin-markdown"), 1);
|
|
2417
|
-
var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
|
|
2418
2421
|
|
|
2419
2422
|
// src/configs/comments.ts
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
"eslint-comments/no-unused-enable": "error"
|
|
2433
|
-
}
|
|
2423
|
+
var comments = async () => [
|
|
2424
|
+
{
|
|
2425
|
+
name: "jsse:eslint-comments",
|
|
2426
|
+
plugins: {
|
|
2427
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
2428
|
+
"eslint-comments": import_eslint_plugin_eslint_comments.default
|
|
2429
|
+
},
|
|
2430
|
+
rules: {
|
|
2431
|
+
"eslint-comments/no-aggregating-enable": "error",
|
|
2432
|
+
"eslint-comments/no-duplicate-disable": "error",
|
|
2433
|
+
"eslint-comments/no-unlimited-disable": "error",
|
|
2434
|
+
"eslint-comments/no-unused-enable": "error"
|
|
2434
2435
|
}
|
|
2435
|
-
|
|
2436
|
-
|
|
2436
|
+
}
|
|
2437
|
+
];
|
|
2437
2438
|
|
|
2438
2439
|
// src/globs.ts
|
|
2439
2440
|
var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
@@ -2504,17 +2505,17 @@ var GLOB_EXCLUDE = [
|
|
|
2504
2505
|
];
|
|
2505
2506
|
|
|
2506
2507
|
// src/configs/ignores.ts
|
|
2507
|
-
|
|
2508
|
+
var ignores = async () => {
|
|
2508
2509
|
return [
|
|
2509
2510
|
{
|
|
2510
2511
|
ignores: GLOB_EXCLUDE
|
|
2511
2512
|
}
|
|
2512
2513
|
];
|
|
2513
|
-
}
|
|
2514
|
+
};
|
|
2514
2515
|
|
|
2515
2516
|
// src/configs/imports.ts
|
|
2516
|
-
|
|
2517
|
-
const { stylistic: stylistic2 = true } = options;
|
|
2517
|
+
var imports = async (options) => {
|
|
2518
|
+
const { stylistic: stylistic2 = true } = options ?? {};
|
|
2518
2519
|
return [
|
|
2519
2520
|
{
|
|
2520
2521
|
name: "jsse:imports",
|
|
@@ -2539,13 +2540,17 @@ function imports(options = {}) {
|
|
|
2539
2540
|
}
|
|
2540
2541
|
}
|
|
2541
2542
|
];
|
|
2542
|
-
}
|
|
2543
|
+
};
|
|
2543
2544
|
|
|
2544
2545
|
// src/configs/javascript.ts
|
|
2545
2546
|
var import_js = __toESM(require("@eslint/js"), 1);
|
|
2546
2547
|
var import_globals = __toESM(require_globals2(), 1);
|
|
2547
|
-
|
|
2548
|
-
const {
|
|
2548
|
+
var javascript = async (options) => {
|
|
2549
|
+
const {
|
|
2550
|
+
isInEditor: isInEditor2 = false,
|
|
2551
|
+
overrides = {},
|
|
2552
|
+
reportUnusedDisableDirectives = true
|
|
2553
|
+
} = options ?? {};
|
|
2549
2554
|
return [
|
|
2550
2555
|
{
|
|
2551
2556
|
languageOptions: {
|
|
@@ -2568,7 +2573,7 @@ function javascript(options = {}) {
|
|
|
2568
2573
|
sourceType: "module"
|
|
2569
2574
|
},
|
|
2570
2575
|
linterOptions: {
|
|
2571
|
-
reportUnusedDisableDirectives
|
|
2576
|
+
reportUnusedDisableDirectives
|
|
2572
2577
|
},
|
|
2573
2578
|
name: "jsse:javascript",
|
|
2574
2579
|
plugins: {
|
|
@@ -2796,10 +2801,10 @@ function javascript(options = {}) {
|
|
|
2796
2801
|
}
|
|
2797
2802
|
}
|
|
2798
2803
|
];
|
|
2799
|
-
}
|
|
2804
|
+
};
|
|
2800
2805
|
|
|
2801
2806
|
// src/configs/jsdoc.ts
|
|
2802
|
-
|
|
2807
|
+
var jsdoc = async () => {
|
|
2803
2808
|
return [
|
|
2804
2809
|
{
|
|
2805
2810
|
name: "jsse:jsdoc",
|
|
@@ -2828,11 +2833,11 @@ function jsdoc() {
|
|
|
2828
2833
|
}
|
|
2829
2834
|
}
|
|
2830
2835
|
];
|
|
2831
|
-
}
|
|
2836
|
+
};
|
|
2832
2837
|
|
|
2833
2838
|
// src/configs/jsonc.ts
|
|
2834
|
-
|
|
2835
|
-
const { overrides = {}, stylistic: stylistic2 = true } = options;
|
|
2839
|
+
var jsonc = async (options) => {
|
|
2840
|
+
const { overrides = {}, stylistic: stylistic2 = true } = options ?? {};
|
|
2836
2841
|
const { indent = 2 } = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
2837
2842
|
return [
|
|
2838
2843
|
{
|
|
@@ -2900,30 +2905,42 @@ function jsonc(options = {}) {
|
|
|
2900
2905
|
}
|
|
2901
2906
|
}
|
|
2902
2907
|
];
|
|
2903
|
-
}
|
|
2908
|
+
};
|
|
2904
2909
|
|
|
2905
2910
|
// src/configs/n.ts
|
|
2906
|
-
|
|
2911
|
+
var n = async () => {
|
|
2907
2912
|
return [
|
|
2908
2913
|
{
|
|
2909
2914
|
name: "jsse:n",
|
|
2910
2915
|
plugins: {
|
|
2911
2916
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
2912
|
-
|
|
2917
|
+
n: import_eslint_plugin_n.default
|
|
2913
2918
|
},
|
|
2914
2919
|
rules: {
|
|
2915
|
-
"
|
|
2916
|
-
"
|
|
2917
|
-
"
|
|
2918
|
-
"
|
|
2919
|
-
"
|
|
2920
|
-
"
|
|
2921
|
-
"
|
|
2922
|
-
"
|
|
2920
|
+
"n/handle-callback-err": ["error", "^(err|error)$"],
|
|
2921
|
+
"n/no-deprecated-api": "error",
|
|
2922
|
+
"n/no-exports-assign": "error",
|
|
2923
|
+
"n/no-new-require": "error",
|
|
2924
|
+
"n/no-path-concat": "error",
|
|
2925
|
+
"n/prefer-global/buffer": ["error", "never"],
|
|
2926
|
+
"n/prefer-global/process": ["error", "never"],
|
|
2927
|
+
"n/process-exit-as-throw": "error"
|
|
2923
2928
|
}
|
|
2924
2929
|
}
|
|
2925
2930
|
];
|
|
2926
|
-
}
|
|
2931
|
+
};
|
|
2932
|
+
|
|
2933
|
+
// src/configs/perfectionist.ts
|
|
2934
|
+
var perfectionist = async () => {
|
|
2935
|
+
return [
|
|
2936
|
+
{
|
|
2937
|
+
name: "jsse:perfectionist",
|
|
2938
|
+
plugins: {
|
|
2939
|
+
perfectionist: import_eslint_plugin_perfectionist.default
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
];
|
|
2943
|
+
};
|
|
2927
2944
|
|
|
2928
2945
|
// src/configs/prettier.ts
|
|
2929
2946
|
function eslintConfigPrettierRules() {
|
|
@@ -3040,16 +3057,14 @@ function eslintConfigPrettierRules() {
|
|
|
3040
3057
|
"yield-star-spacing": "off"
|
|
3041
3058
|
};
|
|
3042
3059
|
}
|
|
3043
|
-
|
|
3060
|
+
var prettier = async () => {
|
|
3044
3061
|
return [
|
|
3045
3062
|
{
|
|
3046
3063
|
name: "jsse:prettier",
|
|
3047
|
-
rules:
|
|
3048
|
-
...eslintConfigPrettierRules()
|
|
3049
|
-
}
|
|
3064
|
+
rules: eslintConfigPrettierRules()
|
|
3050
3065
|
}
|
|
3051
3066
|
];
|
|
3052
|
-
}
|
|
3067
|
+
};
|
|
3053
3068
|
|
|
3054
3069
|
// src/configs/ts/typescript-language-options.ts
|
|
3055
3070
|
var import_node_process = __toESM(require("process"), 1);
|
|
@@ -3308,7 +3323,7 @@ function reactRecomendedRules() {
|
|
|
3308
3323
|
"react/require-render-return": 2
|
|
3309
3324
|
};
|
|
3310
3325
|
}
|
|
3311
|
-
|
|
3326
|
+
var react = async (options) => {
|
|
3312
3327
|
const {
|
|
3313
3328
|
componentExts,
|
|
3314
3329
|
parserOptions = {},
|
|
@@ -3353,10 +3368,10 @@ function react(options) {
|
|
|
3353
3368
|
config.push(...reactRefreshFlatConfigs());
|
|
3354
3369
|
}
|
|
3355
3370
|
return config;
|
|
3356
|
-
}
|
|
3371
|
+
};
|
|
3357
3372
|
|
|
3358
3373
|
// src/configs/sort.ts
|
|
3359
|
-
|
|
3374
|
+
var sortPackageJson = async () => {
|
|
3360
3375
|
return [
|
|
3361
3376
|
{
|
|
3362
3377
|
files: ["**/package.json"],
|
|
@@ -3439,8 +3454,8 @@ function sortPackageJson() {
|
|
|
3439
3454
|
}
|
|
3440
3455
|
}
|
|
3441
3456
|
];
|
|
3442
|
-
}
|
|
3443
|
-
|
|
3457
|
+
};
|
|
3458
|
+
var sortTsconfig = async () => {
|
|
3444
3459
|
return [
|
|
3445
3460
|
{
|
|
3446
3461
|
files: ["**/tsconfig.json", "**/tsconfig.*.json"],
|
|
@@ -3564,7 +3579,7 @@ function sortTsconfig() {
|
|
|
3564
3579
|
}
|
|
3565
3580
|
}
|
|
3566
3581
|
];
|
|
3567
|
-
}
|
|
3582
|
+
};
|
|
3568
3583
|
|
|
3569
3584
|
// src/utils.ts
|
|
3570
3585
|
var import_node_process2 = __toESM(require("process"), 1);
|
|
@@ -3573,6 +3588,12 @@ function combine(...configs) {
|
|
|
3573
3588
|
(config) => Array.isArray(config) ? config : [config]
|
|
3574
3589
|
);
|
|
3575
3590
|
}
|
|
3591
|
+
async function combineAsync(...configs) {
|
|
3592
|
+
const resolved = await Promise.all(configs);
|
|
3593
|
+
return resolved.flatMap(
|
|
3594
|
+
(config) => Array.isArray(config) ? config : [config]
|
|
3595
|
+
);
|
|
3596
|
+
}
|
|
3576
3597
|
function renameRules(rules, from, to) {
|
|
3577
3598
|
if (from === to) {
|
|
3578
3599
|
return rules;
|
|
@@ -3598,7 +3619,7 @@ function isInEditor() {
|
|
|
3598
3619
|
}
|
|
3599
3620
|
|
|
3600
3621
|
// src/configs/test.ts
|
|
3601
|
-
|
|
3622
|
+
var test = async (options = {}) => {
|
|
3602
3623
|
const { isInEditor: isInEditor2 = false, overrides = {} } = options;
|
|
3603
3624
|
return [
|
|
3604
3625
|
{
|
|
@@ -3625,7 +3646,7 @@ function test(options = {}) {
|
|
|
3625
3646
|
}
|
|
3626
3647
|
}
|
|
3627
3648
|
];
|
|
3628
|
-
}
|
|
3649
|
+
};
|
|
3629
3650
|
|
|
3630
3651
|
// src/configs/ts/typescript-rules.ts
|
|
3631
3652
|
function typescriptRulesTypeAware() {
|
|
@@ -4152,7 +4173,7 @@ function unicornOff() {
|
|
|
4152
4173
|
// Super insanely annoying rule
|
|
4153
4174
|
};
|
|
4154
4175
|
}
|
|
4155
|
-
|
|
4176
|
+
var unicorn = async () => {
|
|
4156
4177
|
return [
|
|
4157
4178
|
{
|
|
4158
4179
|
name: "jsse:unicorn",
|
|
@@ -4233,19 +4254,7 @@ function unicorn() {
|
|
|
4233
4254
|
}
|
|
4234
4255
|
}
|
|
4235
4256
|
];
|
|
4236
|
-
}
|
|
4237
|
-
|
|
4238
|
-
// src/configs/perfectionist.ts
|
|
4239
|
-
function perfectionist() {
|
|
4240
|
-
return [
|
|
4241
|
-
{
|
|
4242
|
-
name: "jsse:perfectionist",
|
|
4243
|
-
plugins: {
|
|
4244
|
-
perfectionist: import_eslint_plugin_perfectionist.default
|
|
4245
|
-
}
|
|
4246
|
-
}
|
|
4247
|
-
];
|
|
4248
|
-
}
|
|
4257
|
+
};
|
|
4249
4258
|
|
|
4250
4259
|
// src/factory.ts
|
|
4251
4260
|
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
@@ -4503,8 +4512,8 @@ var Position = function Position2(line, col) {
|
|
|
4503
4512
|
this.line = line;
|
|
4504
4513
|
this.column = col;
|
|
4505
4514
|
};
|
|
4506
|
-
Position.prototype.offset = function offset(
|
|
4507
|
-
return new Position(this.line, this.column +
|
|
4515
|
+
Position.prototype.offset = function offset(n2) {
|
|
4516
|
+
return new Position(this.line, this.column + n2);
|
|
4508
4517
|
};
|
|
4509
4518
|
var SourceLocation = function SourceLocation2(p, start, end) {
|
|
4510
4519
|
this.start = start;
|
|
@@ -4740,9 +4749,9 @@ var Parser = function Parser2(options, input, startPos) {
|
|
|
4740
4749
|
};
|
|
4741
4750
|
var prototypeAccessors = { inFunction: { configurable: true }, inGenerator: { configurable: true }, inAsync: { configurable: true }, canAwait: { configurable: true }, allowSuper: { configurable: true }, allowDirectSuper: { configurable: true }, treatFunctionsAsVar: { configurable: true }, allowNewDotTarget: { configurable: true }, inClassStaticBlock: { configurable: true } };
|
|
4742
4751
|
Parser.prototype.parse = function parse() {
|
|
4743
|
-
var
|
|
4752
|
+
var node = this.options.program || this.startNode();
|
|
4744
4753
|
this.nextToken();
|
|
4745
|
-
return this.parseTopLevel(
|
|
4754
|
+
return this.parseTopLevel(node);
|
|
4746
4755
|
};
|
|
4747
4756
|
prototypeAccessors.inFunction.get = function() {
|
|
4748
4757
|
return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0;
|
|
@@ -4937,14 +4946,14 @@ pp$9.isSimpleAssignTarget = function(expr) {
|
|
|
4937
4946
|
return expr.type === "Identifier" || expr.type === "MemberExpression";
|
|
4938
4947
|
};
|
|
4939
4948
|
var pp$8 = Parser.prototype;
|
|
4940
|
-
pp$8.parseTopLevel = function(
|
|
4949
|
+
pp$8.parseTopLevel = function(node) {
|
|
4941
4950
|
var exports2 = /* @__PURE__ */ Object.create(null);
|
|
4942
|
-
if (!
|
|
4943
|
-
|
|
4951
|
+
if (!node.body) {
|
|
4952
|
+
node.body = [];
|
|
4944
4953
|
}
|
|
4945
4954
|
while (this.type !== types$1.eof) {
|
|
4946
4955
|
var stmt = this.parseStatement(null, true, exports2);
|
|
4947
|
-
|
|
4956
|
+
node.body.push(stmt);
|
|
4948
4957
|
}
|
|
4949
4958
|
if (this.inModule) {
|
|
4950
4959
|
for (var i = 0, list = Object.keys(this.undefinedExports); i < list.length; i += 1) {
|
|
@@ -4952,10 +4961,10 @@ pp$8.parseTopLevel = function(node2) {
|
|
|
4952
4961
|
this.raiseRecoverable(this.undefinedExports[name].start, "Export '" + name + "' is not defined");
|
|
4953
4962
|
}
|
|
4954
4963
|
}
|
|
4955
|
-
this.adaptDirectivePrologue(
|
|
4964
|
+
this.adaptDirectivePrologue(node.body);
|
|
4956
4965
|
this.next();
|
|
4957
|
-
|
|
4958
|
-
return this.finishNode(
|
|
4966
|
+
node.sourceType = this.options.sourceType;
|
|
4967
|
+
return this.finishNode(node, "Program");
|
|
4959
4968
|
};
|
|
4960
4969
|
var loopLabel = { kind: "loop" };
|
|
4961
4970
|
var switchLabel = { kind: "switch" };
|
|
@@ -5000,7 +5009,7 @@ pp$8.isAsyncFunction = function() {
|
|
|
5000
5009
|
return !lineBreak.test(this.input.slice(this.pos, next)) && this.input.slice(next, next + 8) === "function" && (next + 8 === this.input.length || !(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 55295 && after < 56320));
|
|
5001
5010
|
};
|
|
5002
5011
|
pp$8.parseStatement = function(context, topLevel, exports2) {
|
|
5003
|
-
var starttype = this.type,
|
|
5012
|
+
var starttype = this.type, node = this.startNode(), kind;
|
|
5004
5013
|
if (this.isLet(context)) {
|
|
5005
5014
|
starttype = types$1._var;
|
|
5006
5015
|
kind = "let";
|
|
@@ -5008,48 +5017,48 @@ pp$8.parseStatement = function(context, topLevel, exports2) {
|
|
|
5008
5017
|
switch (starttype) {
|
|
5009
5018
|
case types$1._break:
|
|
5010
5019
|
case types$1._continue:
|
|
5011
|
-
return this.parseBreakContinueStatement(
|
|
5020
|
+
return this.parseBreakContinueStatement(node, starttype.keyword);
|
|
5012
5021
|
case types$1._debugger:
|
|
5013
|
-
return this.parseDebuggerStatement(
|
|
5022
|
+
return this.parseDebuggerStatement(node);
|
|
5014
5023
|
case types$1._do:
|
|
5015
|
-
return this.parseDoStatement(
|
|
5024
|
+
return this.parseDoStatement(node);
|
|
5016
5025
|
case types$1._for:
|
|
5017
|
-
return this.parseForStatement(
|
|
5026
|
+
return this.parseForStatement(node);
|
|
5018
5027
|
case types$1._function:
|
|
5019
5028
|
if (context && (this.strict || context !== "if" && context !== "label") && this.options.ecmaVersion >= 6) {
|
|
5020
5029
|
this.unexpected();
|
|
5021
5030
|
}
|
|
5022
|
-
return this.parseFunctionStatement(
|
|
5031
|
+
return this.parseFunctionStatement(node, false, !context);
|
|
5023
5032
|
case types$1._class:
|
|
5024
5033
|
if (context) {
|
|
5025
5034
|
this.unexpected();
|
|
5026
5035
|
}
|
|
5027
|
-
return this.parseClass(
|
|
5036
|
+
return this.parseClass(node, true);
|
|
5028
5037
|
case types$1._if:
|
|
5029
|
-
return this.parseIfStatement(
|
|
5038
|
+
return this.parseIfStatement(node);
|
|
5030
5039
|
case types$1._return:
|
|
5031
|
-
return this.parseReturnStatement(
|
|
5040
|
+
return this.parseReturnStatement(node);
|
|
5032
5041
|
case types$1._switch:
|
|
5033
|
-
return this.parseSwitchStatement(
|
|
5042
|
+
return this.parseSwitchStatement(node);
|
|
5034
5043
|
case types$1._throw:
|
|
5035
|
-
return this.parseThrowStatement(
|
|
5044
|
+
return this.parseThrowStatement(node);
|
|
5036
5045
|
case types$1._try:
|
|
5037
|
-
return this.parseTryStatement(
|
|
5046
|
+
return this.parseTryStatement(node);
|
|
5038
5047
|
case types$1._const:
|
|
5039
5048
|
case types$1._var:
|
|
5040
5049
|
kind = kind || this.value;
|
|
5041
5050
|
if (context && kind !== "var") {
|
|
5042
5051
|
this.unexpected();
|
|
5043
5052
|
}
|
|
5044
|
-
return this.parseVarStatement(
|
|
5053
|
+
return this.parseVarStatement(node, kind);
|
|
5045
5054
|
case types$1._while:
|
|
5046
|
-
return this.parseWhileStatement(
|
|
5055
|
+
return this.parseWhileStatement(node);
|
|
5047
5056
|
case types$1._with:
|
|
5048
|
-
return this.parseWithStatement(
|
|
5057
|
+
return this.parseWithStatement(node);
|
|
5049
5058
|
case types$1.braceL:
|
|
5050
|
-
return this.parseBlock(true,
|
|
5059
|
+
return this.parseBlock(true, node);
|
|
5051
5060
|
case types$1.semi:
|
|
5052
|
-
return this.parseEmptyStatement(
|
|
5061
|
+
return this.parseEmptyStatement(node);
|
|
5053
5062
|
case types$1._export:
|
|
5054
5063
|
case types$1._import:
|
|
5055
5064
|
if (this.options.ecmaVersion > 10 && starttype === types$1._import) {
|
|
@@ -5057,7 +5066,7 @@ pp$8.parseStatement = function(context, topLevel, exports2) {
|
|
|
5057
5066
|
var skip = skipWhiteSpace.exec(this.input);
|
|
5058
5067
|
var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
|
|
5059
5068
|
if (nextCh === 40 || nextCh === 46) {
|
|
5060
|
-
return this.parseExpressionStatement(
|
|
5069
|
+
return this.parseExpressionStatement(node, this.parseExpression());
|
|
5061
5070
|
}
|
|
5062
5071
|
}
|
|
5063
5072
|
if (!this.options.allowImportExportEverywhere) {
|
|
@@ -5068,71 +5077,71 @@ pp$8.parseStatement = function(context, topLevel, exports2) {
|
|
|
5068
5077
|
this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'");
|
|
5069
5078
|
}
|
|
5070
5079
|
}
|
|
5071
|
-
return starttype === types$1._import ? this.parseImport(
|
|
5080
|
+
return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports2);
|
|
5072
5081
|
default:
|
|
5073
5082
|
if (this.isAsyncFunction()) {
|
|
5074
5083
|
if (context) {
|
|
5075
5084
|
this.unexpected();
|
|
5076
5085
|
}
|
|
5077
5086
|
this.next();
|
|
5078
|
-
return this.parseFunctionStatement(
|
|
5087
|
+
return this.parseFunctionStatement(node, true, !context);
|
|
5079
5088
|
}
|
|
5080
5089
|
var maybeName = this.value, expr = this.parseExpression();
|
|
5081
5090
|
if (starttype === types$1.name && expr.type === "Identifier" && this.eat(types$1.colon)) {
|
|
5082
|
-
return this.parseLabeledStatement(
|
|
5091
|
+
return this.parseLabeledStatement(node, maybeName, expr, context);
|
|
5083
5092
|
} else {
|
|
5084
|
-
return this.parseExpressionStatement(
|
|
5093
|
+
return this.parseExpressionStatement(node, expr);
|
|
5085
5094
|
}
|
|
5086
5095
|
}
|
|
5087
5096
|
};
|
|
5088
|
-
pp$8.parseBreakContinueStatement = function(
|
|
5097
|
+
pp$8.parseBreakContinueStatement = function(node, keyword) {
|
|
5089
5098
|
var isBreak = keyword === "break";
|
|
5090
5099
|
this.next();
|
|
5091
5100
|
if (this.eat(types$1.semi) || this.insertSemicolon()) {
|
|
5092
|
-
|
|
5101
|
+
node.label = null;
|
|
5093
5102
|
} else if (this.type !== types$1.name) {
|
|
5094
5103
|
this.unexpected();
|
|
5095
5104
|
} else {
|
|
5096
|
-
|
|
5105
|
+
node.label = this.parseIdent();
|
|
5097
5106
|
this.semicolon();
|
|
5098
5107
|
}
|
|
5099
5108
|
var i = 0;
|
|
5100
5109
|
for (; i < this.labels.length; ++i) {
|
|
5101
5110
|
var lab = this.labels[i];
|
|
5102
|
-
if (
|
|
5111
|
+
if (node.label == null || lab.name === node.label.name) {
|
|
5103
5112
|
if (lab.kind != null && (isBreak || lab.kind === "loop")) {
|
|
5104
5113
|
break;
|
|
5105
5114
|
}
|
|
5106
|
-
if (
|
|
5115
|
+
if (node.label && isBreak) {
|
|
5107
5116
|
break;
|
|
5108
5117
|
}
|
|
5109
5118
|
}
|
|
5110
5119
|
}
|
|
5111
5120
|
if (i === this.labels.length) {
|
|
5112
|
-
this.raise(
|
|
5121
|
+
this.raise(node.start, "Unsyntactic " + keyword);
|
|
5113
5122
|
}
|
|
5114
|
-
return this.finishNode(
|
|
5123
|
+
return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
|
|
5115
5124
|
};
|
|
5116
|
-
pp$8.parseDebuggerStatement = function(
|
|
5125
|
+
pp$8.parseDebuggerStatement = function(node) {
|
|
5117
5126
|
this.next();
|
|
5118
5127
|
this.semicolon();
|
|
5119
|
-
return this.finishNode(
|
|
5128
|
+
return this.finishNode(node, "DebuggerStatement");
|
|
5120
5129
|
};
|
|
5121
|
-
pp$8.parseDoStatement = function(
|
|
5130
|
+
pp$8.parseDoStatement = function(node) {
|
|
5122
5131
|
this.next();
|
|
5123
5132
|
this.labels.push(loopLabel);
|
|
5124
|
-
|
|
5133
|
+
node.body = this.parseStatement("do");
|
|
5125
5134
|
this.labels.pop();
|
|
5126
5135
|
this.expect(types$1._while);
|
|
5127
|
-
|
|
5136
|
+
node.test = this.parseParenExpression();
|
|
5128
5137
|
if (this.options.ecmaVersion >= 6) {
|
|
5129
5138
|
this.eat(types$1.semi);
|
|
5130
5139
|
} else {
|
|
5131
5140
|
this.semicolon();
|
|
5132
5141
|
}
|
|
5133
|
-
return this.finishNode(
|
|
5142
|
+
return this.finishNode(node, "DoWhileStatement");
|
|
5134
5143
|
};
|
|
5135
|
-
pp$8.parseForStatement = function(
|
|
5144
|
+
pp$8.parseForStatement = function(node) {
|
|
5136
5145
|
this.next();
|
|
5137
5146
|
var awaitAt = this.options.ecmaVersion >= 9 && this.canAwait && this.eatContextual("await") ? this.lastTokStart : -1;
|
|
5138
5147
|
this.labels.push(loopLabel);
|
|
@@ -5142,7 +5151,7 @@ pp$8.parseForStatement = function(node2) {
|
|
|
5142
5151
|
if (awaitAt > -1) {
|
|
5143
5152
|
this.unexpected(awaitAt);
|
|
5144
5153
|
}
|
|
5145
|
-
return this.parseFor(
|
|
5154
|
+
return this.parseFor(node, null);
|
|
5146
5155
|
}
|
|
5147
5156
|
var isLet = this.isLet();
|
|
5148
5157
|
if (this.type === types$1._var || this.type === types$1._const || isLet) {
|
|
@@ -5157,15 +5166,15 @@ pp$8.parseForStatement = function(node2) {
|
|
|
5157
5166
|
this.unexpected(awaitAt);
|
|
5158
5167
|
}
|
|
5159
5168
|
} else {
|
|
5160
|
-
|
|
5169
|
+
node.await = awaitAt > -1;
|
|
5161
5170
|
}
|
|
5162
5171
|
}
|
|
5163
|
-
return this.parseForIn(
|
|
5172
|
+
return this.parseForIn(node, init$1);
|
|
5164
5173
|
}
|
|
5165
5174
|
if (awaitAt > -1) {
|
|
5166
5175
|
this.unexpected(awaitAt);
|
|
5167
5176
|
}
|
|
5168
|
-
return this.parseFor(
|
|
5177
|
+
return this.parseFor(node, init$1);
|
|
5169
5178
|
}
|
|
5170
5179
|
var startsWithLet = this.isContextual("let"), isForOf = false;
|
|
5171
5180
|
var refDestructuringErrors = new DestructuringErrors();
|
|
@@ -5177,7 +5186,7 @@ pp$8.parseForStatement = function(node2) {
|
|
|
5177
5186
|
this.unexpected(awaitAt);
|
|
5178
5187
|
}
|
|
5179
5188
|
} else {
|
|
5180
|
-
|
|
5189
|
+
node.await = awaitAt > -1;
|
|
5181
5190
|
}
|
|
5182
5191
|
}
|
|
5183
5192
|
if (startsWithLet && isForOf) {
|
|
@@ -5185,43 +5194,43 @@ pp$8.parseForStatement = function(node2) {
|
|
|
5185
5194
|
}
|
|
5186
5195
|
this.toAssignable(init, false, refDestructuringErrors);
|
|
5187
5196
|
this.checkLValPattern(init);
|
|
5188
|
-
return this.parseForIn(
|
|
5197
|
+
return this.parseForIn(node, init);
|
|
5189
5198
|
} else {
|
|
5190
5199
|
this.checkExpressionErrors(refDestructuringErrors, true);
|
|
5191
5200
|
}
|
|
5192
5201
|
if (awaitAt > -1) {
|
|
5193
5202
|
this.unexpected(awaitAt);
|
|
5194
5203
|
}
|
|
5195
|
-
return this.parseFor(
|
|
5204
|
+
return this.parseFor(node, init);
|
|
5196
5205
|
};
|
|
5197
|
-
pp$8.parseFunctionStatement = function(
|
|
5206
|
+
pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) {
|
|
5198
5207
|
this.next();
|
|
5199
|
-
return this.parseFunction(
|
|
5208
|
+
return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync);
|
|
5200
5209
|
};
|
|
5201
|
-
pp$8.parseIfStatement = function(
|
|
5210
|
+
pp$8.parseIfStatement = function(node) {
|
|
5202
5211
|
this.next();
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
return this.finishNode(
|
|
5212
|
+
node.test = this.parseParenExpression();
|
|
5213
|
+
node.consequent = this.parseStatement("if");
|
|
5214
|
+
node.alternate = this.eat(types$1._else) ? this.parseStatement("if") : null;
|
|
5215
|
+
return this.finishNode(node, "IfStatement");
|
|
5207
5216
|
};
|
|
5208
|
-
pp$8.parseReturnStatement = function(
|
|
5217
|
+
pp$8.parseReturnStatement = function(node) {
|
|
5209
5218
|
if (!this.inFunction && !this.options.allowReturnOutsideFunction) {
|
|
5210
5219
|
this.raise(this.start, "'return' outside of function");
|
|
5211
5220
|
}
|
|
5212
5221
|
this.next();
|
|
5213
5222
|
if (this.eat(types$1.semi) || this.insertSemicolon()) {
|
|
5214
|
-
|
|
5223
|
+
node.argument = null;
|
|
5215
5224
|
} else {
|
|
5216
|
-
|
|
5225
|
+
node.argument = this.parseExpression();
|
|
5217
5226
|
this.semicolon();
|
|
5218
5227
|
}
|
|
5219
|
-
return this.finishNode(
|
|
5228
|
+
return this.finishNode(node, "ReturnStatement");
|
|
5220
5229
|
};
|
|
5221
|
-
pp$8.parseSwitchStatement = function(
|
|
5230
|
+
pp$8.parseSwitchStatement = function(node) {
|
|
5222
5231
|
this.next();
|
|
5223
|
-
|
|
5224
|
-
|
|
5232
|
+
node.discriminant = this.parseParenExpression();
|
|
5233
|
+
node.cases = [];
|
|
5225
5234
|
this.expect(types$1.braceL);
|
|
5226
5235
|
this.labels.push(switchLabel);
|
|
5227
5236
|
this.enterScope(0);
|
|
@@ -5232,7 +5241,7 @@ pp$8.parseSwitchStatement = function(node2) {
|
|
|
5232
5241
|
if (cur) {
|
|
5233
5242
|
this.finishNode(cur, "SwitchCase");
|
|
5234
5243
|
}
|
|
5235
|
-
|
|
5244
|
+
node.cases.push(cur = this.startNode());
|
|
5236
5245
|
cur.consequent = [];
|
|
5237
5246
|
this.next();
|
|
5238
5247
|
if (isCase) {
|
|
@@ -5258,16 +5267,16 @@ pp$8.parseSwitchStatement = function(node2) {
|
|
|
5258
5267
|
}
|
|
5259
5268
|
this.next();
|
|
5260
5269
|
this.labels.pop();
|
|
5261
|
-
return this.finishNode(
|
|
5270
|
+
return this.finishNode(node, "SwitchStatement");
|
|
5262
5271
|
};
|
|
5263
|
-
pp$8.parseThrowStatement = function(
|
|
5272
|
+
pp$8.parseThrowStatement = function(node) {
|
|
5264
5273
|
this.next();
|
|
5265
5274
|
if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) {
|
|
5266
5275
|
this.raise(this.lastTokEnd, "Illegal newline after throw");
|
|
5267
5276
|
}
|
|
5268
|
-
|
|
5277
|
+
node.argument = this.parseExpression();
|
|
5269
5278
|
this.semicolon();
|
|
5270
|
-
return this.finishNode(
|
|
5279
|
+
return this.finishNode(node, "ThrowStatement");
|
|
5271
5280
|
};
|
|
5272
5281
|
var empty$1 = [];
|
|
5273
5282
|
pp$8.parseCatchClauseParam = function() {
|
|
@@ -5278,10 +5287,10 @@ pp$8.parseCatchClauseParam = function() {
|
|
|
5278
5287
|
this.expect(types$1.parenR);
|
|
5279
5288
|
return param;
|
|
5280
5289
|
};
|
|
5281
|
-
pp$8.parseTryStatement = function(
|
|
5290
|
+
pp$8.parseTryStatement = function(node) {
|
|
5282
5291
|
this.next();
|
|
5283
|
-
|
|
5284
|
-
|
|
5292
|
+
node.block = this.parseBlock();
|
|
5293
|
+
node.handler = null;
|
|
5285
5294
|
if (this.type === types$1._catch) {
|
|
5286
5295
|
var clause = this.startNode();
|
|
5287
5296
|
this.next();
|
|
@@ -5296,42 +5305,42 @@ pp$8.parseTryStatement = function(node2) {
|
|
|
5296
5305
|
}
|
|
5297
5306
|
clause.body = this.parseBlock(false);
|
|
5298
5307
|
this.exitScope();
|
|
5299
|
-
|
|
5308
|
+
node.handler = this.finishNode(clause, "CatchClause");
|
|
5300
5309
|
}
|
|
5301
|
-
|
|
5302
|
-
if (!
|
|
5303
|
-
this.raise(
|
|
5310
|
+
node.finalizer = this.eat(types$1._finally) ? this.parseBlock() : null;
|
|
5311
|
+
if (!node.handler && !node.finalizer) {
|
|
5312
|
+
this.raise(node.start, "Missing catch or finally clause");
|
|
5304
5313
|
}
|
|
5305
|
-
return this.finishNode(
|
|
5314
|
+
return this.finishNode(node, "TryStatement");
|
|
5306
5315
|
};
|
|
5307
|
-
pp$8.parseVarStatement = function(
|
|
5316
|
+
pp$8.parseVarStatement = function(node, kind, allowMissingInitializer) {
|
|
5308
5317
|
this.next();
|
|
5309
|
-
this.parseVar(
|
|
5318
|
+
this.parseVar(node, false, kind, allowMissingInitializer);
|
|
5310
5319
|
this.semicolon();
|
|
5311
|
-
return this.finishNode(
|
|
5320
|
+
return this.finishNode(node, "VariableDeclaration");
|
|
5312
5321
|
};
|
|
5313
|
-
pp$8.parseWhileStatement = function(
|
|
5322
|
+
pp$8.parseWhileStatement = function(node) {
|
|
5314
5323
|
this.next();
|
|
5315
|
-
|
|
5324
|
+
node.test = this.parseParenExpression();
|
|
5316
5325
|
this.labels.push(loopLabel);
|
|
5317
|
-
|
|
5326
|
+
node.body = this.parseStatement("while");
|
|
5318
5327
|
this.labels.pop();
|
|
5319
|
-
return this.finishNode(
|
|
5328
|
+
return this.finishNode(node, "WhileStatement");
|
|
5320
5329
|
};
|
|
5321
|
-
pp$8.parseWithStatement = function(
|
|
5330
|
+
pp$8.parseWithStatement = function(node) {
|
|
5322
5331
|
if (this.strict) {
|
|
5323
5332
|
this.raise(this.start, "'with' in strict mode");
|
|
5324
5333
|
}
|
|
5325
5334
|
this.next();
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
return this.finishNode(
|
|
5335
|
+
node.object = this.parseParenExpression();
|
|
5336
|
+
node.body = this.parseStatement("with");
|
|
5337
|
+
return this.finishNode(node, "WithStatement");
|
|
5329
5338
|
};
|
|
5330
|
-
pp$8.parseEmptyStatement = function(
|
|
5339
|
+
pp$8.parseEmptyStatement = function(node) {
|
|
5331
5340
|
this.next();
|
|
5332
|
-
return this.finishNode(
|
|
5341
|
+
return this.finishNode(node, "EmptyStatement");
|
|
5333
5342
|
};
|
|
5334
|
-
pp$8.parseLabeledStatement = function(
|
|
5343
|
+
pp$8.parseLabeledStatement = function(node, maybeName, expr, context) {
|
|
5335
5344
|
for (var i$1 = 0, list = this.labels; i$1 < list.length; i$1 += 1) {
|
|
5336
5345
|
var label = list[i$1];
|
|
5337
5346
|
if (label.name === maybeName) {
|
|
@@ -5341,7 +5350,7 @@ pp$8.parseLabeledStatement = function(node2, maybeName, expr, context) {
|
|
|
5341
5350
|
var kind = this.type.isLoop ? "loop" : this.type === types$1._switch ? "switch" : null;
|
|
5342
5351
|
for (var i = this.labels.length - 1; i >= 0; i--) {
|
|
5343
5352
|
var label$1 = this.labels[i];
|
|
5344
|
-
if (label$1.statementStart ===
|
|
5353
|
+
if (label$1.statementStart === node.start) {
|
|
5345
5354
|
label$1.statementStart = this.start;
|
|
5346
5355
|
label$1.kind = kind;
|
|
5347
5356
|
} else {
|
|
@@ -5349,29 +5358,29 @@ pp$8.parseLabeledStatement = function(node2, maybeName, expr, context) {
|
|
|
5349
5358
|
}
|
|
5350
5359
|
}
|
|
5351
5360
|
this.labels.push({ name: maybeName, kind, statementStart: this.start });
|
|
5352
|
-
|
|
5361
|
+
node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label");
|
|
5353
5362
|
this.labels.pop();
|
|
5354
|
-
|
|
5355
|
-
return this.finishNode(
|
|
5363
|
+
node.label = expr;
|
|
5364
|
+
return this.finishNode(node, "LabeledStatement");
|
|
5356
5365
|
};
|
|
5357
|
-
pp$8.parseExpressionStatement = function(
|
|
5358
|
-
|
|
5366
|
+
pp$8.parseExpressionStatement = function(node, expr) {
|
|
5367
|
+
node.expression = expr;
|
|
5359
5368
|
this.semicolon();
|
|
5360
|
-
return this.finishNode(
|
|
5369
|
+
return this.finishNode(node, "ExpressionStatement");
|
|
5361
5370
|
};
|
|
5362
|
-
pp$8.parseBlock = function(createNewLexicalScope,
|
|
5371
|
+
pp$8.parseBlock = function(createNewLexicalScope, node, exitStrict) {
|
|
5363
5372
|
if (createNewLexicalScope === void 0)
|
|
5364
5373
|
createNewLexicalScope = true;
|
|
5365
|
-
if (
|
|
5366
|
-
|
|
5367
|
-
|
|
5374
|
+
if (node === void 0)
|
|
5375
|
+
node = this.startNode();
|
|
5376
|
+
node.body = [];
|
|
5368
5377
|
this.expect(types$1.braceL);
|
|
5369
5378
|
if (createNewLexicalScope) {
|
|
5370
5379
|
this.enterScope(0);
|
|
5371
5380
|
}
|
|
5372
5381
|
while (this.type !== types$1.braceR) {
|
|
5373
5382
|
var stmt = this.parseStatement(null);
|
|
5374
|
-
|
|
5383
|
+
node.body.push(stmt);
|
|
5375
5384
|
}
|
|
5376
5385
|
if (exitStrict) {
|
|
5377
5386
|
this.strict = false;
|
|
@@ -5380,21 +5389,21 @@ pp$8.parseBlock = function(createNewLexicalScope, node2, exitStrict) {
|
|
|
5380
5389
|
if (createNewLexicalScope) {
|
|
5381
5390
|
this.exitScope();
|
|
5382
5391
|
}
|
|
5383
|
-
return this.finishNode(
|
|
5392
|
+
return this.finishNode(node, "BlockStatement");
|
|
5384
5393
|
};
|
|
5385
|
-
pp$8.parseFor = function(
|
|
5386
|
-
|
|
5394
|
+
pp$8.parseFor = function(node, init) {
|
|
5395
|
+
node.init = init;
|
|
5387
5396
|
this.expect(types$1.semi);
|
|
5388
|
-
|
|
5397
|
+
node.test = this.type === types$1.semi ? null : this.parseExpression();
|
|
5389
5398
|
this.expect(types$1.semi);
|
|
5390
|
-
|
|
5399
|
+
node.update = this.type === types$1.parenR ? null : this.parseExpression();
|
|
5391
5400
|
this.expect(types$1.parenR);
|
|
5392
|
-
|
|
5401
|
+
node.body = this.parseStatement("for");
|
|
5393
5402
|
this.exitScope();
|
|
5394
5403
|
this.labels.pop();
|
|
5395
|
-
return this.finishNode(
|
|
5404
|
+
return this.finishNode(node, "ForStatement");
|
|
5396
5405
|
};
|
|
5397
|
-
pp$8.parseForIn = function(
|
|
5406
|
+
pp$8.parseForIn = function(node, init) {
|
|
5398
5407
|
var isForIn = this.type === types$1._in;
|
|
5399
5408
|
this.next();
|
|
5400
5409
|
if (init.type === "VariableDeclaration" && init.declarations[0].init != null && (!isForIn || this.options.ecmaVersion < 8 || this.strict || init.kind !== "var" || init.declarations[0].id.type !== "Identifier")) {
|
|
@@ -5403,17 +5412,17 @@ pp$8.parseForIn = function(node2, init) {
|
|
|
5403
5412
|
(isForIn ? "for-in" : "for-of") + " loop variable declaration may not have an initializer"
|
|
5404
5413
|
);
|
|
5405
5414
|
}
|
|
5406
|
-
|
|
5407
|
-
|
|
5415
|
+
node.left = init;
|
|
5416
|
+
node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign();
|
|
5408
5417
|
this.expect(types$1.parenR);
|
|
5409
|
-
|
|
5418
|
+
node.body = this.parseStatement("for");
|
|
5410
5419
|
this.exitScope();
|
|
5411
5420
|
this.labels.pop();
|
|
5412
|
-
return this.finishNode(
|
|
5421
|
+
return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement");
|
|
5413
5422
|
};
|
|
5414
|
-
pp$8.parseVar = function(
|
|
5415
|
-
|
|
5416
|
-
|
|
5423
|
+
pp$8.parseVar = function(node, isFor, kind, allowMissingInitializer) {
|
|
5424
|
+
node.declarations = [];
|
|
5425
|
+
node.kind = kind;
|
|
5417
5426
|
for (; ; ) {
|
|
5418
5427
|
var decl = this.startNode();
|
|
5419
5428
|
this.parseVarId(decl, kind);
|
|
@@ -5426,12 +5435,12 @@ pp$8.parseVar = function(node2, isFor, kind, allowMissingInitializer) {
|
|
|
5426
5435
|
} else {
|
|
5427
5436
|
decl.init = null;
|
|
5428
5437
|
}
|
|
5429
|
-
|
|
5438
|
+
node.declarations.push(this.finishNode(decl, "VariableDeclarator"));
|
|
5430
5439
|
if (!this.eat(types$1.comma)) {
|
|
5431
5440
|
break;
|
|
5432
5441
|
}
|
|
5433
5442
|
}
|
|
5434
|
-
return
|
|
5443
|
+
return node;
|
|
5435
5444
|
};
|
|
5436
5445
|
pp$8.parseVarId = function(decl, kind) {
|
|
5437
5446
|
decl.id = this.parseBindingAtom();
|
|
@@ -5440,56 +5449,56 @@ pp$8.parseVarId = function(decl, kind) {
|
|
|
5440
5449
|
var FUNC_STATEMENT = 1;
|
|
5441
5450
|
var FUNC_HANGING_STATEMENT = 2;
|
|
5442
5451
|
var FUNC_NULLABLE_ID = 4;
|
|
5443
|
-
pp$8.parseFunction = function(
|
|
5444
|
-
this.initFunction(
|
|
5452
|
+
pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, forInit) {
|
|
5453
|
+
this.initFunction(node);
|
|
5445
5454
|
if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) {
|
|
5446
5455
|
if (this.type === types$1.star && statement & FUNC_HANGING_STATEMENT) {
|
|
5447
5456
|
this.unexpected();
|
|
5448
5457
|
}
|
|
5449
|
-
|
|
5458
|
+
node.generator = this.eat(types$1.star);
|
|
5450
5459
|
}
|
|
5451
5460
|
if (this.options.ecmaVersion >= 8) {
|
|
5452
|
-
|
|
5461
|
+
node.async = !!isAsync;
|
|
5453
5462
|
}
|
|
5454
5463
|
if (statement & FUNC_STATEMENT) {
|
|
5455
|
-
|
|
5456
|
-
if (
|
|
5457
|
-
this.checkLValSimple(
|
|
5464
|
+
node.id = statement & FUNC_NULLABLE_ID && this.type !== types$1.name ? null : this.parseIdent();
|
|
5465
|
+
if (node.id && !(statement & FUNC_HANGING_STATEMENT)) {
|
|
5466
|
+
this.checkLValSimple(node.id, this.strict || node.generator || node.async ? this.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION);
|
|
5458
5467
|
}
|
|
5459
5468
|
}
|
|
5460
5469
|
var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
|
|
5461
5470
|
this.yieldPos = 0;
|
|
5462
5471
|
this.awaitPos = 0;
|
|
5463
5472
|
this.awaitIdentPos = 0;
|
|
5464
|
-
this.enterScope(functionFlags(
|
|
5473
|
+
this.enterScope(functionFlags(node.async, node.generator));
|
|
5465
5474
|
if (!(statement & FUNC_STATEMENT)) {
|
|
5466
|
-
|
|
5475
|
+
node.id = this.type === types$1.name ? this.parseIdent() : null;
|
|
5467
5476
|
}
|
|
5468
|
-
this.parseFunctionParams(
|
|
5469
|
-
this.parseFunctionBody(
|
|
5477
|
+
this.parseFunctionParams(node);
|
|
5478
|
+
this.parseFunctionBody(node, allowExpressionBody, false, forInit);
|
|
5470
5479
|
this.yieldPos = oldYieldPos;
|
|
5471
5480
|
this.awaitPos = oldAwaitPos;
|
|
5472
5481
|
this.awaitIdentPos = oldAwaitIdentPos;
|
|
5473
|
-
return this.finishNode(
|
|
5482
|
+
return this.finishNode(node, statement & FUNC_STATEMENT ? "FunctionDeclaration" : "FunctionExpression");
|
|
5474
5483
|
};
|
|
5475
|
-
pp$8.parseFunctionParams = function(
|
|
5484
|
+
pp$8.parseFunctionParams = function(node) {
|
|
5476
5485
|
this.expect(types$1.parenL);
|
|
5477
|
-
|
|
5486
|
+
node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8);
|
|
5478
5487
|
this.checkYieldAwaitInDefaultParams();
|
|
5479
5488
|
};
|
|
5480
|
-
pp$8.parseClass = function(
|
|
5489
|
+
pp$8.parseClass = function(node, isStatement) {
|
|
5481
5490
|
this.next();
|
|
5482
5491
|
var oldStrict = this.strict;
|
|
5483
5492
|
this.strict = true;
|
|
5484
|
-
this.parseClassId(
|
|
5485
|
-
this.parseClassSuper(
|
|
5493
|
+
this.parseClassId(node, isStatement);
|
|
5494
|
+
this.parseClassSuper(node);
|
|
5486
5495
|
var privateNameMap = this.enterClassBody();
|
|
5487
5496
|
var classBody = this.startNode();
|
|
5488
5497
|
var hadConstructor = false;
|
|
5489
5498
|
classBody.body = [];
|
|
5490
5499
|
this.expect(types$1.braceL);
|
|
5491
5500
|
while (this.type !== types$1.braceR) {
|
|
5492
|
-
var element = this.parseClassElement(
|
|
5501
|
+
var element = this.parseClassElement(node.superClass !== null);
|
|
5493
5502
|
if (element) {
|
|
5494
5503
|
classBody.body.push(element);
|
|
5495
5504
|
if (element.type === "MethodDefinition" && element.kind === "constructor") {
|
|
@@ -5504,16 +5513,16 @@ pp$8.parseClass = function(node2, isStatement) {
|
|
|
5504
5513
|
}
|
|
5505
5514
|
this.strict = oldStrict;
|
|
5506
5515
|
this.next();
|
|
5507
|
-
|
|
5516
|
+
node.body = this.finishNode(classBody, "ClassBody");
|
|
5508
5517
|
this.exitClassBody();
|
|
5509
|
-
return this.finishNode(
|
|
5518
|
+
return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
|
|
5510
5519
|
};
|
|
5511
5520
|
pp$8.parseClassElement = function(constructorAllowsSuper) {
|
|
5512
5521
|
if (this.eat(types$1.semi)) {
|
|
5513
5522
|
return null;
|
|
5514
5523
|
}
|
|
5515
5524
|
var ecmaVersion = this.options.ecmaVersion;
|
|
5516
|
-
var
|
|
5525
|
+
var node = this.startNode();
|
|
5517
5526
|
var keyName = "";
|
|
5518
5527
|
var isGenerator = false;
|
|
5519
5528
|
var isAsync = false;
|
|
@@ -5521,8 +5530,8 @@ pp$8.parseClassElement = function(constructorAllowsSuper) {
|
|
|
5521
5530
|
var isStatic = false;
|
|
5522
5531
|
if (this.eatContextual("static")) {
|
|
5523
5532
|
if (ecmaVersion >= 13 && this.eat(types$1.braceL)) {
|
|
5524
|
-
this.parseClassStaticBlock(
|
|
5525
|
-
return
|
|
5533
|
+
this.parseClassStaticBlock(node);
|
|
5534
|
+
return node;
|
|
5526
5535
|
}
|
|
5527
5536
|
if (this.isClassElementNameStart() || this.type === types$1.star) {
|
|
5528
5537
|
isStatic = true;
|
|
@@ -5530,7 +5539,7 @@ pp$8.parseClassElement = function(constructorAllowsSuper) {
|
|
|
5530
5539
|
keyName = "static";
|
|
5531
5540
|
}
|
|
5532
5541
|
}
|
|
5533
|
-
|
|
5542
|
+
node.static = isStatic;
|
|
5534
5543
|
if (!keyName && ecmaVersion >= 8 && this.eatContextual("async")) {
|
|
5535
5544
|
if ((this.isClassElementNameStart() || this.type === types$1.star) && !this.canInsertSemicolon()) {
|
|
5536
5545
|
isAsync = true;
|
|
@@ -5552,25 +5561,25 @@ pp$8.parseClassElement = function(constructorAllowsSuper) {
|
|
|
5552
5561
|
}
|
|
5553
5562
|
}
|
|
5554
5563
|
if (keyName) {
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
this.finishNode(
|
|
5564
|
+
node.computed = false;
|
|
5565
|
+
node.key = this.startNodeAt(this.lastTokStart, this.lastTokStartLoc);
|
|
5566
|
+
node.key.name = keyName;
|
|
5567
|
+
this.finishNode(node.key, "Identifier");
|
|
5559
5568
|
} else {
|
|
5560
|
-
this.parseClassElementName(
|
|
5569
|
+
this.parseClassElementName(node);
|
|
5561
5570
|
}
|
|
5562
5571
|
if (ecmaVersion < 13 || this.type === types$1.parenL || kind !== "method" || isGenerator || isAsync) {
|
|
5563
|
-
var isConstructor = !
|
|
5572
|
+
var isConstructor = !node.static && checkKeyName(node, "constructor");
|
|
5564
5573
|
var allowsDirectSuper = isConstructor && constructorAllowsSuper;
|
|
5565
5574
|
if (isConstructor && kind !== "method") {
|
|
5566
|
-
this.raise(
|
|
5575
|
+
this.raise(node.key.start, "Constructor can't have get/set modifier");
|
|
5567
5576
|
}
|
|
5568
|
-
|
|
5569
|
-
this.parseClassMethod(
|
|
5577
|
+
node.kind = isConstructor ? "constructor" : kind;
|
|
5578
|
+
this.parseClassMethod(node, isGenerator, isAsync, allowsDirectSuper);
|
|
5570
5579
|
} else {
|
|
5571
|
-
this.parseClassField(
|
|
5580
|
+
this.parseClassField(node);
|
|
5572
5581
|
}
|
|
5573
|
-
return
|
|
5582
|
+
return node;
|
|
5574
5583
|
};
|
|
5575
5584
|
pp$8.isClassElementNameStart = function() {
|
|
5576
5585
|
return this.type === types$1.name || this.type === types$1.privateId || this.type === types$1.num || this.type === types$1.string || this.type === types$1.bracketL || this.type.keyword;
|
|
@@ -5628,35 +5637,35 @@ pp$8.parseClassField = function(field) {
|
|
|
5628
5637
|
this.semicolon();
|
|
5629
5638
|
return this.finishNode(field, "PropertyDefinition");
|
|
5630
5639
|
};
|
|
5631
|
-
pp$8.parseClassStaticBlock = function(
|
|
5632
|
-
|
|
5640
|
+
pp$8.parseClassStaticBlock = function(node) {
|
|
5641
|
+
node.body = [];
|
|
5633
5642
|
var oldLabels = this.labels;
|
|
5634
5643
|
this.labels = [];
|
|
5635
5644
|
this.enterScope(SCOPE_CLASS_STATIC_BLOCK | SCOPE_SUPER);
|
|
5636
5645
|
while (this.type !== types$1.braceR) {
|
|
5637
5646
|
var stmt = this.parseStatement(null);
|
|
5638
|
-
|
|
5647
|
+
node.body.push(stmt);
|
|
5639
5648
|
}
|
|
5640
5649
|
this.next();
|
|
5641
5650
|
this.exitScope();
|
|
5642
5651
|
this.labels = oldLabels;
|
|
5643
|
-
return this.finishNode(
|
|
5652
|
+
return this.finishNode(node, "StaticBlock");
|
|
5644
5653
|
};
|
|
5645
|
-
pp$8.parseClassId = function(
|
|
5654
|
+
pp$8.parseClassId = function(node, isStatement) {
|
|
5646
5655
|
if (this.type === types$1.name) {
|
|
5647
|
-
|
|
5656
|
+
node.id = this.parseIdent();
|
|
5648
5657
|
if (isStatement) {
|
|
5649
|
-
this.checkLValSimple(
|
|
5658
|
+
this.checkLValSimple(node.id, BIND_LEXICAL, false);
|
|
5650
5659
|
}
|
|
5651
5660
|
} else {
|
|
5652
5661
|
if (isStatement === true) {
|
|
5653
5662
|
this.unexpected();
|
|
5654
5663
|
}
|
|
5655
|
-
|
|
5664
|
+
node.id = null;
|
|
5656
5665
|
}
|
|
5657
5666
|
};
|
|
5658
|
-
pp$8.parseClassSuper = function(
|
|
5659
|
-
|
|
5667
|
+
pp$8.parseClassSuper = function(node) {
|
|
5668
|
+
node.superClass = this.eat(types$1._extends) ? this.parseExprSubscripts(null, false) : null;
|
|
5660
5669
|
};
|
|
5661
5670
|
pp$8.enterClassBody = function() {
|
|
5662
5671
|
var element = { declared: /* @__PURE__ */ Object.create(null), used: [] };
|
|
@@ -5700,57 +5709,57 @@ function isPrivateNameConflicted(privateNameMap, element) {
|
|
|
5700
5709
|
return true;
|
|
5701
5710
|
}
|
|
5702
5711
|
}
|
|
5703
|
-
function checkKeyName(
|
|
5704
|
-
var computed =
|
|
5705
|
-
var key =
|
|
5712
|
+
function checkKeyName(node, name) {
|
|
5713
|
+
var computed = node.computed;
|
|
5714
|
+
var key = node.key;
|
|
5706
5715
|
return !computed && (key.type === "Identifier" && key.name === name || key.type === "Literal" && key.value === name);
|
|
5707
5716
|
}
|
|
5708
|
-
pp$8.parseExportAllDeclaration = function(
|
|
5717
|
+
pp$8.parseExportAllDeclaration = function(node, exports2) {
|
|
5709
5718
|
if (this.options.ecmaVersion >= 11) {
|
|
5710
5719
|
if (this.eatContextual("as")) {
|
|
5711
|
-
|
|
5712
|
-
this.checkExport(exports2,
|
|
5720
|
+
node.exported = this.parseModuleExportName();
|
|
5721
|
+
this.checkExport(exports2, node.exported, this.lastTokStart);
|
|
5713
5722
|
} else {
|
|
5714
|
-
|
|
5723
|
+
node.exported = null;
|
|
5715
5724
|
}
|
|
5716
5725
|
}
|
|
5717
5726
|
this.expectContextual("from");
|
|
5718
5727
|
if (this.type !== types$1.string) {
|
|
5719
5728
|
this.unexpected();
|
|
5720
5729
|
}
|
|
5721
|
-
|
|
5730
|
+
node.source = this.parseExprAtom();
|
|
5722
5731
|
this.semicolon();
|
|
5723
|
-
return this.finishNode(
|
|
5732
|
+
return this.finishNode(node, "ExportAllDeclaration");
|
|
5724
5733
|
};
|
|
5725
|
-
pp$8.parseExport = function(
|
|
5734
|
+
pp$8.parseExport = function(node, exports2) {
|
|
5726
5735
|
this.next();
|
|
5727
5736
|
if (this.eat(types$1.star)) {
|
|
5728
|
-
return this.parseExportAllDeclaration(
|
|
5737
|
+
return this.parseExportAllDeclaration(node, exports2);
|
|
5729
5738
|
}
|
|
5730
5739
|
if (this.eat(types$1._default)) {
|
|
5731
5740
|
this.checkExport(exports2, "default", this.lastTokStart);
|
|
5732
|
-
|
|
5733
|
-
return this.finishNode(
|
|
5741
|
+
node.declaration = this.parseExportDefaultDeclaration();
|
|
5742
|
+
return this.finishNode(node, "ExportDefaultDeclaration");
|
|
5734
5743
|
}
|
|
5735
5744
|
if (this.shouldParseExportStatement()) {
|
|
5736
|
-
|
|
5737
|
-
if (
|
|
5738
|
-
this.checkVariableExport(exports2,
|
|
5745
|
+
node.declaration = this.parseExportDeclaration(node);
|
|
5746
|
+
if (node.declaration.type === "VariableDeclaration") {
|
|
5747
|
+
this.checkVariableExport(exports2, node.declaration.declarations);
|
|
5739
5748
|
} else {
|
|
5740
|
-
this.checkExport(exports2,
|
|
5749
|
+
this.checkExport(exports2, node.declaration.id, node.declaration.id.start);
|
|
5741
5750
|
}
|
|
5742
|
-
|
|
5743
|
-
|
|
5751
|
+
node.specifiers = [];
|
|
5752
|
+
node.source = null;
|
|
5744
5753
|
} else {
|
|
5745
|
-
|
|
5746
|
-
|
|
5754
|
+
node.declaration = null;
|
|
5755
|
+
node.specifiers = this.parseExportSpecifiers(exports2);
|
|
5747
5756
|
if (this.eatContextual("from")) {
|
|
5748
5757
|
if (this.type !== types$1.string) {
|
|
5749
5758
|
this.unexpected();
|
|
5750
5759
|
}
|
|
5751
|
-
|
|
5760
|
+
node.source = this.parseExprAtom();
|
|
5752
5761
|
} else {
|
|
5753
|
-
for (var i = 0, list =
|
|
5762
|
+
for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
|
|
5754
5763
|
var spec = list[i];
|
|
5755
5764
|
this.checkUnreserved(spec.local);
|
|
5756
5765
|
this.checkLocalExport(spec.local);
|
|
@@ -5758,13 +5767,13 @@ pp$8.parseExport = function(node2, exports2) {
|
|
|
5758
5767
|
this.raise(spec.local.start, "A string literal cannot be used as an exported binding without `from`.");
|
|
5759
5768
|
}
|
|
5760
5769
|
}
|
|
5761
|
-
|
|
5770
|
+
node.source = null;
|
|
5762
5771
|
}
|
|
5763
5772
|
this.semicolon();
|
|
5764
5773
|
}
|
|
5765
|
-
return this.finishNode(
|
|
5774
|
+
return this.finishNode(node, "ExportNamedDeclaration");
|
|
5766
5775
|
};
|
|
5767
|
-
pp$8.parseExportDeclaration = function(
|
|
5776
|
+
pp$8.parseExportDeclaration = function(node) {
|
|
5768
5777
|
return this.parseStatement(null);
|
|
5769
5778
|
};
|
|
5770
5779
|
pp$8.parseExportDefaultDeclaration = function() {
|
|
@@ -5834,15 +5843,15 @@ pp$8.shouldParseExportStatement = function() {
|
|
|
5834
5843
|
return this.type.keyword === "var" || this.type.keyword === "const" || this.type.keyword === "class" || this.type.keyword === "function" || this.isLet() || this.isAsyncFunction();
|
|
5835
5844
|
};
|
|
5836
5845
|
pp$8.parseExportSpecifier = function(exports2) {
|
|
5837
|
-
var
|
|
5838
|
-
|
|
5839
|
-
|
|
5846
|
+
var node = this.startNode();
|
|
5847
|
+
node.local = this.parseModuleExportName();
|
|
5848
|
+
node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
|
|
5840
5849
|
this.checkExport(
|
|
5841
5850
|
exports2,
|
|
5842
|
-
|
|
5843
|
-
|
|
5851
|
+
node.exported,
|
|
5852
|
+
node.exported.start
|
|
5844
5853
|
);
|
|
5845
|
-
return this.finishNode(
|
|
5854
|
+
return this.finishNode(node, "ExportSpecifier");
|
|
5846
5855
|
};
|
|
5847
5856
|
pp$8.parseExportSpecifiers = function(exports2) {
|
|
5848
5857
|
var nodes = [], first = true;
|
|
@@ -5860,44 +5869,44 @@ pp$8.parseExportSpecifiers = function(exports2) {
|
|
|
5860
5869
|
}
|
|
5861
5870
|
return nodes;
|
|
5862
5871
|
};
|
|
5863
|
-
pp$8.parseImport = function(
|
|
5872
|
+
pp$8.parseImport = function(node) {
|
|
5864
5873
|
this.next();
|
|
5865
5874
|
if (this.type === types$1.string) {
|
|
5866
|
-
|
|
5867
|
-
|
|
5875
|
+
node.specifiers = empty$1;
|
|
5876
|
+
node.source = this.parseExprAtom();
|
|
5868
5877
|
} else {
|
|
5869
|
-
|
|
5878
|
+
node.specifiers = this.parseImportSpecifiers();
|
|
5870
5879
|
this.expectContextual("from");
|
|
5871
|
-
|
|
5880
|
+
node.source = this.type === types$1.string ? this.parseExprAtom() : this.unexpected();
|
|
5872
5881
|
}
|
|
5873
5882
|
this.semicolon();
|
|
5874
|
-
return this.finishNode(
|
|
5883
|
+
return this.finishNode(node, "ImportDeclaration");
|
|
5875
5884
|
};
|
|
5876
5885
|
pp$8.parseImportSpecifier = function() {
|
|
5877
|
-
var
|
|
5878
|
-
|
|
5886
|
+
var node = this.startNode();
|
|
5887
|
+
node.imported = this.parseModuleExportName();
|
|
5879
5888
|
if (this.eatContextual("as")) {
|
|
5880
|
-
|
|
5889
|
+
node.local = this.parseIdent();
|
|
5881
5890
|
} else {
|
|
5882
|
-
this.checkUnreserved(
|
|
5883
|
-
|
|
5891
|
+
this.checkUnreserved(node.imported);
|
|
5892
|
+
node.local = node.imported;
|
|
5884
5893
|
}
|
|
5885
|
-
this.checkLValSimple(
|
|
5886
|
-
return this.finishNode(
|
|
5894
|
+
this.checkLValSimple(node.local, BIND_LEXICAL);
|
|
5895
|
+
return this.finishNode(node, "ImportSpecifier");
|
|
5887
5896
|
};
|
|
5888
5897
|
pp$8.parseImportDefaultSpecifier = function() {
|
|
5889
|
-
var
|
|
5890
|
-
|
|
5891
|
-
this.checkLValSimple(
|
|
5892
|
-
return this.finishNode(
|
|
5898
|
+
var node = this.startNode();
|
|
5899
|
+
node.local = this.parseIdent();
|
|
5900
|
+
this.checkLValSimple(node.local, BIND_LEXICAL);
|
|
5901
|
+
return this.finishNode(node, "ImportDefaultSpecifier");
|
|
5893
5902
|
};
|
|
5894
5903
|
pp$8.parseImportNamespaceSpecifier = function() {
|
|
5895
|
-
var
|
|
5904
|
+
var node = this.startNode();
|
|
5896
5905
|
this.next();
|
|
5897
5906
|
this.expectContextual("as");
|
|
5898
|
-
|
|
5899
|
-
this.checkLValSimple(
|
|
5900
|
-
return this.finishNode(
|
|
5907
|
+
node.local = this.parseIdent();
|
|
5908
|
+
this.checkLValSimple(node.local, BIND_LEXICAL);
|
|
5909
|
+
return this.finishNode(node, "ImportNamespaceSpecifier");
|
|
5901
5910
|
};
|
|
5902
5911
|
pp$8.parseImportSpecifiers = function() {
|
|
5903
5912
|
var nodes = [], first = true;
|
|
@@ -5945,12 +5954,12 @@ pp$8.isDirectiveCandidate = function(statement) {
|
|
|
5945
5954
|
(this.input[statement.start] === '"' || this.input[statement.start] === "'");
|
|
5946
5955
|
};
|
|
5947
5956
|
var pp$7 = Parser.prototype;
|
|
5948
|
-
pp$7.toAssignable = function(
|
|
5949
|
-
if (this.options.ecmaVersion >= 6 &&
|
|
5950
|
-
switch (
|
|
5957
|
+
pp$7.toAssignable = function(node, isBinding, refDestructuringErrors) {
|
|
5958
|
+
if (this.options.ecmaVersion >= 6 && node) {
|
|
5959
|
+
switch (node.type) {
|
|
5951
5960
|
case "Identifier":
|
|
5952
|
-
if (this.inAsync &&
|
|
5953
|
-
this.raise(
|
|
5961
|
+
if (this.inAsync && node.name === "await") {
|
|
5962
|
+
this.raise(node.start, "Cannot use 'await' as identifier inside an async function");
|
|
5954
5963
|
}
|
|
5955
5964
|
break;
|
|
5956
5965
|
case "ObjectPattern":
|
|
@@ -5959,11 +5968,11 @@ pp$7.toAssignable = function(node2, isBinding, refDestructuringErrors) {
|
|
|
5959
5968
|
case "RestElement":
|
|
5960
5969
|
break;
|
|
5961
5970
|
case "ObjectExpression":
|
|
5962
|
-
|
|
5971
|
+
node.type = "ObjectPattern";
|
|
5963
5972
|
if (refDestructuringErrors) {
|
|
5964
5973
|
this.checkPatternErrors(refDestructuringErrors, true);
|
|
5965
5974
|
}
|
|
5966
|
-
for (var i = 0, list =
|
|
5975
|
+
for (var i = 0, list = node.properties; i < list.length; i += 1) {
|
|
5967
5976
|
var prop = list[i];
|
|
5968
5977
|
this.toAssignable(prop, isBinding);
|
|
5969
5978
|
if (prop.type === "RestElement" && (prop.argument.type === "ArrayPattern" || prop.argument.type === "ObjectPattern")) {
|
|
@@ -5972,50 +5981,50 @@ pp$7.toAssignable = function(node2, isBinding, refDestructuringErrors) {
|
|
|
5972
5981
|
}
|
|
5973
5982
|
break;
|
|
5974
5983
|
case "Property":
|
|
5975
|
-
if (
|
|
5976
|
-
this.raise(
|
|
5984
|
+
if (node.kind !== "init") {
|
|
5985
|
+
this.raise(node.key.start, "Object pattern can't contain getter or setter");
|
|
5977
5986
|
}
|
|
5978
|
-
this.toAssignable(
|
|
5987
|
+
this.toAssignable(node.value, isBinding);
|
|
5979
5988
|
break;
|
|
5980
5989
|
case "ArrayExpression":
|
|
5981
|
-
|
|
5990
|
+
node.type = "ArrayPattern";
|
|
5982
5991
|
if (refDestructuringErrors) {
|
|
5983
5992
|
this.checkPatternErrors(refDestructuringErrors, true);
|
|
5984
5993
|
}
|
|
5985
|
-
this.toAssignableList(
|
|
5994
|
+
this.toAssignableList(node.elements, isBinding);
|
|
5986
5995
|
break;
|
|
5987
5996
|
case "SpreadElement":
|
|
5988
|
-
|
|
5989
|
-
this.toAssignable(
|
|
5990
|
-
if (
|
|
5991
|
-
this.raise(
|
|
5997
|
+
node.type = "RestElement";
|
|
5998
|
+
this.toAssignable(node.argument, isBinding);
|
|
5999
|
+
if (node.argument.type === "AssignmentPattern") {
|
|
6000
|
+
this.raise(node.argument.start, "Rest elements cannot have a default value");
|
|
5992
6001
|
}
|
|
5993
6002
|
break;
|
|
5994
6003
|
case "AssignmentExpression":
|
|
5995
|
-
if (
|
|
5996
|
-
this.raise(
|
|
6004
|
+
if (node.operator !== "=") {
|
|
6005
|
+
this.raise(node.left.end, "Only '=' operator can be used for specifying default value.");
|
|
5997
6006
|
}
|
|
5998
|
-
|
|
5999
|
-
delete
|
|
6000
|
-
this.toAssignable(
|
|
6007
|
+
node.type = "AssignmentPattern";
|
|
6008
|
+
delete node.operator;
|
|
6009
|
+
this.toAssignable(node.left, isBinding);
|
|
6001
6010
|
break;
|
|
6002
6011
|
case "ParenthesizedExpression":
|
|
6003
|
-
this.toAssignable(
|
|
6012
|
+
this.toAssignable(node.expression, isBinding, refDestructuringErrors);
|
|
6004
6013
|
break;
|
|
6005
6014
|
case "ChainExpression":
|
|
6006
|
-
this.raiseRecoverable(
|
|
6015
|
+
this.raiseRecoverable(node.start, "Optional chaining cannot appear in left-hand side");
|
|
6007
6016
|
break;
|
|
6008
6017
|
case "MemberExpression":
|
|
6009
6018
|
if (!isBinding) {
|
|
6010
6019
|
break;
|
|
6011
6020
|
}
|
|
6012
6021
|
default:
|
|
6013
|
-
this.raise(
|
|
6022
|
+
this.raise(node.start, "Assigning to rvalue");
|
|
6014
6023
|
}
|
|
6015
6024
|
} else if (refDestructuringErrors) {
|
|
6016
6025
|
this.checkPatternErrors(refDestructuringErrors, true);
|
|
6017
6026
|
}
|
|
6018
|
-
return
|
|
6027
|
+
return node;
|
|
6019
6028
|
};
|
|
6020
6029
|
pp$7.toAssignableList = function(exprList, isBinding) {
|
|
6021
6030
|
var end = exprList.length;
|
|
@@ -6034,28 +6043,28 @@ pp$7.toAssignableList = function(exprList, isBinding) {
|
|
|
6034
6043
|
return exprList;
|
|
6035
6044
|
};
|
|
6036
6045
|
pp$7.parseSpread = function(refDestructuringErrors) {
|
|
6037
|
-
var
|
|
6046
|
+
var node = this.startNode();
|
|
6038
6047
|
this.next();
|
|
6039
|
-
|
|
6040
|
-
return this.finishNode(
|
|
6048
|
+
node.argument = this.parseMaybeAssign(false, refDestructuringErrors);
|
|
6049
|
+
return this.finishNode(node, "SpreadElement");
|
|
6041
6050
|
};
|
|
6042
6051
|
pp$7.parseRestBinding = function() {
|
|
6043
|
-
var
|
|
6052
|
+
var node = this.startNode();
|
|
6044
6053
|
this.next();
|
|
6045
6054
|
if (this.options.ecmaVersion === 6 && this.type !== types$1.name) {
|
|
6046
6055
|
this.unexpected();
|
|
6047
6056
|
}
|
|
6048
|
-
|
|
6049
|
-
return this.finishNode(
|
|
6057
|
+
node.argument = this.parseBindingAtom();
|
|
6058
|
+
return this.finishNode(node, "RestElement");
|
|
6050
6059
|
};
|
|
6051
6060
|
pp$7.parseBindingAtom = function() {
|
|
6052
6061
|
if (this.options.ecmaVersion >= 6) {
|
|
6053
6062
|
switch (this.type) {
|
|
6054
6063
|
case types$1.bracketL:
|
|
6055
|
-
var
|
|
6064
|
+
var node = this.startNode();
|
|
6056
6065
|
this.next();
|
|
6057
|
-
|
|
6058
|
-
return this.finishNode(
|
|
6066
|
+
node.elements = this.parseBindingList(types$1.bracketR, true, true);
|
|
6067
|
+
return this.finishNode(node, "ArrayPattern");
|
|
6059
6068
|
case types$1.braceL:
|
|
6060
6069
|
return this.parseObj(true);
|
|
6061
6070
|
}
|
|
@@ -6102,10 +6111,10 @@ pp$7.parseMaybeDefault = function(startPos, startLoc, left) {
|
|
|
6102
6111
|
if (this.options.ecmaVersion < 6 || !this.eat(types$1.eq)) {
|
|
6103
6112
|
return left;
|
|
6104
6113
|
}
|
|
6105
|
-
var
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
return this.finishNode(
|
|
6114
|
+
var node = this.startNodeAt(startPos, startLoc);
|
|
6115
|
+
node.left = left;
|
|
6116
|
+
node.right = this.parseMaybeAssign();
|
|
6117
|
+
return this.finishNode(node, "AssignmentPattern");
|
|
6109
6118
|
};
|
|
6110
6119
|
pp$7.checkLValSimple = function(expr, bindingType, checkClashes) {
|
|
6111
6120
|
if (bindingType === void 0)
|
|
@@ -6390,12 +6399,12 @@ pp$5.parseExpression = function(forInit, refDestructuringErrors) {
|
|
|
6390
6399
|
var startPos = this.start, startLoc = this.startLoc;
|
|
6391
6400
|
var expr = this.parseMaybeAssign(forInit, refDestructuringErrors);
|
|
6392
6401
|
if (this.type === types$1.comma) {
|
|
6393
|
-
var
|
|
6394
|
-
|
|
6402
|
+
var node = this.startNodeAt(startPos, startLoc);
|
|
6403
|
+
node.expressions = [expr];
|
|
6395
6404
|
while (this.eat(types$1.comma)) {
|
|
6396
|
-
|
|
6405
|
+
node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors));
|
|
6397
6406
|
}
|
|
6398
|
-
return this.finishNode(
|
|
6407
|
+
return this.finishNode(node, "SequenceExpression");
|
|
6399
6408
|
}
|
|
6400
6409
|
return expr;
|
|
6401
6410
|
};
|
|
@@ -6427,8 +6436,8 @@ pp$5.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse
|
|
|
6427
6436
|
left = afterLeftParse.call(this, left, startPos, startLoc);
|
|
6428
6437
|
}
|
|
6429
6438
|
if (this.type.isAssign) {
|
|
6430
|
-
var
|
|
6431
|
-
|
|
6439
|
+
var node = this.startNodeAt(startPos, startLoc);
|
|
6440
|
+
node.operator = this.value;
|
|
6432
6441
|
if (this.type === types$1.eq) {
|
|
6433
6442
|
left = this.toAssignable(left, false, refDestructuringErrors);
|
|
6434
6443
|
}
|
|
@@ -6443,13 +6452,13 @@ pp$5.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse
|
|
|
6443
6452
|
} else {
|
|
6444
6453
|
this.checkLValSimple(left);
|
|
6445
6454
|
}
|
|
6446
|
-
|
|
6455
|
+
node.left = left;
|
|
6447
6456
|
this.next();
|
|
6448
|
-
|
|
6457
|
+
node.right = this.parseMaybeAssign(forInit);
|
|
6449
6458
|
if (oldDoubleProto > -1) {
|
|
6450
6459
|
refDestructuringErrors.doubleProto = oldDoubleProto;
|
|
6451
6460
|
}
|
|
6452
|
-
return this.finishNode(
|
|
6461
|
+
return this.finishNode(node, "AssignmentExpression");
|
|
6453
6462
|
} else {
|
|
6454
6463
|
if (ownDestructuringErrors) {
|
|
6455
6464
|
this.checkExpressionErrors(refDestructuringErrors, true);
|
|
@@ -6470,12 +6479,12 @@ pp$5.parseMaybeConditional = function(forInit, refDestructuringErrors) {
|
|
|
6470
6479
|
return expr;
|
|
6471
6480
|
}
|
|
6472
6481
|
if (this.eat(types$1.question)) {
|
|
6473
|
-
var
|
|
6474
|
-
|
|
6475
|
-
|
|
6482
|
+
var node = this.startNodeAt(startPos, startLoc);
|
|
6483
|
+
node.test = expr;
|
|
6484
|
+
node.consequent = this.parseMaybeAssign();
|
|
6476
6485
|
this.expect(types$1.colon);
|
|
6477
|
-
|
|
6478
|
-
return this.finishNode(
|
|
6486
|
+
node.alternate = this.parseMaybeAssign(forInit);
|
|
6487
|
+
return this.finishNode(node, "ConditionalExpression");
|
|
6479
6488
|
}
|
|
6480
6489
|
return expr;
|
|
6481
6490
|
};
|
|
@@ -6500,11 +6509,11 @@ pp$5.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, forInit)
|
|
|
6500
6509
|
this.next();
|
|
6501
6510
|
var startPos = this.start, startLoc = this.startLoc;
|
|
6502
6511
|
var right = this.parseExprOp(this.parseMaybeUnary(null, false, false, forInit), startPos, startLoc, prec, forInit);
|
|
6503
|
-
var
|
|
6512
|
+
var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce);
|
|
6504
6513
|
if (logical && this.type === types$1.coalesce || coalesce && (this.type === types$1.logicalOR || this.type === types$1.logicalAND)) {
|
|
6505
6514
|
this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses");
|
|
6506
6515
|
}
|
|
6507
|
-
return this.parseExprOp(
|
|
6516
|
+
return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, forInit);
|
|
6508
6517
|
}
|
|
6509
6518
|
}
|
|
6510
6519
|
return left;
|
|
@@ -6513,11 +6522,11 @@ pp$5.buildBinary = function(startPos, startLoc, left, right, op, logical) {
|
|
|
6513
6522
|
if (right.type === "PrivateIdentifier") {
|
|
6514
6523
|
this.raise(right.start, "Private identifier can only be left side of binary expression");
|
|
6515
6524
|
}
|
|
6516
|
-
var
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
return this.finishNode(
|
|
6525
|
+
var node = this.startNodeAt(startPos, startLoc);
|
|
6526
|
+
node.left = left;
|
|
6527
|
+
node.operator = op;
|
|
6528
|
+
node.right = right;
|
|
6529
|
+
return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression");
|
|
6521
6530
|
};
|
|
6522
6531
|
pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forInit) {
|
|
6523
6532
|
var startPos = this.start, startLoc = this.startLoc, expr;
|
|
@@ -6525,22 +6534,22 @@ pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forIni
|
|
|
6525
6534
|
expr = this.parseAwait(forInit);
|
|
6526
6535
|
sawUnary = true;
|
|
6527
6536
|
} else if (this.type.prefix) {
|
|
6528
|
-
var
|
|
6529
|
-
|
|
6530
|
-
|
|
6537
|
+
var node = this.startNode(), update = this.type === types$1.incDec;
|
|
6538
|
+
node.operator = this.value;
|
|
6539
|
+
node.prefix = true;
|
|
6531
6540
|
this.next();
|
|
6532
|
-
|
|
6541
|
+
node.argument = this.parseMaybeUnary(null, true, update, forInit);
|
|
6533
6542
|
this.checkExpressionErrors(refDestructuringErrors, true);
|
|
6534
6543
|
if (update) {
|
|
6535
|
-
this.checkLValSimple(
|
|
6536
|
-
} else if (this.strict &&
|
|
6537
|
-
this.raiseRecoverable(
|
|
6538
|
-
} else if (
|
|
6539
|
-
this.raiseRecoverable(
|
|
6544
|
+
this.checkLValSimple(node.argument);
|
|
6545
|
+
} else if (this.strict && node.operator === "delete" && node.argument.type === "Identifier") {
|
|
6546
|
+
this.raiseRecoverable(node.start, "Deleting local variable in strict mode");
|
|
6547
|
+
} else if (node.operator === "delete" && isPrivateFieldAccess(node.argument)) {
|
|
6548
|
+
this.raiseRecoverable(node.start, "Private fields can not be deleted");
|
|
6540
6549
|
} else {
|
|
6541
6550
|
sawUnary = true;
|
|
6542
6551
|
}
|
|
6543
|
-
expr = this.finishNode(
|
|
6552
|
+
expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
|
|
6544
6553
|
} else if (!sawUnary && this.type === types$1.privateId) {
|
|
6545
6554
|
if ((forInit || this.privateNameStack.length === 0) && this.options.checkPrivateFields) {
|
|
6546
6555
|
this.unexpected();
|
|
@@ -6574,8 +6583,8 @@ pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forIni
|
|
|
6574
6583
|
return expr;
|
|
6575
6584
|
}
|
|
6576
6585
|
};
|
|
6577
|
-
function isPrivateFieldAccess(
|
|
6578
|
-
return
|
|
6586
|
+
function isPrivateFieldAccess(node) {
|
|
6587
|
+
return node.type === "MemberExpression" && node.property.type === "PrivateIdentifier" || node.type === "ChainExpression" && isPrivateFieldAccess(node.expression);
|
|
6579
6588
|
}
|
|
6580
6589
|
pp$5.parseExprSubscripts = function(refDestructuringErrors, forInit) {
|
|
6581
6590
|
var startPos = this.start, startLoc = this.startLoc;
|
|
@@ -6630,21 +6639,21 @@ pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArro
|
|
|
6630
6639
|
}
|
|
6631
6640
|
var computed = this.eat(types$1.bracketL);
|
|
6632
6641
|
if (computed || optional && this.type !== types$1.parenL && this.type !== types$1.backQuote || this.eat(types$1.dot)) {
|
|
6633
|
-
var
|
|
6634
|
-
|
|
6642
|
+
var node = this.startNodeAt(startPos, startLoc);
|
|
6643
|
+
node.object = base;
|
|
6635
6644
|
if (computed) {
|
|
6636
|
-
|
|
6645
|
+
node.property = this.parseExpression();
|
|
6637
6646
|
this.expect(types$1.bracketR);
|
|
6638
6647
|
} else if (this.type === types$1.privateId && base.type !== "Super") {
|
|
6639
|
-
|
|
6648
|
+
node.property = this.parsePrivateIdent();
|
|
6640
6649
|
} else {
|
|
6641
|
-
|
|
6650
|
+
node.property = this.parseIdent(this.options.allowReserved !== "never");
|
|
6642
6651
|
}
|
|
6643
|
-
|
|
6652
|
+
node.computed = !!computed;
|
|
6644
6653
|
if (optionalSupported) {
|
|
6645
|
-
|
|
6654
|
+
node.optional = optional;
|
|
6646
6655
|
}
|
|
6647
|
-
base = this.finishNode(
|
|
6656
|
+
base = this.finishNode(node, "MemberExpression");
|
|
6648
6657
|
} else if (!noCalls && this.eat(types$1.parenL)) {
|
|
6649
6658
|
var refDestructuringErrors = new DestructuringErrors(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
|
|
6650
6659
|
this.yieldPos = 0;
|
|
@@ -6688,25 +6697,25 @@ pp$5.parseExprAtom = function(refDestructuringErrors, forInit, forNew) {
|
|
|
6688
6697
|
if (this.type === types$1.slash) {
|
|
6689
6698
|
this.readRegexp();
|
|
6690
6699
|
}
|
|
6691
|
-
var
|
|
6700
|
+
var node, canBeArrow = this.potentialArrowAt === this.start;
|
|
6692
6701
|
switch (this.type) {
|
|
6693
6702
|
case types$1._super:
|
|
6694
6703
|
if (!this.allowSuper) {
|
|
6695
6704
|
this.raise(this.start, "'super' keyword outside a method");
|
|
6696
6705
|
}
|
|
6697
|
-
|
|
6706
|
+
node = this.startNode();
|
|
6698
6707
|
this.next();
|
|
6699
6708
|
if (this.type === types$1.parenL && !this.allowDirectSuper) {
|
|
6700
|
-
this.raise(
|
|
6709
|
+
this.raise(node.start, "super() call outside constructor of a subclass");
|
|
6701
6710
|
}
|
|
6702
6711
|
if (this.type !== types$1.dot && this.type !== types$1.bracketL && this.type !== types$1.parenL) {
|
|
6703
6712
|
this.unexpected();
|
|
6704
6713
|
}
|
|
6705
|
-
return this.finishNode(
|
|
6714
|
+
return this.finishNode(node, "Super");
|
|
6706
6715
|
case types$1._this:
|
|
6707
|
-
|
|
6716
|
+
node = this.startNode();
|
|
6708
6717
|
this.next();
|
|
6709
|
-
return this.finishNode(
|
|
6718
|
+
return this.finishNode(node, "ThisExpression");
|
|
6710
6719
|
case types$1.name:
|
|
6711
6720
|
var startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc;
|
|
6712
6721
|
var id = this.parseIdent(false);
|
|
@@ -6729,20 +6738,20 @@ pp$5.parseExprAtom = function(refDestructuringErrors, forInit, forNew) {
|
|
|
6729
6738
|
return id;
|
|
6730
6739
|
case types$1.regexp:
|
|
6731
6740
|
var value = this.value;
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
return
|
|
6741
|
+
node = this.parseLiteral(value.value);
|
|
6742
|
+
node.regex = { pattern: value.pattern, flags: value.flags };
|
|
6743
|
+
return node;
|
|
6735
6744
|
case types$1.num:
|
|
6736
6745
|
case types$1.string:
|
|
6737
6746
|
return this.parseLiteral(this.value);
|
|
6738
6747
|
case types$1._null:
|
|
6739
6748
|
case types$1._true:
|
|
6740
6749
|
case types$1._false:
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6750
|
+
node = this.startNode();
|
|
6751
|
+
node.value = this.type === types$1._null ? null : this.type === types$1._true;
|
|
6752
|
+
node.raw = this.type.keyword;
|
|
6744
6753
|
this.next();
|
|
6745
|
-
return this.finishNode(
|
|
6754
|
+
return this.finishNode(node, "Literal");
|
|
6746
6755
|
case types$1.parenL:
|
|
6747
6756
|
var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow, forInit);
|
|
6748
6757
|
if (refDestructuringErrors) {
|
|
@@ -6755,17 +6764,17 @@ pp$5.parseExprAtom = function(refDestructuringErrors, forInit, forNew) {
|
|
|
6755
6764
|
}
|
|
6756
6765
|
return expr;
|
|
6757
6766
|
case types$1.bracketL:
|
|
6758
|
-
|
|
6767
|
+
node = this.startNode();
|
|
6759
6768
|
this.next();
|
|
6760
|
-
|
|
6761
|
-
return this.finishNode(
|
|
6769
|
+
node.elements = this.parseExprList(types$1.bracketR, true, true, refDestructuringErrors);
|
|
6770
|
+
return this.finishNode(node, "ArrayExpression");
|
|
6762
6771
|
case types$1.braceL:
|
|
6763
6772
|
this.overrideContext(types.b_expr);
|
|
6764
6773
|
return this.parseObj(false, refDestructuringErrors);
|
|
6765
6774
|
case types$1._function:
|
|
6766
|
-
|
|
6775
|
+
node = this.startNode();
|
|
6767
6776
|
this.next();
|
|
6768
|
-
return this.parseFunction(
|
|
6777
|
+
return this.parseFunction(node, 0);
|
|
6769
6778
|
case types$1._class:
|
|
6770
6779
|
return this.parseClass(this.startNode(), false);
|
|
6771
6780
|
case types$1._new:
|
|
@@ -6786,25 +6795,25 @@ pp$5.parseExprAtomDefault = function() {
|
|
|
6786
6795
|
this.unexpected();
|
|
6787
6796
|
};
|
|
6788
6797
|
pp$5.parseExprImport = function(forNew) {
|
|
6789
|
-
var
|
|
6798
|
+
var node = this.startNode();
|
|
6790
6799
|
if (this.containsEsc) {
|
|
6791
6800
|
this.raiseRecoverable(this.start, "Escape sequence in keyword import");
|
|
6792
6801
|
}
|
|
6793
6802
|
this.next();
|
|
6794
6803
|
if (this.type === types$1.parenL && !forNew) {
|
|
6795
|
-
return this.parseDynamicImport(
|
|
6804
|
+
return this.parseDynamicImport(node);
|
|
6796
6805
|
} else if (this.type === types$1.dot) {
|
|
6797
|
-
var meta = this.startNodeAt(
|
|
6806
|
+
var meta = this.startNodeAt(node.start, node.loc && node.loc.start);
|
|
6798
6807
|
meta.name = "import";
|
|
6799
|
-
|
|
6800
|
-
return this.parseImportMeta(
|
|
6808
|
+
node.meta = this.finishNode(meta, "Identifier");
|
|
6809
|
+
return this.parseImportMeta(node);
|
|
6801
6810
|
} else {
|
|
6802
6811
|
this.unexpected();
|
|
6803
6812
|
}
|
|
6804
6813
|
};
|
|
6805
|
-
pp$5.parseDynamicImport = function(
|
|
6814
|
+
pp$5.parseDynamicImport = function(node) {
|
|
6806
6815
|
this.next();
|
|
6807
|
-
|
|
6816
|
+
node.source = this.parseMaybeAssign();
|
|
6808
6817
|
if (!this.eat(types$1.parenR)) {
|
|
6809
6818
|
var errorPos = this.start;
|
|
6810
6819
|
if (this.eat(types$1.comma) && this.eat(types$1.parenR)) {
|
|
@@ -6813,32 +6822,32 @@ pp$5.parseDynamicImport = function(node2) {
|
|
|
6813
6822
|
this.unexpected(errorPos);
|
|
6814
6823
|
}
|
|
6815
6824
|
}
|
|
6816
|
-
return this.finishNode(
|
|
6825
|
+
return this.finishNode(node, "ImportExpression");
|
|
6817
6826
|
};
|
|
6818
|
-
pp$5.parseImportMeta = function(
|
|
6827
|
+
pp$5.parseImportMeta = function(node) {
|
|
6819
6828
|
this.next();
|
|
6820
6829
|
var containsEsc = this.containsEsc;
|
|
6821
|
-
|
|
6822
|
-
if (
|
|
6823
|
-
this.raiseRecoverable(
|
|
6830
|
+
node.property = this.parseIdent(true);
|
|
6831
|
+
if (node.property.name !== "meta") {
|
|
6832
|
+
this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'");
|
|
6824
6833
|
}
|
|
6825
6834
|
if (containsEsc) {
|
|
6826
|
-
this.raiseRecoverable(
|
|
6835
|
+
this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters");
|
|
6827
6836
|
}
|
|
6828
6837
|
if (this.options.sourceType !== "module" && !this.options.allowImportExportEverywhere) {
|
|
6829
|
-
this.raiseRecoverable(
|
|
6838
|
+
this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module");
|
|
6830
6839
|
}
|
|
6831
|
-
return this.finishNode(
|
|
6840
|
+
return this.finishNode(node, "MetaProperty");
|
|
6832
6841
|
};
|
|
6833
6842
|
pp$5.parseLiteral = function(value) {
|
|
6834
|
-
var
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
if (
|
|
6838
|
-
|
|
6843
|
+
var node = this.startNode();
|
|
6844
|
+
node.value = value;
|
|
6845
|
+
node.raw = this.input.slice(this.start, this.end);
|
|
6846
|
+
if (node.raw.charCodeAt(node.raw.length - 1) === 110) {
|
|
6847
|
+
node.bigint = node.raw.slice(0, -1).replace(/_/g, "");
|
|
6839
6848
|
}
|
|
6840
6849
|
this.next();
|
|
6841
|
-
return this.finishNode(
|
|
6850
|
+
return this.finishNode(node, "Literal");
|
|
6842
6851
|
};
|
|
6843
6852
|
pp$5.parseParenExpression = function() {
|
|
6844
6853
|
this.expect(types$1.parenL);
|
|
@@ -6924,34 +6933,34 @@ pp$5.parseNew = function() {
|
|
|
6924
6933
|
if (this.containsEsc) {
|
|
6925
6934
|
this.raiseRecoverable(this.start, "Escape sequence in keyword new");
|
|
6926
6935
|
}
|
|
6927
|
-
var
|
|
6936
|
+
var node = this.startNode();
|
|
6928
6937
|
this.next();
|
|
6929
6938
|
if (this.options.ecmaVersion >= 6 && this.type === types$1.dot) {
|
|
6930
|
-
var meta = this.startNodeAt(
|
|
6939
|
+
var meta = this.startNodeAt(node.start, node.loc && node.loc.start);
|
|
6931
6940
|
meta.name = "new";
|
|
6932
|
-
|
|
6941
|
+
node.meta = this.finishNode(meta, "Identifier");
|
|
6933
6942
|
this.next();
|
|
6934
6943
|
var containsEsc = this.containsEsc;
|
|
6935
|
-
|
|
6936
|
-
if (
|
|
6937
|
-
this.raiseRecoverable(
|
|
6944
|
+
node.property = this.parseIdent(true);
|
|
6945
|
+
if (node.property.name !== "target") {
|
|
6946
|
+
this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'");
|
|
6938
6947
|
}
|
|
6939
6948
|
if (containsEsc) {
|
|
6940
|
-
this.raiseRecoverable(
|
|
6949
|
+
this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters");
|
|
6941
6950
|
}
|
|
6942
6951
|
if (!this.allowNewDotTarget) {
|
|
6943
|
-
this.raiseRecoverable(
|
|
6952
|
+
this.raiseRecoverable(node.start, "'new.target' can only be used in functions and class static block");
|
|
6944
6953
|
}
|
|
6945
|
-
return this.finishNode(
|
|
6954
|
+
return this.finishNode(node, "MetaProperty");
|
|
6946
6955
|
}
|
|
6947
6956
|
var startPos = this.start, startLoc = this.startLoc;
|
|
6948
|
-
|
|
6957
|
+
node.callee = this.parseSubscripts(this.parseExprAtom(null, false, true), startPos, startLoc, true, false);
|
|
6949
6958
|
if (this.eat(types$1.parenL)) {
|
|
6950
|
-
|
|
6959
|
+
node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false);
|
|
6951
6960
|
} else {
|
|
6952
|
-
|
|
6961
|
+
node.arguments = empty;
|
|
6953
6962
|
}
|
|
6954
|
-
return this.finishNode(
|
|
6963
|
+
return this.finishNode(node, "NewExpression");
|
|
6955
6964
|
};
|
|
6956
6965
|
pp$5.parseTemplateElement = function(ref2) {
|
|
6957
6966
|
var isTagged = ref2.isTagged;
|
|
@@ -6980,29 +6989,29 @@ pp$5.parseTemplate = function(ref2) {
|
|
|
6980
6989
|
var isTagged = ref2.isTagged;
|
|
6981
6990
|
if (isTagged === void 0)
|
|
6982
6991
|
isTagged = false;
|
|
6983
|
-
var
|
|
6992
|
+
var node = this.startNode();
|
|
6984
6993
|
this.next();
|
|
6985
|
-
|
|
6994
|
+
node.expressions = [];
|
|
6986
6995
|
var curElt = this.parseTemplateElement({ isTagged });
|
|
6987
|
-
|
|
6996
|
+
node.quasis = [curElt];
|
|
6988
6997
|
while (!curElt.tail) {
|
|
6989
6998
|
if (this.type === types$1.eof) {
|
|
6990
6999
|
this.raise(this.pos, "Unterminated template literal");
|
|
6991
7000
|
}
|
|
6992
7001
|
this.expect(types$1.dollarBraceL);
|
|
6993
|
-
|
|
7002
|
+
node.expressions.push(this.parseExpression());
|
|
6994
7003
|
this.expect(types$1.braceR);
|
|
6995
|
-
|
|
7004
|
+
node.quasis.push(curElt = this.parseTemplateElement({ isTagged }));
|
|
6996
7005
|
}
|
|
6997
7006
|
this.next();
|
|
6998
|
-
return this.finishNode(
|
|
7007
|
+
return this.finishNode(node, "TemplateLiteral");
|
|
6999
7008
|
};
|
|
7000
7009
|
pp$5.isAsyncProp = function(prop) {
|
|
7001
7010
|
return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" && (this.type === types$1.name || this.type === types$1.num || this.type === types$1.string || this.type === types$1.bracketL || this.type.keyword || this.options.ecmaVersion >= 9 && this.type === types$1.star) && !lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
|
|
7002
7011
|
};
|
|
7003
7012
|
pp$5.parseObj = function(isPattern, refDestructuringErrors) {
|
|
7004
|
-
var
|
|
7005
|
-
|
|
7013
|
+
var node = this.startNode(), first = true, propHash = {};
|
|
7014
|
+
node.properties = [];
|
|
7006
7015
|
this.next();
|
|
7007
7016
|
while (!this.eat(types$1.braceR)) {
|
|
7008
7017
|
if (!first) {
|
|
@@ -7017,9 +7026,9 @@ pp$5.parseObj = function(isPattern, refDestructuringErrors) {
|
|
|
7017
7026
|
if (!isPattern) {
|
|
7018
7027
|
this.checkPropClash(prop, propHash, refDestructuringErrors);
|
|
7019
7028
|
}
|
|
7020
|
-
|
|
7029
|
+
node.properties.push(prop);
|
|
7021
7030
|
}
|
|
7022
|
-
return this.finishNode(
|
|
7031
|
+
return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression");
|
|
7023
7032
|
};
|
|
7024
7033
|
pp$5.parseProperty = function(isPattern, refDestructuringErrors) {
|
|
7025
7034
|
var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc;
|
|
@@ -7134,67 +7143,67 @@ pp$5.parsePropertyName = function(prop) {
|
|
|
7134
7143
|
}
|
|
7135
7144
|
return prop.key = this.type === types$1.num || this.type === types$1.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never");
|
|
7136
7145
|
};
|
|
7137
|
-
pp$5.initFunction = function(
|
|
7138
|
-
|
|
7146
|
+
pp$5.initFunction = function(node) {
|
|
7147
|
+
node.id = null;
|
|
7139
7148
|
if (this.options.ecmaVersion >= 6) {
|
|
7140
|
-
|
|
7149
|
+
node.generator = node.expression = false;
|
|
7141
7150
|
}
|
|
7142
7151
|
if (this.options.ecmaVersion >= 8) {
|
|
7143
|
-
|
|
7152
|
+
node.async = false;
|
|
7144
7153
|
}
|
|
7145
7154
|
};
|
|
7146
7155
|
pp$5.parseMethod = function(isGenerator, isAsync, allowDirectSuper) {
|
|
7147
|
-
var
|
|
7148
|
-
this.initFunction(
|
|
7156
|
+
var node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
|
|
7157
|
+
this.initFunction(node);
|
|
7149
7158
|
if (this.options.ecmaVersion >= 6) {
|
|
7150
|
-
|
|
7159
|
+
node.generator = isGenerator;
|
|
7151
7160
|
}
|
|
7152
7161
|
if (this.options.ecmaVersion >= 8) {
|
|
7153
|
-
|
|
7162
|
+
node.async = !!isAsync;
|
|
7154
7163
|
}
|
|
7155
7164
|
this.yieldPos = 0;
|
|
7156
7165
|
this.awaitPos = 0;
|
|
7157
7166
|
this.awaitIdentPos = 0;
|
|
7158
|
-
this.enterScope(functionFlags(isAsync,
|
|
7167
|
+
this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0));
|
|
7159
7168
|
this.expect(types$1.parenL);
|
|
7160
|
-
|
|
7169
|
+
node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8);
|
|
7161
7170
|
this.checkYieldAwaitInDefaultParams();
|
|
7162
|
-
this.parseFunctionBody(
|
|
7171
|
+
this.parseFunctionBody(node, false, true, false);
|
|
7163
7172
|
this.yieldPos = oldYieldPos;
|
|
7164
7173
|
this.awaitPos = oldAwaitPos;
|
|
7165
7174
|
this.awaitIdentPos = oldAwaitIdentPos;
|
|
7166
|
-
return this.finishNode(
|
|
7175
|
+
return this.finishNode(node, "FunctionExpression");
|
|
7167
7176
|
};
|
|
7168
|
-
pp$5.parseArrowExpression = function(
|
|
7177
|
+
pp$5.parseArrowExpression = function(node, params, isAsync, forInit) {
|
|
7169
7178
|
var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
|
|
7170
7179
|
this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW);
|
|
7171
|
-
this.initFunction(
|
|
7180
|
+
this.initFunction(node);
|
|
7172
7181
|
if (this.options.ecmaVersion >= 8) {
|
|
7173
|
-
|
|
7182
|
+
node.async = !!isAsync;
|
|
7174
7183
|
}
|
|
7175
7184
|
this.yieldPos = 0;
|
|
7176
7185
|
this.awaitPos = 0;
|
|
7177
7186
|
this.awaitIdentPos = 0;
|
|
7178
|
-
|
|
7179
|
-
this.parseFunctionBody(
|
|
7187
|
+
node.params = this.toAssignableList(params, true);
|
|
7188
|
+
this.parseFunctionBody(node, true, false, forInit);
|
|
7180
7189
|
this.yieldPos = oldYieldPos;
|
|
7181
7190
|
this.awaitPos = oldAwaitPos;
|
|
7182
7191
|
this.awaitIdentPos = oldAwaitIdentPos;
|
|
7183
|
-
return this.finishNode(
|
|
7192
|
+
return this.finishNode(node, "ArrowFunctionExpression");
|
|
7184
7193
|
};
|
|
7185
|
-
pp$5.parseFunctionBody = function(
|
|
7194
|
+
pp$5.parseFunctionBody = function(node, isArrowFunction, isMethod, forInit) {
|
|
7186
7195
|
var isExpression = isArrowFunction && this.type !== types$1.braceL;
|
|
7187
7196
|
var oldStrict = this.strict, useStrict = false;
|
|
7188
7197
|
if (isExpression) {
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
this.checkParams(
|
|
7198
|
+
node.body = this.parseMaybeAssign(forInit);
|
|
7199
|
+
node.expression = true;
|
|
7200
|
+
this.checkParams(node, false);
|
|
7192
7201
|
} else {
|
|
7193
|
-
var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(
|
|
7202
|
+
var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params);
|
|
7194
7203
|
if (!oldStrict || nonSimple) {
|
|
7195
7204
|
useStrict = this.strictDirective(this.end);
|
|
7196
7205
|
if (useStrict && nonSimple) {
|
|
7197
|
-
this.raiseRecoverable(
|
|
7206
|
+
this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list");
|
|
7198
7207
|
}
|
|
7199
7208
|
}
|
|
7200
7209
|
var oldLabels = this.labels;
|
|
@@ -7202,13 +7211,13 @@ pp$5.parseFunctionBody = function(node2, isArrowFunction, isMethod, forInit) {
|
|
|
7202
7211
|
if (useStrict) {
|
|
7203
7212
|
this.strict = true;
|
|
7204
7213
|
}
|
|
7205
|
-
this.checkParams(
|
|
7206
|
-
if (this.strict &&
|
|
7207
|
-
this.checkLValSimple(
|
|
7214
|
+
this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params));
|
|
7215
|
+
if (this.strict && node.id) {
|
|
7216
|
+
this.checkLValSimple(node.id, BIND_OUTSIDE);
|
|
7208
7217
|
}
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
this.adaptDirectivePrologue(
|
|
7218
|
+
node.body = this.parseBlock(false, void 0, useStrict && !oldStrict);
|
|
7219
|
+
node.expression = false;
|
|
7220
|
+
this.adaptDirectivePrologue(node.body.body);
|
|
7212
7221
|
this.labels = oldLabels;
|
|
7213
7222
|
}
|
|
7214
7223
|
this.exitScope();
|
|
@@ -7222,9 +7231,9 @@ pp$5.isSimpleParamList = function(params) {
|
|
|
7222
7231
|
}
|
|
7223
7232
|
return true;
|
|
7224
7233
|
};
|
|
7225
|
-
pp$5.checkParams = function(
|
|
7234
|
+
pp$5.checkParams = function(node, allowDuplicates) {
|
|
7226
7235
|
var nameHash = /* @__PURE__ */ Object.create(null);
|
|
7227
|
-
for (var i = 0, list =
|
|
7236
|
+
for (var i = 0, list = node.params; i < list.length; i += 1) {
|
|
7228
7237
|
var param = list[i];
|
|
7229
7238
|
this.checkLValInnerPattern(param, BIND_VAR, allowDuplicates ? null : nameHash);
|
|
7230
7239
|
}
|
|
@@ -7286,73 +7295,73 @@ pp$5.checkUnreserved = function(ref2) {
|
|
|
7286
7295
|
}
|
|
7287
7296
|
};
|
|
7288
7297
|
pp$5.parseIdent = function(liberal) {
|
|
7289
|
-
var
|
|
7298
|
+
var node = this.parseIdentNode();
|
|
7290
7299
|
this.next(!!liberal);
|
|
7291
|
-
this.finishNode(
|
|
7300
|
+
this.finishNode(node, "Identifier");
|
|
7292
7301
|
if (!liberal) {
|
|
7293
|
-
this.checkUnreserved(
|
|
7294
|
-
if (
|
|
7295
|
-
this.awaitIdentPos =
|
|
7302
|
+
this.checkUnreserved(node);
|
|
7303
|
+
if (node.name === "await" && !this.awaitIdentPos) {
|
|
7304
|
+
this.awaitIdentPos = node.start;
|
|
7296
7305
|
}
|
|
7297
7306
|
}
|
|
7298
|
-
return
|
|
7307
|
+
return node;
|
|
7299
7308
|
};
|
|
7300
7309
|
pp$5.parseIdentNode = function() {
|
|
7301
|
-
var
|
|
7310
|
+
var node = this.startNode();
|
|
7302
7311
|
if (this.type === types$1.name) {
|
|
7303
|
-
|
|
7312
|
+
node.name = this.value;
|
|
7304
7313
|
} else if (this.type.keyword) {
|
|
7305
|
-
|
|
7306
|
-
if ((
|
|
7314
|
+
node.name = this.type.keyword;
|
|
7315
|
+
if ((node.name === "class" || node.name === "function") && (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {
|
|
7307
7316
|
this.context.pop();
|
|
7308
7317
|
}
|
|
7309
7318
|
this.type = types$1.name;
|
|
7310
7319
|
} else {
|
|
7311
7320
|
this.unexpected();
|
|
7312
7321
|
}
|
|
7313
|
-
return
|
|
7322
|
+
return node;
|
|
7314
7323
|
};
|
|
7315
7324
|
pp$5.parsePrivateIdent = function() {
|
|
7316
|
-
var
|
|
7325
|
+
var node = this.startNode();
|
|
7317
7326
|
if (this.type === types$1.privateId) {
|
|
7318
|
-
|
|
7327
|
+
node.name = this.value;
|
|
7319
7328
|
} else {
|
|
7320
7329
|
this.unexpected();
|
|
7321
7330
|
}
|
|
7322
7331
|
this.next();
|
|
7323
|
-
this.finishNode(
|
|
7332
|
+
this.finishNode(node, "PrivateIdentifier");
|
|
7324
7333
|
if (this.options.checkPrivateFields) {
|
|
7325
7334
|
if (this.privateNameStack.length === 0) {
|
|
7326
|
-
this.raise(
|
|
7335
|
+
this.raise(node.start, "Private field '#" + node.name + "' must be declared in an enclosing class");
|
|
7327
7336
|
} else {
|
|
7328
|
-
this.privateNameStack[this.privateNameStack.length - 1].used.push(
|
|
7337
|
+
this.privateNameStack[this.privateNameStack.length - 1].used.push(node);
|
|
7329
7338
|
}
|
|
7330
7339
|
}
|
|
7331
|
-
return
|
|
7340
|
+
return node;
|
|
7332
7341
|
};
|
|
7333
7342
|
pp$5.parseYield = function(forInit) {
|
|
7334
7343
|
if (!this.yieldPos) {
|
|
7335
7344
|
this.yieldPos = this.start;
|
|
7336
7345
|
}
|
|
7337
|
-
var
|
|
7346
|
+
var node = this.startNode();
|
|
7338
7347
|
this.next();
|
|
7339
7348
|
if (this.type === types$1.semi || this.canInsertSemicolon() || this.type !== types$1.star && !this.type.startsExpr) {
|
|
7340
|
-
|
|
7341
|
-
|
|
7349
|
+
node.delegate = false;
|
|
7350
|
+
node.argument = null;
|
|
7342
7351
|
} else {
|
|
7343
|
-
|
|
7344
|
-
|
|
7352
|
+
node.delegate = this.eat(types$1.star);
|
|
7353
|
+
node.argument = this.parseMaybeAssign(forInit);
|
|
7345
7354
|
}
|
|
7346
|
-
return this.finishNode(
|
|
7355
|
+
return this.finishNode(node, "YieldExpression");
|
|
7347
7356
|
};
|
|
7348
7357
|
pp$5.parseAwait = function(forInit) {
|
|
7349
7358
|
if (!this.awaitPos) {
|
|
7350
7359
|
this.awaitPos = this.start;
|
|
7351
7360
|
}
|
|
7352
|
-
var
|
|
7361
|
+
var node = this.startNode();
|
|
7353
7362
|
this.next();
|
|
7354
|
-
|
|
7355
|
-
return this.finishNode(
|
|
7363
|
+
node.argument = this.parseMaybeUnary(null, true, false, forInit);
|
|
7364
|
+
return this.finishNode(node, "AwaitExpression");
|
|
7356
7365
|
};
|
|
7357
7366
|
var pp$4 = Parser.prototype;
|
|
7358
7367
|
pp$4.raise = function(pos, message) {
|
|
@@ -7472,27 +7481,27 @@ pp$2.startNode = function() {
|
|
|
7472
7481
|
pp$2.startNodeAt = function(pos, loc) {
|
|
7473
7482
|
return new Node(this, pos, loc);
|
|
7474
7483
|
};
|
|
7475
|
-
function finishNodeAt(
|
|
7476
|
-
|
|
7477
|
-
|
|
7484
|
+
function finishNodeAt(node, type, pos, loc) {
|
|
7485
|
+
node.type = type;
|
|
7486
|
+
node.end = pos;
|
|
7478
7487
|
if (this.options.locations) {
|
|
7479
|
-
|
|
7488
|
+
node.loc.end = loc;
|
|
7480
7489
|
}
|
|
7481
7490
|
if (this.options.ranges) {
|
|
7482
|
-
|
|
7491
|
+
node.range[1] = pos;
|
|
7483
7492
|
}
|
|
7484
|
-
return
|
|
7493
|
+
return node;
|
|
7485
7494
|
}
|
|
7486
|
-
pp$2.finishNode = function(
|
|
7487
|
-
return finishNodeAt.call(this,
|
|
7495
|
+
pp$2.finishNode = function(node, type) {
|
|
7496
|
+
return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc);
|
|
7488
7497
|
};
|
|
7489
|
-
pp$2.finishNodeAt = function(
|
|
7490
|
-
return finishNodeAt.call(this,
|
|
7498
|
+
pp$2.finishNodeAt = function(node, type, pos, loc) {
|
|
7499
|
+
return finishNodeAt.call(this, node, type, pos, loc);
|
|
7491
7500
|
};
|
|
7492
|
-
pp$2.copyNode = function(
|
|
7493
|
-
var newNode = new Node(this,
|
|
7494
|
-
for (var prop in
|
|
7495
|
-
newNode[prop] =
|
|
7501
|
+
pp$2.copyNode = function(node) {
|
|
7502
|
+
var newNode = new Node(this, node.start, this.startLoc);
|
|
7503
|
+
for (var prop in node) {
|
|
7504
|
+
newNode[prop] = node[prop];
|
|
7496
7505
|
}
|
|
7497
7506
|
return newNode;
|
|
7498
7507
|
};
|
|
@@ -8086,14 +8095,14 @@ pp$1.regexp_eatAtomEscape = function(state) {
|
|
|
8086
8095
|
pp$1.regexp_eatBackReference = function(state) {
|
|
8087
8096
|
var start = state.pos;
|
|
8088
8097
|
if (this.regexp_eatDecimalEscape(state)) {
|
|
8089
|
-
var
|
|
8098
|
+
var n2 = state.lastIntValue;
|
|
8090
8099
|
if (state.switchU) {
|
|
8091
|
-
if (
|
|
8092
|
-
state.maxBackReference =
|
|
8100
|
+
if (n2 > state.maxBackReference) {
|
|
8101
|
+
state.maxBackReference = n2;
|
|
8093
8102
|
}
|
|
8094
8103
|
return true;
|
|
8095
8104
|
}
|
|
8096
|
-
if (
|
|
8105
|
+
if (n2 <= state.numCapturingParens) {
|
|
8097
8106
|
return true;
|
|
8098
8107
|
}
|
|
8099
8108
|
state.pos = start;
|
|
@@ -9536,11 +9545,11 @@ pp.readEscapedChar = function(inTemplate) {
|
|
|
9536
9545
|
};
|
|
9537
9546
|
pp.readHexChar = function(len) {
|
|
9538
9547
|
var codePos = this.pos;
|
|
9539
|
-
var
|
|
9540
|
-
if (
|
|
9548
|
+
var n2 = this.readInt(16, len);
|
|
9549
|
+
if (n2 === null) {
|
|
9541
9550
|
this.invalidStringToken(codePos, "Bad character escape sequence");
|
|
9542
9551
|
}
|
|
9543
|
-
return
|
|
9552
|
+
return n2;
|
|
9544
9553
|
};
|
|
9545
9554
|
pp.readWord1 = function() {
|
|
9546
9555
|
this.containsEsc = false;
|
|
@@ -11045,75 +11054,41 @@ function resolvePackage(name, options = {}) {
|
|
|
11045
11054
|
}
|
|
11046
11055
|
}
|
|
11047
11056
|
|
|
11048
|
-
// src/configs/
|
|
11049
|
-
|
|
11057
|
+
// src/configs/antfu.ts
|
|
11058
|
+
var antfu = async () => {
|
|
11050
11059
|
return [
|
|
11051
11060
|
{
|
|
11052
|
-
name: "jsse:
|
|
11061
|
+
name: "jsse:antfu",
|
|
11053
11062
|
plugins: {
|
|
11054
11063
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
11055
|
-
|
|
11064
|
+
antfu: import_eslint_plugin_antfu.default
|
|
11056
11065
|
},
|
|
11057
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
11058
11066
|
rules: {
|
|
11059
|
-
|
|
11060
|
-
|
|
11067
|
+
"antfu/no-import-node-modules-by-path": "error",
|
|
11068
|
+
"antfu/top-level-function": "error"
|
|
11061
11069
|
}
|
|
11062
|
-
}
|
|
11063
|
-
];
|
|
11064
|
-
}
|
|
11065
|
-
|
|
11066
|
-
// src/configs/stylistic.ts
|
|
11067
|
-
function jsxStylistic({
|
|
11068
|
-
indent
|
|
11069
|
-
}) {
|
|
11070
|
-
return {
|
|
11071
|
-
"@stylistic/jsx-curly-brace-presence": [
|
|
11072
|
-
"error",
|
|
11073
|
-
{ propElementValues: "always" }
|
|
11074
|
-
],
|
|
11075
|
-
"@stylistic/jsx-indent": [
|
|
11076
|
-
"error",
|
|
11077
|
-
indent,
|
|
11078
|
-
{ checkAttributes: true, indentLogicalExpressions: true }
|
|
11079
|
-
],
|
|
11080
|
-
"@stylistic/jsx-quotes": "error"
|
|
11081
|
-
};
|
|
11082
|
-
}
|
|
11083
|
-
function stylistic(options = {}) {
|
|
11084
|
-
const { indent = 2, jsx = true, quotes = "double" } = options;
|
|
11085
|
-
return [
|
|
11070
|
+
},
|
|
11086
11071
|
{
|
|
11087
|
-
|
|
11088
|
-
|
|
11089
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
11090
|
-
"@stylistic": import_eslint_plugin.default
|
|
11091
|
-
},
|
|
11072
|
+
files: ["**/src/**/*"],
|
|
11073
|
+
name: "jsse:antfu:bin",
|
|
11092
11074
|
rules: {
|
|
11093
|
-
"
|
|
11094
|
-
|
|
11095
|
-
|
|
11096
|
-
|
|
11097
|
-
|
|
11098
|
-
|
|
11099
|
-
|
|
11075
|
+
"antfu/no-import-dist": "error"
|
|
11076
|
+
}
|
|
11077
|
+
},
|
|
11078
|
+
{
|
|
11079
|
+
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
11080
|
+
name: "jsse:antfu:bin",
|
|
11081
|
+
rules: {
|
|
11082
|
+
"antfu/no-import-dist": "off",
|
|
11083
|
+
"antfu/no-import-node-modules-by-path": "off"
|
|
11100
11084
|
}
|
|
11101
11085
|
}
|
|
11102
11086
|
];
|
|
11103
|
-
}
|
|
11104
|
-
|
|
11105
|
-
// src/slow.ts
|
|
11106
|
-
var slowRules = [
|
|
11107
|
-
"@typescript-eslint/no-misused-promises",
|
|
11108
|
-
"@typescript-eslint/no-unsafe-assignment",
|
|
11109
|
-
"@typescript-eslint/no-unsafe-call",
|
|
11110
|
-
"@typescript-eslint/no-unsafe-member-access",
|
|
11111
|
-
"@typescript-eslint/no-unsafe-return"
|
|
11112
|
-
];
|
|
11087
|
+
};
|
|
11113
11088
|
|
|
11114
11089
|
// src/configs/md.ts
|
|
11115
|
-
|
|
11116
|
-
const { componentExts = [], overrides = {} } = options;
|
|
11090
|
+
var markdown = async (options) => {
|
|
11091
|
+
const { componentExts = [], overrides = {} } = options ?? {};
|
|
11117
11092
|
const tsRulesOff = Object.fromEntries(
|
|
11118
11093
|
// @ts-expect-error - undefined
|
|
11119
11094
|
Object.keys(typescriptRulesTypeAware()).map((key) => [
|
|
@@ -11173,11 +11148,72 @@ function markdown(options = {}) {
|
|
|
11173
11148
|
}
|
|
11174
11149
|
}
|
|
11175
11150
|
];
|
|
11151
|
+
};
|
|
11152
|
+
|
|
11153
|
+
// src/configs/stylistic.ts
|
|
11154
|
+
function jsxStylistic({
|
|
11155
|
+
indent
|
|
11156
|
+
}) {
|
|
11157
|
+
return {
|
|
11158
|
+
"@stylistic/jsx-curly-brace-presence": [
|
|
11159
|
+
"error",
|
|
11160
|
+
{ propElementValues: "always" }
|
|
11161
|
+
],
|
|
11162
|
+
"@stylistic/jsx-indent": [
|
|
11163
|
+
"error",
|
|
11164
|
+
indent,
|
|
11165
|
+
{ checkAttributes: true, indentLogicalExpressions: true }
|
|
11166
|
+
],
|
|
11167
|
+
"@stylistic/jsx-quotes": "error"
|
|
11168
|
+
};
|
|
11176
11169
|
}
|
|
11170
|
+
var stylistic = async (options) => {
|
|
11171
|
+
const { indent = 2, jsx = true, quotes = "double" } = options ?? {};
|
|
11172
|
+
return [
|
|
11173
|
+
{
|
|
11174
|
+
name: "jsse:stylistic",
|
|
11175
|
+
plugins: {
|
|
11176
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
11177
|
+
"@stylistic": import_eslint_plugin.default
|
|
11178
|
+
},
|
|
11179
|
+
rules: {
|
|
11180
|
+
"@stylistic/quote-props": ["error", "as-needed"],
|
|
11181
|
+
"@stylistic/quotes": [
|
|
11182
|
+
"error",
|
|
11183
|
+
quotes,
|
|
11184
|
+
{ allowTemplateLiterals: false, avoidEscape: true }
|
|
11185
|
+
],
|
|
11186
|
+
...jsx ? jsxStylistic({ indent }) : {}
|
|
11187
|
+
}
|
|
11188
|
+
}
|
|
11189
|
+
];
|
|
11190
|
+
};
|
|
11191
|
+
|
|
11192
|
+
// src/configs/tailwind.ts
|
|
11193
|
+
var tailwind = async () => {
|
|
11194
|
+
return [
|
|
11195
|
+
{
|
|
11196
|
+
name: "jsse:tailwind",
|
|
11197
|
+
plugins: {
|
|
11198
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
11199
|
+
tailwindcss: import_eslint_plugin_tailwindcss.default
|
|
11200
|
+
},
|
|
11201
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
11202
|
+
rules: {
|
|
11203
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
11204
|
+
...import_eslint_plugin_tailwindcss.default.configs.recommended.rules
|
|
11205
|
+
}
|
|
11206
|
+
}
|
|
11207
|
+
];
|
|
11208
|
+
};
|
|
11177
11209
|
|
|
11178
11210
|
// src/configs/yml.ts
|
|
11179
|
-
|
|
11180
|
-
const {
|
|
11211
|
+
var yml = async (options) => {
|
|
11212
|
+
const {
|
|
11213
|
+
files = [GLOB_YAML],
|
|
11214
|
+
overrides = {},
|
|
11215
|
+
stylistic: stylistic2 = true
|
|
11216
|
+
} = options ?? {};
|
|
11181
11217
|
const { indent = 2, quotes = "single" } = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
11182
11218
|
const [pluginYaml, parserYaml] = await Promise.all([
|
|
11183
11219
|
interopDefault(import("eslint-plugin-yml")),
|
|
@@ -11222,7 +11258,16 @@ async function yml(options = {}) {
|
|
|
11222
11258
|
}
|
|
11223
11259
|
}
|
|
11224
11260
|
];
|
|
11225
|
-
}
|
|
11261
|
+
};
|
|
11262
|
+
|
|
11263
|
+
// src/slow.ts
|
|
11264
|
+
var slowRules = [
|
|
11265
|
+
"@typescript-eslint/no-misused-promises",
|
|
11266
|
+
"@typescript-eslint/no-unsafe-assignment",
|
|
11267
|
+
"@typescript-eslint/no-unsafe-call",
|
|
11268
|
+
"@typescript-eslint/no-unsafe-member-access",
|
|
11269
|
+
"@typescript-eslint/no-unsafe-return"
|
|
11270
|
+
];
|
|
11226
11271
|
|
|
11227
11272
|
// src/factory.ts
|
|
11228
11273
|
var flatConfigProps = [
|
|
@@ -11310,12 +11355,13 @@ async function jsse(options = {}, ...userConfigs) {
|
|
|
11310
11355
|
reportUnusedDisableDirectives
|
|
11311
11356
|
}),
|
|
11312
11357
|
comments(),
|
|
11313
|
-
|
|
11358
|
+
n(),
|
|
11314
11359
|
jsdoc(),
|
|
11315
11360
|
imports({
|
|
11316
11361
|
stylistic: stylisticOptions
|
|
11317
11362
|
}),
|
|
11318
11363
|
unicorn(),
|
|
11364
|
+
antfu(),
|
|
11319
11365
|
perfectionist()
|
|
11320
11366
|
);
|
|
11321
11367
|
if (enableTypeScript) {
|
|
@@ -11355,7 +11401,7 @@ async function jsse(options = {}, ...userConfigs) {
|
|
|
11355
11401
|
}
|
|
11356
11402
|
if (normalizedOptions.test) {
|
|
11357
11403
|
configs.push(
|
|
11358
|
-
test({
|
|
11404
|
+
await test({
|
|
11359
11405
|
isInEditor: isInEditor2,
|
|
11360
11406
|
overrides: overrides.test
|
|
11361
11407
|
})
|
|
@@ -11393,7 +11439,15 @@ async function jsse(options = {}, ...userConfigs) {
|
|
|
11393
11439
|
}))
|
|
11394
11440
|
);
|
|
11395
11441
|
}
|
|
11396
|
-
|
|
11442
|
+
const combinedConfigs = await combineAsync(...configs, ...userConfigs);
|
|
11443
|
+
if (normalizedOptions.preReturn) {
|
|
11444
|
+
const preReturned = normalizedOptions.preReturn(combinedConfigs);
|
|
11445
|
+
if (preReturned instanceof Promise) {
|
|
11446
|
+
return await preReturned;
|
|
11447
|
+
}
|
|
11448
|
+
return preReturned;
|
|
11449
|
+
}
|
|
11450
|
+
return combinedConfigs;
|
|
11397
11451
|
}
|
|
11398
11452
|
|
|
11399
11453
|
// src/presets.ts
|
|
@@ -11435,6 +11489,7 @@ function jsseReact() {
|
|
|
11435
11489
|
GLOB_TSX,
|
|
11436
11490
|
GLOB_YAML,
|
|
11437
11491
|
combine,
|
|
11492
|
+
combineAsync,
|
|
11438
11493
|
comments,
|
|
11439
11494
|
eslintConfigPrettierRules,
|
|
11440
11495
|
ignores,
|
|
@@ -11448,10 +11503,11 @@ function jsseReact() {
|
|
|
11448
11503
|
jsse,
|
|
11449
11504
|
jsseReact,
|
|
11450
11505
|
jssestd,
|
|
11451
|
-
|
|
11506
|
+
n,
|
|
11452
11507
|
parserJsonc,
|
|
11453
11508
|
parserTs,
|
|
11454
11509
|
perfectionist,
|
|
11510
|
+
pluginAntfu,
|
|
11455
11511
|
pluginEslintComments,
|
|
11456
11512
|
pluginImport,
|
|
11457
11513
|
pluginJsdoc,
|