@dereekb/util 13.12.0 → 13.12.1

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.
@@ -907,7 +907,7 @@ function _non_iterable_rest$8() {
907
907
  function _sliced_to_array$8(arr, i) {
908
908
  return _array_with_holes$8(arr) || _iterable_to_array_limit$8(arr, i) || _unsupported_iterable_to_array$a(arr, i) || _non_iterable_rest$8();
909
909
  }
910
- function _type_of(obj) {
910
+ function _type_of$1(obj) {
911
911
  "@swc/helpers - typeof";
912
912
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
913
913
  }
@@ -1024,7 +1024,7 @@ function walkChildren(node, out) {
1024
1024
  * @param node - The AST node to traverse.
1025
1025
  * @param out - The accumulator array that receives counted `ReturnStatement` nodes.
1026
1026
  */ function collectCountedReturns(node, out) {
1027
- if (node === null || (typeof node === "undefined" ? "undefined" : _type_of(node)) !== 'object') return;
1027
+ if (node === null || (typeof node === "undefined" ? "undefined" : _type_of$1(node)) !== 'object') return;
1028
1028
  if (Array.isArray(node)) {
1029
1029
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1030
1030
  try {
@@ -1875,6 +1875,10 @@ function _non_iterable_spread$2() {
1875
1875
  function _to_consumable_array$2(arr) {
1876
1876
  return _array_without_holes$2(arr) || _iterable_to_array$2(arr) || _unsupported_iterable_to_array$8(arr) || _non_iterable_spread$2();
1877
1877
  }
1878
+ function _type_of(obj) {
1879
+ "@swc/helpers - typeof";
1880
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1881
+ }
1878
1882
  function _unsupported_iterable_to_array$8(o, minLen) {
1879
1883
  if (!o) return;
1880
1884
  if (typeof o === "string") return _array_like_to_array$8(o, minLen);
@@ -2074,26 +2078,513 @@ function _unsupported_iterable_to_array$8(o, minLen) {
2074
2078
  return sourceCode.text.slice(range[0], range[1]);
2075
2079
  }
2076
2080
  /**
2077
- * Returns true when every deprecated statement in `deprecated` appears AFTER every non-deprecated
2078
- * analyzable statement in `analyzable` (i.e., the deprecated section is already at the bottom of
2079
- * the file). This is the condition under which the autofix can simply insert the marker without
2081
+ * Unwraps an `export` statement to the underlying declaration. Returns the node itself when it is
2082
+ * not an export wrapper.
2083
+ *
2084
+ * @param statement - The top-level statement node.
2085
+ * @returns The inner declaration for export wrappers, otherwise the statement itself.
2086
+ */ function unwrapDeclaration(statement) {
2087
+ var declaration = statement;
2088
+ if ((statement.type === 'ExportNamedDeclaration' || statement.type === 'ExportDefaultDeclaration') && statement.declaration != null) {
2089
+ declaration = statement.declaration;
2090
+ }
2091
+ return declaration;
2092
+ }
2093
+ /**
2094
+ * Recursively collects the binding names introduced by a binding pattern (`Identifier`,
2095
+ * `ObjectPattern`, `ArrayPattern`, including defaults and rest elements).
2096
+ *
2097
+ * @param node - A binding pattern to walk; missing array-pattern holes contribute no names.
2098
+ * @returns The flat list of bound identifier names.
2099
+ */ function collectPatternNames(node) {
2100
+ var names = [];
2101
+ if (node != null) {
2102
+ if (node.type === 'Identifier') {
2103
+ names.push(node.name);
2104
+ } else if (node.type === 'ObjectPattern') {
2105
+ var _node_properties;
2106
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2107
+ try {
2108
+ for(var _iterator = ((_node_properties = node.properties) !== null && _node_properties !== void 0 ? _node_properties : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2109
+ var property = _step.value;
2110
+ var _names;
2111
+ (_names = names).push.apply(_names, _to_consumable_array$2(collectPatternNames(property.type === 'RestElement' ? property.argument : property.value)));
2112
+ }
2113
+ } catch (err) {
2114
+ _didIteratorError = true;
2115
+ _iteratorError = err;
2116
+ } finally{
2117
+ try {
2118
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2119
+ _iterator.return();
2120
+ }
2121
+ } finally{
2122
+ if (_didIteratorError) {
2123
+ throw _iteratorError;
2124
+ }
2125
+ }
2126
+ }
2127
+ } else if (node.type === 'ArrayPattern') {
2128
+ var _node_elements;
2129
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
2130
+ try {
2131
+ for(var _iterator1 = ((_node_elements = node.elements) !== null && _node_elements !== void 0 ? _node_elements : [])[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
2132
+ var element = _step1.value;
2133
+ var _names1;
2134
+ (_names1 = names).push.apply(_names1, _to_consumable_array$2(collectPatternNames((element === null || element === void 0 ? void 0 : element.type) === 'RestElement' ? element.argument : element)));
2135
+ }
2136
+ } catch (err) {
2137
+ _didIteratorError1 = true;
2138
+ _iteratorError1 = err;
2139
+ } finally{
2140
+ try {
2141
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
2142
+ _iterator1.return();
2143
+ }
2144
+ } finally{
2145
+ if (_didIteratorError1) {
2146
+ throw _iteratorError1;
2147
+ }
2148
+ }
2149
+ }
2150
+ } else if (node.type === 'AssignmentPattern') {
2151
+ var _names2;
2152
+ (_names2 = names).push.apply(_names2, _to_consumable_array$2(collectPatternNames(node.left)));
2153
+ } else if (node.type === 'RestElement') {
2154
+ var _names3;
2155
+ (_names3 = names).push.apply(_names3, _to_consumable_array$2(collectPatternNames(node.argument)));
2156
+ }
2157
+ }
2158
+ return names;
2159
+ }
2160
+ /**
2161
+ * Returns the binding names a top-level statement introduces: variable declarator ids, an
2162
+ * import's local specifier names, or a function/class/interface/type/enum declaration id.
2163
+ *
2164
+ * @param statement - The top-level statement node.
2165
+ * @returns The names bound by the statement.
2166
+ */ function getDeclaredBindingNames(statement) {
2167
+ var _declaration_id;
2168
+ var names = [];
2169
+ var declaration = unwrapDeclaration(statement);
2170
+ if (declaration.type === 'VariableDeclaration') {
2171
+ var _declaration_declarations;
2172
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2173
+ try {
2174
+ for(var _iterator = ((_declaration_declarations = declaration.declarations) !== null && _declaration_declarations !== void 0 ? _declaration_declarations : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2175
+ var declarator = _step.value;
2176
+ var _names;
2177
+ (_names = names).push.apply(_names, _to_consumable_array$2(collectPatternNames(declarator.id)));
2178
+ }
2179
+ } catch (err) {
2180
+ _didIteratorError = true;
2181
+ _iteratorError = err;
2182
+ } finally{
2183
+ try {
2184
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2185
+ _iterator.return();
2186
+ }
2187
+ } finally{
2188
+ if (_didIteratorError) {
2189
+ throw _iteratorError;
2190
+ }
2191
+ }
2192
+ }
2193
+ } else if (declaration.type === 'ImportDeclaration') {
2194
+ var _declaration_specifiers;
2195
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
2196
+ try {
2197
+ for(var _iterator1 = ((_declaration_specifiers = declaration.specifiers) !== null && _declaration_specifiers !== void 0 ? _declaration_specifiers : [])[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
2198
+ var specifier = _step1.value;
2199
+ var _specifier_local;
2200
+ if (typeof ((_specifier_local = specifier.local) === null || _specifier_local === void 0 ? void 0 : _specifier_local.name) === 'string') {
2201
+ names.push(specifier.local.name);
2202
+ }
2203
+ }
2204
+ } catch (err) {
2205
+ _didIteratorError1 = true;
2206
+ _iteratorError1 = err;
2207
+ } finally{
2208
+ try {
2209
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
2210
+ _iterator1.return();
2211
+ }
2212
+ } finally{
2213
+ if (_didIteratorError1) {
2214
+ throw _iteratorError1;
2215
+ }
2216
+ }
2217
+ }
2218
+ } else if (((_declaration_id = declaration.id) === null || _declaration_id === void 0 ? void 0 : _declaration_id.type) === 'Identifier') {
2219
+ names.push(declaration.id.name);
2220
+ }
2221
+ return names;
2222
+ }
2223
+ /**
2224
+ * Returns true for AST-walk keys that must not be descended into: the `parent` back-reference
2225
+ * (which would escape the subtree) and the `loc`/`range` position metadata.
2226
+ *
2227
+ * @param key - The property key being considered for traversal.
2228
+ * @returns True when the key should be skipped.
2229
+ */ function isIdentifierWalkSkipKey(key) {
2230
+ return key === 'parent' || key === 'loc' || key === 'range';
2231
+ }
2232
+ /**
2233
+ * Collects every `Identifier` name reachable from an AST record (a node with a string `type`),
2234
+ * recursing into its child nodes while skipping the keys flagged by {@link isIdentifierWalkSkipKey}.
2235
+ *
2236
+ * @param record - An AST node, keyed by its properties.
2237
+ * @returns The set of identifier names found within the node.
2238
+ */ function collectIdentifierNamesFromRecord(record) {
2239
+ var names = new Set();
2240
+ if (record.type === 'Identifier' && typeof record.name === 'string') {
2241
+ names.add(record.name);
2242
+ }
2243
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2244
+ try {
2245
+ for(var _iterator = Object.keys(record)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2246
+ var key = _step.value;
2247
+ if (!isIdentifierWalkSkipKey(key)) {
2248
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
2249
+ try {
2250
+ for(var _iterator1 = collectIdentifierNames(record[key])[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
2251
+ var name = _step1.value;
2252
+ names.add(name);
2253
+ }
2254
+ } catch (err) {
2255
+ _didIteratorError1 = true;
2256
+ _iteratorError1 = err;
2257
+ } finally{
2258
+ try {
2259
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
2260
+ _iterator1.return();
2261
+ }
2262
+ } finally{
2263
+ if (_didIteratorError1) {
2264
+ throw _iteratorError1;
2265
+ }
2266
+ }
2267
+ }
2268
+ }
2269
+ }
2270
+ } catch (err) {
2271
+ _didIteratorError = true;
2272
+ _iteratorError = err;
2273
+ } finally{
2274
+ try {
2275
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2276
+ _iterator.return();
2277
+ }
2278
+ } finally{
2279
+ if (_didIteratorError) {
2280
+ throw _iteratorError;
2281
+ }
2282
+ }
2283
+ }
2284
+ return names;
2285
+ }
2286
+ /**
2287
+ * Recursively collects every `Identifier` name reachable from a value, staying within the subtree.
2288
+ *
2289
+ * Used both for the value-alias check (over a declarator `init`) and the reverse-reference safety
2290
+ * net (over a whole statement). Over-collection is acceptable for both callers: it only makes the
2291
+ * safety net more conservative and the alias check more permissive toward genuine aliases.
2292
+ *
2293
+ * @param node - The subtree root to scan (an AST node, an array of nodes, or a leaf value).
2294
+ * @returns The set of identifier names found in the subtree.
2295
+ */ function collectIdentifierNames(node) {
2296
+ var names = new Set();
2297
+ if (Array.isArray(node)) {
2298
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2299
+ try {
2300
+ for(var _iterator = node[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2301
+ var item = _step.value;
2302
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
2303
+ try {
2304
+ for(var _iterator1 = collectIdentifierNames(item)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
2305
+ var name = _step1.value;
2306
+ names.add(name);
2307
+ }
2308
+ } catch (err) {
2309
+ _didIteratorError1 = true;
2310
+ _iteratorError1 = err;
2311
+ } finally{
2312
+ try {
2313
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
2314
+ _iterator1.return();
2315
+ }
2316
+ } finally{
2317
+ if (_didIteratorError1) {
2318
+ throw _iteratorError1;
2319
+ }
2320
+ }
2321
+ }
2322
+ }
2323
+ } catch (err) {
2324
+ _didIteratorError = true;
2325
+ _iteratorError = err;
2326
+ } finally{
2327
+ try {
2328
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2329
+ _iterator.return();
2330
+ }
2331
+ } finally{
2332
+ if (_didIteratorError) {
2333
+ throw _iteratorError;
2334
+ }
2335
+ }
2336
+ }
2337
+ } else if (node != null && (typeof node === "undefined" ? "undefined" : _type_of(node)) === 'object' && typeof node.type === 'string') {
2338
+ names = collectIdentifierNamesFromRecord(node);
2339
+ }
2340
+ return names;
2341
+ }
2342
+ /**
2343
+ * Builds a map of every top-level binding name in the file to whether its declaration carries an
2344
+ * `@deprecated` tag. A name declared more than once is considered non-deprecated when any of its
2345
+ * declarations is non-deprecated.
2346
+ *
2347
+ * @param sourceCode - The ESLint `SourceCode` instance.
2348
+ * @param body - All top-level program-body statements.
2349
+ * @returns Whether each top-level binding name is declared as `@deprecated`, keyed by that name.
2350
+ */ function buildBindingDeprecationMap(sourceCode, body) {
2351
+ var bindingDeprecation = new Map();
2352
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2353
+ try {
2354
+ for(var _iterator = body[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2355
+ var statement = _step.value;
2356
+ var deprecated = statementIsDeprecated(sourceCode, statement);
2357
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
2358
+ try {
2359
+ for(var _iterator1 = getDeclaredBindingNames(statement)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
2360
+ var name = _step1.value;
2361
+ var existing = bindingDeprecation.get(name);
2362
+ bindingDeprecation.set(name, existing === undefined ? deprecated : existing && deprecated);
2363
+ }
2364
+ } catch (err) {
2365
+ _didIteratorError1 = true;
2366
+ _iteratorError1 = err;
2367
+ } finally{
2368
+ try {
2369
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
2370
+ _iterator1.return();
2371
+ }
2372
+ } finally{
2373
+ if (_didIteratorError1) {
2374
+ throw _iteratorError1;
2375
+ }
2376
+ }
2377
+ }
2378
+ }
2379
+ } catch (err) {
2380
+ _didIteratorError = true;
2381
+ _iteratorError = err;
2382
+ } finally{
2383
+ try {
2384
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2385
+ _iterator.return();
2386
+ }
2387
+ } finally{
2388
+ if (_didIteratorError) {
2389
+ throw _iteratorError;
2390
+ }
2391
+ }
2392
+ }
2393
+ return bindingDeprecation;
2394
+ }
2395
+ /**
2396
+ * Returns true when a `@deprecated` statement is a runtime *value alias* — a `VariableDeclaration`
2397
+ * whose initializer references a non-deprecated binding declared elsewhere in the file (or an
2398
+ * imported name). Literal-only initializers (`= 'SPED'`, `= 5`, object/array literals with no
2399
+ * variable references) are primary definitions, not aliases, and return false.
2400
+ *
2401
+ * @param sourceCode - The ESLint `SourceCode` instance.
2402
+ * @param statement - The top-level statement node.
2403
+ * @param bindingDeprecation - Map of top-level binding name to deprecation flag.
2404
+ * @returns True when the statement is a deprecated value alias.
2405
+ */ function statementIsValueAlias(sourceCode, statement, bindingDeprecation) {
2406
+ var isAlias = false;
2407
+ var declaration = unwrapDeclaration(statement);
2408
+ if (statementIsDeprecated(sourceCode, statement) && declaration.type === 'VariableDeclaration') {
2409
+ var _declaration_declarations;
2410
+ var ownNames = new Set(getDeclaredBindingNames(statement));
2411
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2412
+ try {
2413
+ for(var _iterator = ((_declaration_declarations = declaration.declarations) !== null && _declaration_declarations !== void 0 ? _declaration_declarations : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2414
+ var declarator = _step.value;
2415
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
2416
+ try {
2417
+ for(var _iterator1 = collectIdentifierNames(declarator.init)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
2418
+ var name = _step1.value;
2419
+ if (!ownNames.has(name) && bindingDeprecation.get(name) === false) {
2420
+ isAlias = true;
2421
+ }
2422
+ }
2423
+ } catch (err) {
2424
+ _didIteratorError1 = true;
2425
+ _iteratorError1 = err;
2426
+ } finally{
2427
+ try {
2428
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
2429
+ _iterator1.return();
2430
+ }
2431
+ } finally{
2432
+ if (_didIteratorError1) {
2433
+ throw _iteratorError1;
2434
+ }
2435
+ }
2436
+ }
2437
+ }
2438
+ } catch (err) {
2439
+ _didIteratorError = true;
2440
+ _iteratorError = err;
2441
+ } finally{
2442
+ try {
2443
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2444
+ _iterator.return();
2445
+ }
2446
+ } finally{
2447
+ if (_didIteratorError) {
2448
+ throw _iteratorError;
2449
+ }
2450
+ }
2451
+ }
2452
+ }
2453
+ return isAlias;
2454
+ }
2455
+ /**
2456
+ * Safety net for runtime value aliases: returns true when any name bound by `statement` is
2457
+ * referenced by some *other* top-level statement in the file. Relocating such a value below those
2458
+ * references would introduce a use-before-declaration / temporal-dead-zone error, so a referenced
2459
+ * alias must stay in place.
2460
+ *
2461
+ * @param names - The names bound by the candidate statement.
2462
+ * @param statement - The candidate statement (excluded from the scan).
2463
+ * @param body - All top-level program-body statements.
2464
+ * @returns True when another statement references one of `names`.
2465
+ */ function isReferencedByOtherStatements(names, statement, body) {
2466
+ var referenced = false;
2467
+ if (names.length !== 0) {
2468
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2469
+ try {
2470
+ for(var _iterator = body[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2471
+ var other = _step.value;
2472
+ if (other !== statement) {
2473
+ var otherNames = collectIdentifierNames(other);
2474
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
2475
+ try {
2476
+ for(var _iterator1 = names[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
2477
+ var name = _step1.value;
2478
+ if (otherNames.has(name)) {
2479
+ referenced = true;
2480
+ }
2481
+ }
2482
+ } catch (err) {
2483
+ _didIteratorError1 = true;
2484
+ _iteratorError1 = err;
2485
+ } finally{
2486
+ try {
2487
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
2488
+ _iterator1.return();
2489
+ }
2490
+ } finally{
2491
+ if (_didIteratorError1) {
2492
+ throw _iteratorError1;
2493
+ }
2494
+ }
2495
+ }
2496
+ }
2497
+ }
2498
+ } catch (err) {
2499
+ _didIteratorError = true;
2500
+ _iteratorError = err;
2501
+ } finally{
2502
+ try {
2503
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2504
+ _iterator.return();
2505
+ }
2506
+ } finally{
2507
+ if (_didIteratorError) {
2508
+ throw _iteratorError;
2509
+ }
2510
+ }
2511
+ }
2512
+ }
2513
+ return referenced;
2514
+ }
2515
+ /**
2516
+ * Collects the analyzable statements the rule may relocate to the `// COMPAT: Deprecated aliases`
2517
+ * section.
2518
+ *
2519
+ * A `@deprecated` statement is movable when it is a type-only declaration (`TSTypeAliasDeclaration`
2520
+ * or `TSInterfaceDeclaration`), which is erased at runtime and can never cause a
2521
+ * use-before-declaration error, or a runtime value alias (see {@link statementIsValueAlias}) that
2522
+ * is not referenced by any other statement in the file (see {@link isReferencedByOtherStatements}).
2523
+ *
2524
+ * Primary runtime definitions — literal-valued consts, functions, classes, enums — are never
2525
+ * movable; they stay exactly where they are so the autofix cannot reorder a value below its uses.
2526
+ *
2527
+ * @param sourceCode - The ESLint `SourceCode` instance.
2528
+ * @param body - All top-level program-body statements.
2529
+ * @param analyzable - The analyzable subset of `body` in source order.
2530
+ * @returns The movable statements in source order.
2531
+ */ function computeMovableStatements(sourceCode, body, analyzable) {
2532
+ var bindingDeprecation = buildBindingDeprecationMap(sourceCode, body);
2533
+ var movable = [];
2534
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2535
+ try {
2536
+ for(var _iterator = analyzable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2537
+ var statement = _step.value;
2538
+ if (statementIsDeprecated(sourceCode, statement)) {
2539
+ var declaration = unwrapDeclaration(statement);
2540
+ var isMovable = false;
2541
+ if (declaration.type === 'TSTypeAliasDeclaration' || declaration.type === 'TSInterfaceDeclaration') {
2542
+ isMovable = true;
2543
+ } else if (statementIsValueAlias(sourceCode, statement, bindingDeprecation)) {
2544
+ isMovable = !isReferencedByOtherStatements(getDeclaredBindingNames(statement), statement, body);
2545
+ }
2546
+ if (isMovable) {
2547
+ movable.push(statement);
2548
+ }
2549
+ }
2550
+ }
2551
+ } catch (err) {
2552
+ _didIteratorError = true;
2553
+ _iteratorError = err;
2554
+ } finally{
2555
+ try {
2556
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2557
+ _iterator.return();
2558
+ }
2559
+ } finally{
2560
+ if (_didIteratorError) {
2561
+ throw _iteratorError;
2562
+ }
2563
+ }
2564
+ }
2565
+ return movable;
2566
+ }
2567
+ /**
2568
+ * Returns true when every movable statement in `movable` appears AFTER every non-movable analyzable
2569
+ * statement in `analyzable` (i.e., the deprecated-alias section is already at the bottom of the
2570
+ * file). This is the condition under which the autofix can simply insert the marker without
2080
2571
  * reordering statements.
2081
2572
  *
2082
2573
  * @param analyzable - All analyzable top-level statements in source order.
2083
- * @param deprecated - The subset that carry `@deprecated`.
2084
- * @returns True when no non-deprecated statement appears after the first deprecated one.
2085
- */ function allDeprecatedAtBottom(analyzable, deprecated) {
2574
+ * @param movable - The movable subset (relocatable deprecated aliases).
2575
+ * @returns True when no non-movable statement appears after the first movable one.
2576
+ */ function allMovableStatementsAtBottom(analyzable, movable) {
2086
2577
  var atBottom = true;
2087
- if (deprecated.length !== 0) {
2088
- var firstDeprecatedStart = deprecated[0].range[0];
2578
+ if (movable.length !== 0) {
2579
+ var firstMovableStart = movable[0].range[0];
2089
2580
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2090
2581
  try {
2091
2582
  for(var _iterator = analyzable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2092
2583
  var stmt = _step.value;
2093
- if (stmt.range[0] > firstDeprecatedStart) {
2094
- // Statement appears after the first deprecated one. It must itself be deprecated.
2095
- var isDeprecated = deprecated.includes(stmt);
2096
- if (!isDeprecated) {
2584
+ if (stmt.range[0] > firstMovableStart) {
2585
+ // Statement appears after the first movable one. It must itself be movable.
2586
+ var isMovable = movable.includes(stmt);
2587
+ if (!isMovable) {
2097
2588
  atBottom = false;
2098
2589
  }
2099
2590
  }
@@ -2133,18 +2624,18 @@ function _unsupported_iterable_to_array$8(o, minLen) {
2133
2624
  };
2134
2625
  }
2135
2626
  /**
2136
- * Builds the fix for the interleaved case: cut every deprecated block out of the file and re-emit
2627
+ * Builds the fix for the interleaved case: cut every movable block out of the file and re-emit
2137
2628
  * them in source order at EOF, preceded by the marker.
2138
2629
  *
2139
2630
  * @param sourceCode - The ESLint `SourceCode` instance.
2140
- * @param deprecatedStatements - Deprecated statements in source order.
2141
- * @returns A fix function that removes and re-appends each deprecated block.
2142
- */ function buildInterleavedFix(sourceCode, deprecatedStatements) {
2631
+ * @param movableStatements - Movable deprecated-alias statements in source order.
2632
+ * @returns A fix function that removes and re-appends each movable block.
2633
+ */ function buildInterleavedFix(sourceCode, movableStatements) {
2143
2634
  var blockRanges = [];
2144
2635
  var blockTexts = [];
2145
2636
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2146
2637
  try {
2147
- for(var _iterator = deprecatedStatements[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2638
+ for(var _iterator = movableStatements[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2148
2639
  var stmt = _step.value;
2149
2640
  var range = getStatementBlockRange(sourceCode, stmt);
2150
2641
  blockRanges.push(range);
@@ -2187,19 +2678,19 @@ function _unsupported_iterable_to_array$8(o, minLen) {
2187
2678
  }
2188
2679
  /**
2189
2680
  * Reports the `missingCompatMarker` violation, choosing between the marker-only and interleaved
2190
- * fix strategies based on whether the deprecated tail is already at the bottom of the file.
2681
+ * fix strategies based on whether the movable tail is already at the bottom of the file.
2191
2682
  *
2192
2683
  * @param args - Inputs grouped as a single config object.
2193
2684
  * @param args.context - The ESLint rule context.
2194
2685
  * @param args.sourceCode - The ESLint `SourceCode` instance.
2195
2686
  * @param args.analyzable - All analyzable top-level statements in source order.
2196
- * @param args.deprecatedStatements - The subset that carry `@deprecated`.
2687
+ * @param args.movableStatements - The movable (relocatable deprecated-alias) subset.
2197
2688
  */ function reportMissingMarker(args) {
2198
- var context = args.context, sourceCode = args.sourceCode, analyzable = args.analyzable, deprecatedStatements = args.deprecatedStatements;
2199
- var firstDeprecated = deprecatedStatements[0];
2200
- var fixFn = allDeprecatedAtBottom(analyzable, deprecatedStatements) ? buildMarkerOnlyFix(sourceCode, firstDeprecated) : buildInterleavedFix(sourceCode, deprecatedStatements);
2689
+ var context = args.context, sourceCode = args.sourceCode, analyzable = args.analyzable, movableStatements = args.movableStatements;
2690
+ var firstMovable = movableStatements[0];
2691
+ var fixFn = allMovableStatementsAtBottom(analyzable, movableStatements) ? buildMarkerOnlyFix(sourceCode, firstMovable) : buildInterleavedFix(sourceCode, movableStatements);
2201
2692
  context.report({
2202
- node: firstDeprecated,
2693
+ node: firstMovable,
2203
2694
  messageId: 'missingCompatMarker',
2204
2695
  fix: fixFn
2205
2696
  });
@@ -2253,17 +2744,23 @@ function _unsupported_iterable_to_array$8(o, minLen) {
2253
2744
  };
2254
2745
  }
2255
2746
  /**
2256
- * Reports the first misplaced deprecated block (above the marker) and the first misplaced
2747
+ * Reports the first misplaced movable alias (above the marker) and the first misplaced
2257
2748
  * non-deprecated block (below the marker). At most one of each is reported per pass; ESLint's
2258
2749
  * autofix loop converges across multiple violations.
2259
2750
  *
2751
+ * Only movable statements are pulled down below the marker; only statements that are not
2752
+ * `@deprecated` at all are pushed up above it. A deprecated-but-not-movable statement (a primary
2753
+ * definition such as a literal-valued const) sitting below an existing marker is left in place, so
2754
+ * files that already carry a marker are not re-churned.
2755
+ *
2260
2756
  * @param args - Inputs grouped as a single config object.
2261
2757
  * @param args.context - The ESLint rule context.
2262
2758
  * @param args.sourceCode - The ESLint `SourceCode` instance.
2263
2759
  * @param args.analyzable - All analyzable top-level statements in source order.
2264
2760
  * @param args.markerOffset - The marker comment's start offset.
2761
+ * @param args.movableSet - The set of movable (relocatable deprecated-alias) statements.
2265
2762
  */ function reportMisplacedStatements(args) {
2266
- var context = args.context, sourceCode = args.sourceCode, analyzable = args.analyzable, markerOffset = args.markerOffset;
2763
+ var context = args.context, sourceCode = args.sourceCode, analyzable = args.analyzable, markerOffset = args.markerOffset, movableSet = args.movableSet;
2267
2764
  var marker = {
2268
2765
  comment: findCompatMarkerComment(sourceCode),
2269
2766
  offset: markerOffset
@@ -2275,8 +2772,9 @@ function _unsupported_iterable_to_array$8(o, minLen) {
2275
2772
  for(var _iterator = analyzable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2276
2773
  var stmt = _step.value;
2277
2774
  var isAfterMarker = stmt.range[0] > markerOffset;
2775
+ var isMovable = movableSet.has(stmt);
2278
2776
  var isDeprecated = statementIsDeprecated(sourceCode, stmt);
2279
- if (isDeprecated && !isAfterMarker && !reportedAliasAboveMarker) {
2777
+ if (isMovable && !isAfterMarker && !reportedAliasAboveMarker) {
2280
2778
  context.report({
2281
2779
  node: stmt,
2282
2780
  messageId: 'deprecatedAliasNotAtBottom',
@@ -2308,56 +2806,29 @@ function _unsupported_iterable_to_array$8(o, minLen) {
2308
2806
  }
2309
2807
  }
2310
2808
  /**
2311
- * Collects all analyzable top-level statements that carry an `@deprecated` JSDoc tag, preserving
2312
- * source order.
2809
+ * ESLint rule requiring that `@deprecated` *aliases* live at the bottom of the file under a
2810
+ * `// COMPAT: Deprecated aliases` line comment, and that no non-deprecated exports follow the
2811
+ * marker. The rule mirrors the workspace's "Deprecated Alias Placement" convention so that
2812
+ * deprecated aliases stay segregated from current code and are easy to spot for removal.
2313
2813
  *
2314
- * @param sourceCode - The ESLint `SourceCode` instance.
2315
- * @param analyzable - All analyzable top-level statements in source order.
2316
- * @returns The deprecated subset of `analyzable`.
2317
- */ function collectDeprecatedStatements(sourceCode, analyzable) {
2318
- var deprecatedStatements = [];
2319
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2320
- try {
2321
- for(var _iterator = analyzable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2322
- var stmt = _step.value;
2323
- if (statementIsDeprecated(sourceCode, stmt)) {
2324
- deprecatedStatements.push(stmt);
2325
- }
2326
- }
2327
- } catch (err) {
2328
- _didIteratorError = true;
2329
- _iteratorError = err;
2330
- } finally{
2331
- try {
2332
- if (!_iteratorNormalCompletion && _iterator.return != null) {
2333
- _iterator.return();
2334
- }
2335
- } finally{
2336
- if (_didIteratorError) {
2337
- throw _iteratorError;
2338
- }
2339
- }
2340
- }
2341
- return deprecatedStatements;
2342
- }
2343
- /**
2344
- * ESLint rule requiring that exports carrying a `@deprecated` JSDoc tag live at the bottom of the
2345
- * file under a `// COMPAT: Deprecated aliases` line comment, and that no non-deprecated exports
2346
- * follow the marker. The rule mirrors the workspace's "Deprecated Alias Placement" convention so
2347
- * that deprecated aliases stay segregated from current code and are easy to spot for removal.
2814
+ * Only *relocatable* deprecated statements participate (see {@link computeMovableStatements}):
2815
+ * type-only declarations (always runtime-safe to move) and runtime value aliases — a
2816
+ * `VariableDeclaration` whose initializer references a non-deprecated binding that are not
2817
+ * referenced elsewhere in the file. Primary runtime definitions (literal-valued consts, functions,
2818
+ * classes, enums) and any value still referenced by other code are left exactly where they are, so
2819
+ * the autofix can never reorder a value below its uses (a use-before-declaration error).
2348
2820
  *
2349
2821
  * The rule reports at most one violation per concern (missing marker, alias above marker,
2350
2822
  * non-deprecated below marker) to keep editor noise manageable; once the first violation in a
2351
2823
  * category is fixed, re-linting will surface the next one.
2352
2824
  *
2353
2825
  * Autofix coverage:
2354
- * - `missingCompatMarker` — inserts `// COMPAT: Deprecated aliases` and consolidates all
2355
- * deprecated blocks at the bottom of the file. When the deprecated tail is already at the
2356
- * bottom of the file, only the marker line is inserted (no statements are moved). When
2357
- * deprecated exports are interleaved with non-deprecated ones, the autofix removes each
2358
- * deprecated block from its current location and re-emits them in source order at the bottom
2359
- * of the file under the marker.
2360
- * - `deprecatedAliasNotAtBottom` — moves the misplaced deprecated block from above the marker to
2826
+ * - `missingCompatMarker` — inserts `// COMPAT: Deprecated aliases` and consolidates all movable
2827
+ * blocks at the bottom of the file. When the movable tail is already at the bottom of the file,
2828
+ * only the marker line is inserted (no statements are moved). When movable aliases are
2829
+ * interleaved with other statements, the autofix removes each movable block from its current
2830
+ * location and re-emits them in source order at the bottom of the file under the marker.
2831
+ * - `deprecatedAliasNotAtBottom` — moves the misplaced movable block from above the marker to
2361
2832
  * just after the marker. One block per pass; ESLint's autofix loop converges across multiple
2362
2833
  * violations.
2363
2834
  * - `nonDeprecatedAfterMarker` — moves the misplaced non-deprecated block from below the marker
@@ -2369,12 +2840,12 @@ function _unsupported_iterable_to_array$8(o, minLen) {
2369
2840
  type: 'suggestion',
2370
2841
  fixable: 'code',
2371
2842
  docs: {
2372
- description: 'Require @deprecated exports to live at the bottom of the file under a // COMPAT: Deprecated aliases marker.',
2843
+ description: 'Require @deprecated aliases to live at the bottom of the file under a // COMPAT: Deprecated aliases marker.',
2373
2844
  recommended: true
2374
2845
  },
2375
2846
  messages: {
2376
- missingCompatMarker: "File contains @deprecated exports but is missing the '// COMPAT: Deprecated aliases' marker line comment. Add the marker and move all @deprecated exports below it.",
2377
- deprecatedAliasNotAtBottom: "This @deprecated export should live below the '// COMPAT: Deprecated aliases' marker at the bottom of the file.",
2847
+ missingCompatMarker: "File contains @deprecated aliases but is missing the '// COMPAT: Deprecated aliases' marker line comment. Add the marker and move the @deprecated aliases below it.",
2848
+ deprecatedAliasNotAtBottom: "This @deprecated alias should live below the '// COMPAT: Deprecated aliases' marker at the bottom of the file.",
2378
2849
  nonDeprecatedAfterMarker: "This export is not @deprecated but appears after the '// COMPAT: Deprecated aliases' marker. Move it above the marker."
2379
2850
  },
2380
2851
  schema: []
@@ -2385,8 +2856,8 @@ function _unsupported_iterable_to_array$8(o, minLen) {
2385
2856
  var _programNode_body;
2386
2857
  var body = (_programNode_body = programNode.body) !== null && _programNode_body !== void 0 ? _programNode_body : [];
2387
2858
  var analyzable = body.filter(isAnalyzableExportLike);
2388
- var deprecatedStatements = collectDeprecatedStatements(sourceCode, analyzable);
2389
- if (deprecatedStatements.length === 0) {
2859
+ var movableStatements = computeMovableStatements(sourceCode, body, analyzable);
2860
+ if (movableStatements.length === 0) {
2390
2861
  return;
2391
2862
  }
2392
2863
  var markerOffset = findCompatMarkerOffset(sourceCode);
@@ -2395,7 +2866,7 @@ function _unsupported_iterable_to_array$8(o, minLen) {
2395
2866
  context: context,
2396
2867
  sourceCode: sourceCode,
2397
2868
  analyzable: analyzable,
2398
- deprecatedStatements: deprecatedStatements
2869
+ movableStatements: movableStatements
2399
2870
  });
2400
2871
  return;
2401
2872
  }
@@ -2403,7 +2874,8 @@ function _unsupported_iterable_to_array$8(o, minLen) {
2403
2874
  context: context,
2404
2875
  sourceCode: sourceCode,
2405
2876
  analyzable: analyzable,
2406
- markerOffset: markerOffset
2877
+ markerOffset: markerOffset,
2878
+ movableSet: new Set(movableStatements)
2407
2879
  });
2408
2880
  }
2409
2881
  return {