@dereekb/util 13.12.0 → 13.12.2
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/eslint/index.cjs.js +605 -94
- package/eslint/index.esm.js +605 -94
- package/eslint/package.json +1 -1
- package/eslint/src/lib/require-deprecated-alias-placement.rule.d.ts +17 -11
- package/fetch/package.json +2 -2
- package/package.json +1 -1
- package/src/lib/string/mimetype.d.ts +21 -21
- package/test/package.json +2 -2
package/eslint/index.cjs.js
CHANGED
|
@@ -909,7 +909,7 @@ function _non_iterable_rest$8() {
|
|
|
909
909
|
function _sliced_to_array$8(arr, i) {
|
|
910
910
|
return _array_with_holes$8(arr) || _iterable_to_array_limit$8(arr, i) || _unsupported_iterable_to_array$a(arr, i) || _non_iterable_rest$8();
|
|
911
911
|
}
|
|
912
|
-
function _type_of(obj) {
|
|
912
|
+
function _type_of$1(obj) {
|
|
913
913
|
"@swc/helpers - typeof";
|
|
914
914
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
915
915
|
}
|
|
@@ -1026,7 +1026,7 @@ function walkChildren(node, out) {
|
|
|
1026
1026
|
* @param node - The AST node to traverse.
|
|
1027
1027
|
* @param out - The accumulator array that receives counted `ReturnStatement` nodes.
|
|
1028
1028
|
*/ function collectCountedReturns(node, out) {
|
|
1029
|
-
if (node === null || (typeof node === "undefined" ? "undefined" : _type_of(node)) !== 'object') return;
|
|
1029
|
+
if (node === null || (typeof node === "undefined" ? "undefined" : _type_of$1(node)) !== 'object') return;
|
|
1030
1030
|
if (Array.isArray(node)) {
|
|
1031
1031
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1032
1032
|
try {
|
|
@@ -1877,6 +1877,10 @@ function _non_iterable_spread$2() {
|
|
|
1877
1877
|
function _to_consumable_array$2(arr) {
|
|
1878
1878
|
return _array_without_holes$2(arr) || _iterable_to_array$2(arr) || _unsupported_iterable_to_array$8(arr) || _non_iterable_spread$2();
|
|
1879
1879
|
}
|
|
1880
|
+
function _type_of(obj) {
|
|
1881
|
+
"@swc/helpers - typeof";
|
|
1882
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1883
|
+
}
|
|
1880
1884
|
function _unsupported_iterable_to_array$8(o, minLen) {
|
|
1881
1885
|
if (!o) return;
|
|
1882
1886
|
if (typeof o === "string") return _array_like_to_array$8(o, minLen);
|
|
@@ -2076,26 +2080,513 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
2076
2080
|
return sourceCode.text.slice(range[0], range[1]);
|
|
2077
2081
|
}
|
|
2078
2082
|
/**
|
|
2079
|
-
*
|
|
2080
|
-
*
|
|
2081
|
-
*
|
|
2083
|
+
* Unwraps an `export` statement to the underlying declaration. Returns the node itself when it is
|
|
2084
|
+
* not an export wrapper.
|
|
2085
|
+
*
|
|
2086
|
+
* @param statement - The top-level statement node.
|
|
2087
|
+
* @returns The inner declaration for export wrappers, otherwise the statement itself.
|
|
2088
|
+
*/ function unwrapDeclaration(statement) {
|
|
2089
|
+
var declaration = statement;
|
|
2090
|
+
if ((statement.type === 'ExportNamedDeclaration' || statement.type === 'ExportDefaultDeclaration') && statement.declaration != null) {
|
|
2091
|
+
declaration = statement.declaration;
|
|
2092
|
+
}
|
|
2093
|
+
return declaration;
|
|
2094
|
+
}
|
|
2095
|
+
/**
|
|
2096
|
+
* Recursively collects the binding names introduced by a binding pattern (`Identifier`,
|
|
2097
|
+
* `ObjectPattern`, `ArrayPattern`, including defaults and rest elements).
|
|
2098
|
+
*
|
|
2099
|
+
* @param node - A binding pattern to walk; missing array-pattern holes contribute no names.
|
|
2100
|
+
* @returns The flat list of bound identifier names.
|
|
2101
|
+
*/ function collectPatternNames(node) {
|
|
2102
|
+
var names = [];
|
|
2103
|
+
if (node != null) {
|
|
2104
|
+
if (node.type === 'Identifier') {
|
|
2105
|
+
names.push(node.name);
|
|
2106
|
+
} else if (node.type === 'ObjectPattern') {
|
|
2107
|
+
var _node_properties;
|
|
2108
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2109
|
+
try {
|
|
2110
|
+
for(var _iterator = ((_node_properties = node.properties) !== null && _node_properties !== void 0 ? _node_properties : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2111
|
+
var property = _step.value;
|
|
2112
|
+
var _names;
|
|
2113
|
+
(_names = names).push.apply(_names, _to_consumable_array$2(collectPatternNames(property.type === 'RestElement' ? property.argument : property.value)));
|
|
2114
|
+
}
|
|
2115
|
+
} catch (err) {
|
|
2116
|
+
_didIteratorError = true;
|
|
2117
|
+
_iteratorError = err;
|
|
2118
|
+
} finally{
|
|
2119
|
+
try {
|
|
2120
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2121
|
+
_iterator.return();
|
|
2122
|
+
}
|
|
2123
|
+
} finally{
|
|
2124
|
+
if (_didIteratorError) {
|
|
2125
|
+
throw _iteratorError;
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
} else if (node.type === 'ArrayPattern') {
|
|
2130
|
+
var _node_elements;
|
|
2131
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
2132
|
+
try {
|
|
2133
|
+
for(var _iterator1 = ((_node_elements = node.elements) !== null && _node_elements !== void 0 ? _node_elements : [])[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
2134
|
+
var element = _step1.value;
|
|
2135
|
+
var _names1;
|
|
2136
|
+
(_names1 = names).push.apply(_names1, _to_consumable_array$2(collectPatternNames((element === null || element === void 0 ? void 0 : element.type) === 'RestElement' ? element.argument : element)));
|
|
2137
|
+
}
|
|
2138
|
+
} catch (err) {
|
|
2139
|
+
_didIteratorError1 = true;
|
|
2140
|
+
_iteratorError1 = err;
|
|
2141
|
+
} finally{
|
|
2142
|
+
try {
|
|
2143
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
2144
|
+
_iterator1.return();
|
|
2145
|
+
}
|
|
2146
|
+
} finally{
|
|
2147
|
+
if (_didIteratorError1) {
|
|
2148
|
+
throw _iteratorError1;
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
} else if (node.type === 'AssignmentPattern') {
|
|
2153
|
+
var _names2;
|
|
2154
|
+
(_names2 = names).push.apply(_names2, _to_consumable_array$2(collectPatternNames(node.left)));
|
|
2155
|
+
} else if (node.type === 'RestElement') {
|
|
2156
|
+
var _names3;
|
|
2157
|
+
(_names3 = names).push.apply(_names3, _to_consumable_array$2(collectPatternNames(node.argument)));
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
return names;
|
|
2161
|
+
}
|
|
2162
|
+
/**
|
|
2163
|
+
* Returns the binding names a top-level statement introduces: variable declarator ids, an
|
|
2164
|
+
* import's local specifier names, or a function/class/interface/type/enum declaration id.
|
|
2165
|
+
*
|
|
2166
|
+
* @param statement - The top-level statement node.
|
|
2167
|
+
* @returns The names bound by the statement.
|
|
2168
|
+
*/ function getDeclaredBindingNames(statement) {
|
|
2169
|
+
var _declaration_id;
|
|
2170
|
+
var names = [];
|
|
2171
|
+
var declaration = unwrapDeclaration(statement);
|
|
2172
|
+
if (declaration.type === 'VariableDeclaration') {
|
|
2173
|
+
var _declaration_declarations;
|
|
2174
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2175
|
+
try {
|
|
2176
|
+
for(var _iterator = ((_declaration_declarations = declaration.declarations) !== null && _declaration_declarations !== void 0 ? _declaration_declarations : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2177
|
+
var declarator = _step.value;
|
|
2178
|
+
var _names;
|
|
2179
|
+
(_names = names).push.apply(_names, _to_consumable_array$2(collectPatternNames(declarator.id)));
|
|
2180
|
+
}
|
|
2181
|
+
} catch (err) {
|
|
2182
|
+
_didIteratorError = true;
|
|
2183
|
+
_iteratorError = err;
|
|
2184
|
+
} finally{
|
|
2185
|
+
try {
|
|
2186
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2187
|
+
_iterator.return();
|
|
2188
|
+
}
|
|
2189
|
+
} finally{
|
|
2190
|
+
if (_didIteratorError) {
|
|
2191
|
+
throw _iteratorError;
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
} else if (declaration.type === 'ImportDeclaration') {
|
|
2196
|
+
var _declaration_specifiers;
|
|
2197
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
2198
|
+
try {
|
|
2199
|
+
for(var _iterator1 = ((_declaration_specifiers = declaration.specifiers) !== null && _declaration_specifiers !== void 0 ? _declaration_specifiers : [])[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
2200
|
+
var specifier = _step1.value;
|
|
2201
|
+
var _specifier_local;
|
|
2202
|
+
if (typeof ((_specifier_local = specifier.local) === null || _specifier_local === void 0 ? void 0 : _specifier_local.name) === 'string') {
|
|
2203
|
+
names.push(specifier.local.name);
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
} catch (err) {
|
|
2207
|
+
_didIteratorError1 = true;
|
|
2208
|
+
_iteratorError1 = err;
|
|
2209
|
+
} finally{
|
|
2210
|
+
try {
|
|
2211
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
2212
|
+
_iterator1.return();
|
|
2213
|
+
}
|
|
2214
|
+
} finally{
|
|
2215
|
+
if (_didIteratorError1) {
|
|
2216
|
+
throw _iteratorError1;
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
} else if (((_declaration_id = declaration.id) === null || _declaration_id === void 0 ? void 0 : _declaration_id.type) === 'Identifier') {
|
|
2221
|
+
names.push(declaration.id.name);
|
|
2222
|
+
}
|
|
2223
|
+
return names;
|
|
2224
|
+
}
|
|
2225
|
+
/**
|
|
2226
|
+
* Returns true for AST-walk keys that must not be descended into: the `parent` back-reference
|
|
2227
|
+
* (which would escape the subtree) and the `loc`/`range` position metadata.
|
|
2228
|
+
*
|
|
2229
|
+
* @param key - The property key being considered for traversal.
|
|
2230
|
+
* @returns True when the key should be skipped.
|
|
2231
|
+
*/ function isIdentifierWalkSkipKey(key) {
|
|
2232
|
+
return key === 'parent' || key === 'loc' || key === 'range';
|
|
2233
|
+
}
|
|
2234
|
+
/**
|
|
2235
|
+
* Collects every `Identifier` name reachable from an AST record (a node with a string `type`),
|
|
2236
|
+
* recursing into its child nodes while skipping the keys flagged by {@link isIdentifierWalkSkipKey}.
|
|
2237
|
+
*
|
|
2238
|
+
* @param record - An AST node, keyed by its properties.
|
|
2239
|
+
* @returns The set of identifier names found within the node.
|
|
2240
|
+
*/ function collectIdentifierNamesFromRecord(record) {
|
|
2241
|
+
var names = new Set();
|
|
2242
|
+
if (record.type === 'Identifier' && typeof record.name === 'string') {
|
|
2243
|
+
names.add(record.name);
|
|
2244
|
+
}
|
|
2245
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2246
|
+
try {
|
|
2247
|
+
for(var _iterator = Object.keys(record)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2248
|
+
var key = _step.value;
|
|
2249
|
+
if (!isIdentifierWalkSkipKey(key)) {
|
|
2250
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
2251
|
+
try {
|
|
2252
|
+
for(var _iterator1 = collectIdentifierNames(record[key])[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
2253
|
+
var name = _step1.value;
|
|
2254
|
+
names.add(name);
|
|
2255
|
+
}
|
|
2256
|
+
} catch (err) {
|
|
2257
|
+
_didIteratorError1 = true;
|
|
2258
|
+
_iteratorError1 = err;
|
|
2259
|
+
} finally{
|
|
2260
|
+
try {
|
|
2261
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
2262
|
+
_iterator1.return();
|
|
2263
|
+
}
|
|
2264
|
+
} finally{
|
|
2265
|
+
if (_didIteratorError1) {
|
|
2266
|
+
throw _iteratorError1;
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
} catch (err) {
|
|
2273
|
+
_didIteratorError = true;
|
|
2274
|
+
_iteratorError = err;
|
|
2275
|
+
} finally{
|
|
2276
|
+
try {
|
|
2277
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2278
|
+
_iterator.return();
|
|
2279
|
+
}
|
|
2280
|
+
} finally{
|
|
2281
|
+
if (_didIteratorError) {
|
|
2282
|
+
throw _iteratorError;
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
return names;
|
|
2287
|
+
}
|
|
2288
|
+
/**
|
|
2289
|
+
* Recursively collects every `Identifier` name reachable from a value, staying within the subtree.
|
|
2290
|
+
*
|
|
2291
|
+
* Used both for the value-alias check (over a declarator `init`) and the reverse-reference safety
|
|
2292
|
+
* net (over a whole statement). Over-collection is acceptable for both callers: it only makes the
|
|
2293
|
+
* safety net more conservative and the alias check more permissive toward genuine aliases.
|
|
2294
|
+
*
|
|
2295
|
+
* @param node - The subtree root to scan (an AST node, an array of nodes, or a leaf value).
|
|
2296
|
+
* @returns The set of identifier names found in the subtree.
|
|
2297
|
+
*/ function collectIdentifierNames(node) {
|
|
2298
|
+
var names = new Set();
|
|
2299
|
+
if (Array.isArray(node)) {
|
|
2300
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2301
|
+
try {
|
|
2302
|
+
for(var _iterator = node[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2303
|
+
var item = _step.value;
|
|
2304
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
2305
|
+
try {
|
|
2306
|
+
for(var _iterator1 = collectIdentifierNames(item)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
2307
|
+
var name = _step1.value;
|
|
2308
|
+
names.add(name);
|
|
2309
|
+
}
|
|
2310
|
+
} catch (err) {
|
|
2311
|
+
_didIteratorError1 = true;
|
|
2312
|
+
_iteratorError1 = err;
|
|
2313
|
+
} finally{
|
|
2314
|
+
try {
|
|
2315
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
2316
|
+
_iterator1.return();
|
|
2317
|
+
}
|
|
2318
|
+
} finally{
|
|
2319
|
+
if (_didIteratorError1) {
|
|
2320
|
+
throw _iteratorError1;
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2325
|
+
} catch (err) {
|
|
2326
|
+
_didIteratorError = true;
|
|
2327
|
+
_iteratorError = err;
|
|
2328
|
+
} finally{
|
|
2329
|
+
try {
|
|
2330
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2331
|
+
_iterator.return();
|
|
2332
|
+
}
|
|
2333
|
+
} finally{
|
|
2334
|
+
if (_didIteratorError) {
|
|
2335
|
+
throw _iteratorError;
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
} else if (node != null && (typeof node === "undefined" ? "undefined" : _type_of(node)) === 'object' && typeof node.type === 'string') {
|
|
2340
|
+
names = collectIdentifierNamesFromRecord(node);
|
|
2341
|
+
}
|
|
2342
|
+
return names;
|
|
2343
|
+
}
|
|
2344
|
+
/**
|
|
2345
|
+
* Builds a map of every top-level binding name in the file to whether its declaration carries an
|
|
2346
|
+
* `@deprecated` tag. A name declared more than once is considered non-deprecated when any of its
|
|
2347
|
+
* declarations is non-deprecated.
|
|
2348
|
+
*
|
|
2349
|
+
* @param sourceCode - The ESLint `SourceCode` instance.
|
|
2350
|
+
* @param body - All top-level program-body statements.
|
|
2351
|
+
* @returns Whether each top-level binding name is declared as `@deprecated`, keyed by that name.
|
|
2352
|
+
*/ function buildBindingDeprecationMap(sourceCode, body) {
|
|
2353
|
+
var bindingDeprecation = new Map();
|
|
2354
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2355
|
+
try {
|
|
2356
|
+
for(var _iterator = body[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2357
|
+
var statement = _step.value;
|
|
2358
|
+
var deprecated = statementIsDeprecated(sourceCode, statement);
|
|
2359
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
2360
|
+
try {
|
|
2361
|
+
for(var _iterator1 = getDeclaredBindingNames(statement)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
2362
|
+
var name = _step1.value;
|
|
2363
|
+
var existing = bindingDeprecation.get(name);
|
|
2364
|
+
bindingDeprecation.set(name, existing === undefined ? deprecated : existing && deprecated);
|
|
2365
|
+
}
|
|
2366
|
+
} catch (err) {
|
|
2367
|
+
_didIteratorError1 = true;
|
|
2368
|
+
_iteratorError1 = err;
|
|
2369
|
+
} finally{
|
|
2370
|
+
try {
|
|
2371
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
2372
|
+
_iterator1.return();
|
|
2373
|
+
}
|
|
2374
|
+
} finally{
|
|
2375
|
+
if (_didIteratorError1) {
|
|
2376
|
+
throw _iteratorError1;
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2381
|
+
} catch (err) {
|
|
2382
|
+
_didIteratorError = true;
|
|
2383
|
+
_iteratorError = err;
|
|
2384
|
+
} finally{
|
|
2385
|
+
try {
|
|
2386
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2387
|
+
_iterator.return();
|
|
2388
|
+
}
|
|
2389
|
+
} finally{
|
|
2390
|
+
if (_didIteratorError) {
|
|
2391
|
+
throw _iteratorError;
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
return bindingDeprecation;
|
|
2396
|
+
}
|
|
2397
|
+
/**
|
|
2398
|
+
* Returns true when a `@deprecated` statement is a runtime *value alias* — a `VariableDeclaration`
|
|
2399
|
+
* whose initializer references a non-deprecated binding declared elsewhere in the file (or an
|
|
2400
|
+
* imported name). Literal-only initializers (`= 'SPED'`, `= 5`, object/array literals with no
|
|
2401
|
+
* variable references) are primary definitions, not aliases, and return false.
|
|
2402
|
+
*
|
|
2403
|
+
* @param sourceCode - The ESLint `SourceCode` instance.
|
|
2404
|
+
* @param statement - The top-level statement node.
|
|
2405
|
+
* @param bindingDeprecation - Map of top-level binding name to deprecation flag.
|
|
2406
|
+
* @returns True when the statement is a deprecated value alias.
|
|
2407
|
+
*/ function statementIsValueAlias(sourceCode, statement, bindingDeprecation) {
|
|
2408
|
+
var isAlias = false;
|
|
2409
|
+
var declaration = unwrapDeclaration(statement);
|
|
2410
|
+
if (statementIsDeprecated(sourceCode, statement) && declaration.type === 'VariableDeclaration') {
|
|
2411
|
+
var _declaration_declarations;
|
|
2412
|
+
var ownNames = new Set(getDeclaredBindingNames(statement));
|
|
2413
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2414
|
+
try {
|
|
2415
|
+
for(var _iterator = ((_declaration_declarations = declaration.declarations) !== null && _declaration_declarations !== void 0 ? _declaration_declarations : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2416
|
+
var declarator = _step.value;
|
|
2417
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
2418
|
+
try {
|
|
2419
|
+
for(var _iterator1 = collectIdentifierNames(declarator.init)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
2420
|
+
var name = _step1.value;
|
|
2421
|
+
if (!ownNames.has(name) && bindingDeprecation.get(name) === false) {
|
|
2422
|
+
isAlias = true;
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
} catch (err) {
|
|
2426
|
+
_didIteratorError1 = true;
|
|
2427
|
+
_iteratorError1 = err;
|
|
2428
|
+
} finally{
|
|
2429
|
+
try {
|
|
2430
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
2431
|
+
_iterator1.return();
|
|
2432
|
+
}
|
|
2433
|
+
} finally{
|
|
2434
|
+
if (_didIteratorError1) {
|
|
2435
|
+
throw _iteratorError1;
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
} catch (err) {
|
|
2441
|
+
_didIteratorError = true;
|
|
2442
|
+
_iteratorError = err;
|
|
2443
|
+
} finally{
|
|
2444
|
+
try {
|
|
2445
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2446
|
+
_iterator.return();
|
|
2447
|
+
}
|
|
2448
|
+
} finally{
|
|
2449
|
+
if (_didIteratorError) {
|
|
2450
|
+
throw _iteratorError;
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
return isAlias;
|
|
2456
|
+
}
|
|
2457
|
+
/**
|
|
2458
|
+
* Safety net for runtime value aliases: returns true when any name bound by `statement` is
|
|
2459
|
+
* referenced by some *other* top-level statement in the file. Relocating such a value below those
|
|
2460
|
+
* references would introduce a use-before-declaration / temporal-dead-zone error, so a referenced
|
|
2461
|
+
* alias must stay in place.
|
|
2462
|
+
*
|
|
2463
|
+
* @param names - The names bound by the candidate statement.
|
|
2464
|
+
* @param statement - The candidate statement (excluded from the scan).
|
|
2465
|
+
* @param body - All top-level program-body statements.
|
|
2466
|
+
* @returns True when another statement references one of `names`.
|
|
2467
|
+
*/ function isReferencedByOtherStatements(names, statement, body) {
|
|
2468
|
+
var referenced = false;
|
|
2469
|
+
if (names.length !== 0) {
|
|
2470
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2471
|
+
try {
|
|
2472
|
+
for(var _iterator = body[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2473
|
+
var other = _step.value;
|
|
2474
|
+
if (other !== statement) {
|
|
2475
|
+
var otherNames = collectIdentifierNames(other);
|
|
2476
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
2477
|
+
try {
|
|
2478
|
+
for(var _iterator1 = names[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
2479
|
+
var name = _step1.value;
|
|
2480
|
+
if (otherNames.has(name)) {
|
|
2481
|
+
referenced = true;
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
} catch (err) {
|
|
2485
|
+
_didIteratorError1 = true;
|
|
2486
|
+
_iteratorError1 = err;
|
|
2487
|
+
} finally{
|
|
2488
|
+
try {
|
|
2489
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
2490
|
+
_iterator1.return();
|
|
2491
|
+
}
|
|
2492
|
+
} finally{
|
|
2493
|
+
if (_didIteratorError1) {
|
|
2494
|
+
throw _iteratorError1;
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
} catch (err) {
|
|
2501
|
+
_didIteratorError = true;
|
|
2502
|
+
_iteratorError = err;
|
|
2503
|
+
} finally{
|
|
2504
|
+
try {
|
|
2505
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2506
|
+
_iterator.return();
|
|
2507
|
+
}
|
|
2508
|
+
} finally{
|
|
2509
|
+
if (_didIteratorError) {
|
|
2510
|
+
throw _iteratorError;
|
|
2511
|
+
}
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
return referenced;
|
|
2516
|
+
}
|
|
2517
|
+
/**
|
|
2518
|
+
* Collects the analyzable statements the rule may relocate to the `// COMPAT: Deprecated aliases`
|
|
2519
|
+
* section.
|
|
2520
|
+
*
|
|
2521
|
+
* A `@deprecated` statement is movable when it is a type-only declaration (`TSTypeAliasDeclaration`
|
|
2522
|
+
* or `TSInterfaceDeclaration`), which is erased at runtime and can never cause a
|
|
2523
|
+
* use-before-declaration error, or a runtime value alias (see {@link statementIsValueAlias}) that
|
|
2524
|
+
* is not referenced by any other statement in the file (see {@link isReferencedByOtherStatements}).
|
|
2525
|
+
*
|
|
2526
|
+
* Primary runtime definitions — literal-valued consts, functions, classes, enums — are never
|
|
2527
|
+
* movable; they stay exactly where they are so the autofix cannot reorder a value below its uses.
|
|
2528
|
+
*
|
|
2529
|
+
* @param sourceCode - The ESLint `SourceCode` instance.
|
|
2530
|
+
* @param body - All top-level program-body statements.
|
|
2531
|
+
* @param analyzable - The analyzable subset of `body` in source order.
|
|
2532
|
+
* @returns The movable statements in source order.
|
|
2533
|
+
*/ function computeMovableStatements(sourceCode, body, analyzable) {
|
|
2534
|
+
var bindingDeprecation = buildBindingDeprecationMap(sourceCode, body);
|
|
2535
|
+
var movable = [];
|
|
2536
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2537
|
+
try {
|
|
2538
|
+
for(var _iterator = analyzable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2539
|
+
var statement = _step.value;
|
|
2540
|
+
if (statementIsDeprecated(sourceCode, statement)) {
|
|
2541
|
+
var declaration = unwrapDeclaration(statement);
|
|
2542
|
+
var isMovable = false;
|
|
2543
|
+
if (declaration.type === 'TSTypeAliasDeclaration' || declaration.type === 'TSInterfaceDeclaration') {
|
|
2544
|
+
isMovable = true;
|
|
2545
|
+
} else if (statementIsValueAlias(sourceCode, statement, bindingDeprecation)) {
|
|
2546
|
+
isMovable = !isReferencedByOtherStatements(getDeclaredBindingNames(statement), statement, body);
|
|
2547
|
+
}
|
|
2548
|
+
if (isMovable) {
|
|
2549
|
+
movable.push(statement);
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
} catch (err) {
|
|
2554
|
+
_didIteratorError = true;
|
|
2555
|
+
_iteratorError = err;
|
|
2556
|
+
} finally{
|
|
2557
|
+
try {
|
|
2558
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2559
|
+
_iterator.return();
|
|
2560
|
+
}
|
|
2561
|
+
} finally{
|
|
2562
|
+
if (_didIteratorError) {
|
|
2563
|
+
throw _iteratorError;
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
return movable;
|
|
2568
|
+
}
|
|
2569
|
+
/**
|
|
2570
|
+
* Returns true when every movable statement in `movable` appears AFTER every non-movable analyzable
|
|
2571
|
+
* statement in `analyzable` (i.e., the deprecated-alias section is already at the bottom of the
|
|
2572
|
+
* file). This is the condition under which the autofix can simply insert the marker without
|
|
2082
2573
|
* reordering statements.
|
|
2083
2574
|
*
|
|
2084
2575
|
* @param analyzable - All analyzable top-level statements in source order.
|
|
2085
|
-
* @param
|
|
2086
|
-
* @returns True when no non-
|
|
2087
|
-
*/ function
|
|
2576
|
+
* @param movable - The movable subset (relocatable deprecated aliases).
|
|
2577
|
+
* @returns True when no non-movable statement appears after the first movable one.
|
|
2578
|
+
*/ function allMovableStatementsAtBottom(analyzable, movable) {
|
|
2088
2579
|
var atBottom = true;
|
|
2089
|
-
if (
|
|
2090
|
-
var
|
|
2580
|
+
if (movable.length !== 0) {
|
|
2581
|
+
var firstMovableStart = movable[0].range[0];
|
|
2091
2582
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2092
2583
|
try {
|
|
2093
2584
|
for(var _iterator = analyzable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2094
2585
|
var stmt = _step.value;
|
|
2095
|
-
if (stmt.range[0] >
|
|
2096
|
-
// Statement appears after the first
|
|
2097
|
-
var
|
|
2098
|
-
if (!
|
|
2586
|
+
if (stmt.range[0] > firstMovableStart) {
|
|
2587
|
+
// Statement appears after the first movable one. It must itself be movable.
|
|
2588
|
+
var isMovable = movable.includes(stmt);
|
|
2589
|
+
if (!isMovable) {
|
|
2099
2590
|
atBottom = false;
|
|
2100
2591
|
}
|
|
2101
2592
|
}
|
|
@@ -2135,18 +2626,18 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
2135
2626
|
};
|
|
2136
2627
|
}
|
|
2137
2628
|
/**
|
|
2138
|
-
* Builds the fix for the interleaved case: cut every
|
|
2629
|
+
* Builds the fix for the interleaved case: cut every movable block out of the file and re-emit
|
|
2139
2630
|
* them in source order at EOF, preceded by the marker.
|
|
2140
2631
|
*
|
|
2141
2632
|
* @param sourceCode - The ESLint `SourceCode` instance.
|
|
2142
|
-
* @param
|
|
2143
|
-
* @returns A fix function that removes and re-appends each
|
|
2144
|
-
*/ function buildInterleavedFix(sourceCode,
|
|
2633
|
+
* @param movableStatements - Movable deprecated-alias statements in source order.
|
|
2634
|
+
* @returns A fix function that removes and re-appends each movable block.
|
|
2635
|
+
*/ function buildInterleavedFix(sourceCode, movableStatements) {
|
|
2145
2636
|
var blockRanges = [];
|
|
2146
2637
|
var blockTexts = [];
|
|
2147
2638
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2148
2639
|
try {
|
|
2149
|
-
for(var _iterator =
|
|
2640
|
+
for(var _iterator = movableStatements[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2150
2641
|
var stmt = _step.value;
|
|
2151
2642
|
var range = getStatementBlockRange(sourceCode, stmt);
|
|
2152
2643
|
blockRanges.push(range);
|
|
@@ -2189,19 +2680,19 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
2189
2680
|
}
|
|
2190
2681
|
/**
|
|
2191
2682
|
* Reports the `missingCompatMarker` violation, choosing between the marker-only and interleaved
|
|
2192
|
-
* fix strategies based on whether the
|
|
2683
|
+
* fix strategies based on whether the movable tail is already at the bottom of the file.
|
|
2193
2684
|
*
|
|
2194
2685
|
* @param args - Inputs grouped as a single config object.
|
|
2195
2686
|
* @param args.context - The ESLint rule context.
|
|
2196
2687
|
* @param args.sourceCode - The ESLint `SourceCode` instance.
|
|
2197
2688
|
* @param args.analyzable - All analyzable top-level statements in source order.
|
|
2198
|
-
* @param args.
|
|
2689
|
+
* @param args.movableStatements - The movable (relocatable deprecated-alias) subset.
|
|
2199
2690
|
*/ function reportMissingMarker(args) {
|
|
2200
|
-
var context = args.context, sourceCode = args.sourceCode, analyzable = args.analyzable,
|
|
2201
|
-
var
|
|
2202
|
-
var fixFn =
|
|
2691
|
+
var context = args.context, sourceCode = args.sourceCode, analyzable = args.analyzable, movableStatements = args.movableStatements;
|
|
2692
|
+
var firstMovable = movableStatements[0];
|
|
2693
|
+
var fixFn = allMovableStatementsAtBottom(analyzable, movableStatements) ? buildMarkerOnlyFix(sourceCode, firstMovable) : buildInterleavedFix(sourceCode, movableStatements);
|
|
2203
2694
|
context.report({
|
|
2204
|
-
node:
|
|
2695
|
+
node: firstMovable,
|
|
2205
2696
|
messageId: 'missingCompatMarker',
|
|
2206
2697
|
fix: fixFn
|
|
2207
2698
|
});
|
|
@@ -2255,17 +2746,23 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
2255
2746
|
};
|
|
2256
2747
|
}
|
|
2257
2748
|
/**
|
|
2258
|
-
* Reports the first misplaced
|
|
2749
|
+
* Reports the first misplaced movable alias (above the marker) and the first misplaced
|
|
2259
2750
|
* non-deprecated block (below the marker). At most one of each is reported per pass; ESLint's
|
|
2260
2751
|
* autofix loop converges across multiple violations.
|
|
2261
2752
|
*
|
|
2753
|
+
* Only movable statements are pulled down below the marker; only statements that are not
|
|
2754
|
+
* `@deprecated` at all are pushed up above it. A deprecated-but-not-movable statement (a primary
|
|
2755
|
+
* definition such as a literal-valued const) sitting below an existing marker is left in place, so
|
|
2756
|
+
* files that already carry a marker are not re-churned.
|
|
2757
|
+
*
|
|
2262
2758
|
* @param args - Inputs grouped as a single config object.
|
|
2263
2759
|
* @param args.context - The ESLint rule context.
|
|
2264
2760
|
* @param args.sourceCode - The ESLint `SourceCode` instance.
|
|
2265
2761
|
* @param args.analyzable - All analyzable top-level statements in source order.
|
|
2266
2762
|
* @param args.markerOffset - The marker comment's start offset.
|
|
2763
|
+
* @param args.movableSet - The set of movable (relocatable deprecated-alias) statements.
|
|
2267
2764
|
*/ function reportMisplacedStatements(args) {
|
|
2268
|
-
var context = args.context, sourceCode = args.sourceCode, analyzable = args.analyzable, markerOffset = args.markerOffset;
|
|
2765
|
+
var context = args.context, sourceCode = args.sourceCode, analyzable = args.analyzable, markerOffset = args.markerOffset, movableSet = args.movableSet;
|
|
2269
2766
|
var marker = {
|
|
2270
2767
|
comment: findCompatMarkerComment(sourceCode),
|
|
2271
2768
|
offset: markerOffset
|
|
@@ -2277,8 +2774,9 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
2277
2774
|
for(var _iterator = analyzable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2278
2775
|
var stmt = _step.value;
|
|
2279
2776
|
var isAfterMarker = stmt.range[0] > markerOffset;
|
|
2777
|
+
var isMovable = movableSet.has(stmt);
|
|
2280
2778
|
var isDeprecated = statementIsDeprecated(sourceCode, stmt);
|
|
2281
|
-
if (
|
|
2779
|
+
if (isMovable && !isAfterMarker && !reportedAliasAboveMarker) {
|
|
2282
2780
|
context.report({
|
|
2283
2781
|
node: stmt,
|
|
2284
2782
|
messageId: 'deprecatedAliasNotAtBottom',
|
|
@@ -2310,56 +2808,29 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
2310
2808
|
}
|
|
2311
2809
|
}
|
|
2312
2810
|
/**
|
|
2313
|
-
*
|
|
2314
|
-
*
|
|
2811
|
+
* ESLint rule requiring that `@deprecated` *aliases* live at the bottom of the file under a
|
|
2812
|
+
* `// COMPAT: Deprecated aliases` line comment, and that no non-deprecated exports follow the
|
|
2813
|
+
* marker. The rule mirrors the workspace's "Deprecated Alias Placement" convention so that
|
|
2814
|
+
* deprecated aliases stay segregated from current code and are easy to spot for removal.
|
|
2315
2815
|
*
|
|
2316
|
-
*
|
|
2317
|
-
*
|
|
2318
|
-
*
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
try {
|
|
2323
|
-
for(var _iterator = analyzable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2324
|
-
var stmt = _step.value;
|
|
2325
|
-
if (statementIsDeprecated(sourceCode, stmt)) {
|
|
2326
|
-
deprecatedStatements.push(stmt);
|
|
2327
|
-
}
|
|
2328
|
-
}
|
|
2329
|
-
} catch (err) {
|
|
2330
|
-
_didIteratorError = true;
|
|
2331
|
-
_iteratorError = err;
|
|
2332
|
-
} finally{
|
|
2333
|
-
try {
|
|
2334
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2335
|
-
_iterator.return();
|
|
2336
|
-
}
|
|
2337
|
-
} finally{
|
|
2338
|
-
if (_didIteratorError) {
|
|
2339
|
-
throw _iteratorError;
|
|
2340
|
-
}
|
|
2341
|
-
}
|
|
2342
|
-
}
|
|
2343
|
-
return deprecatedStatements;
|
|
2344
|
-
}
|
|
2345
|
-
/**
|
|
2346
|
-
* ESLint rule requiring that exports carrying a `@deprecated` JSDoc tag live at the bottom of the
|
|
2347
|
-
* file under a `// COMPAT: Deprecated aliases` line comment, and that no non-deprecated exports
|
|
2348
|
-
* follow the marker. The rule mirrors the workspace's "Deprecated Alias Placement" convention so
|
|
2349
|
-
* that deprecated aliases stay segregated from current code and are easy to spot for removal.
|
|
2816
|
+
* Only *relocatable* deprecated statements participate (see {@link computeMovableStatements}):
|
|
2817
|
+
* type-only declarations (always runtime-safe to move) and runtime value aliases — a
|
|
2818
|
+
* `VariableDeclaration` whose initializer references a non-deprecated binding — that are not
|
|
2819
|
+
* referenced elsewhere in the file. Primary runtime definitions (literal-valued consts, functions,
|
|
2820
|
+
* classes, enums) and any value still referenced by other code are left exactly where they are, so
|
|
2821
|
+
* the autofix can never reorder a value below its uses (a use-before-declaration error).
|
|
2350
2822
|
*
|
|
2351
2823
|
* The rule reports at most one violation per concern (missing marker, alias above marker,
|
|
2352
2824
|
* non-deprecated below marker) to keep editor noise manageable; once the first violation in a
|
|
2353
2825
|
* category is fixed, re-linting will surface the next one.
|
|
2354
2826
|
*
|
|
2355
2827
|
* Autofix coverage:
|
|
2356
|
-
* - `missingCompatMarker` — inserts `// COMPAT: Deprecated aliases` and consolidates all
|
|
2357
|
-
*
|
|
2358
|
-
*
|
|
2359
|
-
*
|
|
2360
|
-
*
|
|
2361
|
-
*
|
|
2362
|
-
* - `deprecatedAliasNotAtBottom` — moves the misplaced deprecated block from above the marker to
|
|
2828
|
+
* - `missingCompatMarker` — inserts `// COMPAT: Deprecated aliases` and consolidates all movable
|
|
2829
|
+
* blocks at the bottom of the file. When the movable tail is already at the bottom of the file,
|
|
2830
|
+
* only the marker line is inserted (no statements are moved). When movable aliases are
|
|
2831
|
+
* interleaved with other statements, the autofix removes each movable block from its current
|
|
2832
|
+
* location and re-emits them in source order at the bottom of the file under the marker.
|
|
2833
|
+
* - `deprecatedAliasNotAtBottom` — moves the misplaced movable block from above the marker to
|
|
2363
2834
|
* just after the marker. One block per pass; ESLint's autofix loop converges across multiple
|
|
2364
2835
|
* violations.
|
|
2365
2836
|
* - `nonDeprecatedAfterMarker` — moves the misplaced non-deprecated block from below the marker
|
|
@@ -2371,12 +2842,12 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
2371
2842
|
type: 'suggestion',
|
|
2372
2843
|
fixable: 'code',
|
|
2373
2844
|
docs: {
|
|
2374
|
-
description: 'Require @deprecated
|
|
2845
|
+
description: 'Require @deprecated aliases to live at the bottom of the file under a // COMPAT: Deprecated aliases marker.',
|
|
2375
2846
|
recommended: true
|
|
2376
2847
|
},
|
|
2377
2848
|
messages: {
|
|
2378
|
-
missingCompatMarker: "File contains @deprecated
|
|
2379
|
-
deprecatedAliasNotAtBottom: "This @deprecated
|
|
2849
|
+
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.",
|
|
2850
|
+
deprecatedAliasNotAtBottom: "This @deprecated alias should live below the '// COMPAT: Deprecated aliases' marker at the bottom of the file.",
|
|
2380
2851
|
nonDeprecatedAfterMarker: "This export is not @deprecated but appears after the '// COMPAT: Deprecated aliases' marker. Move it above the marker."
|
|
2381
2852
|
},
|
|
2382
2853
|
schema: []
|
|
@@ -2387,8 +2858,8 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
2387
2858
|
var _programNode_body;
|
|
2388
2859
|
var body = (_programNode_body = programNode.body) !== null && _programNode_body !== void 0 ? _programNode_body : [];
|
|
2389
2860
|
var analyzable = body.filter(isAnalyzableExportLike);
|
|
2390
|
-
var
|
|
2391
|
-
if (
|
|
2861
|
+
var movableStatements = computeMovableStatements(sourceCode, body, analyzable);
|
|
2862
|
+
if (movableStatements.length === 0) {
|
|
2392
2863
|
return;
|
|
2393
2864
|
}
|
|
2394
2865
|
var markerOffset = findCompatMarkerOffset(sourceCode);
|
|
@@ -2397,7 +2868,7 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
2397
2868
|
context: context,
|
|
2398
2869
|
sourceCode: sourceCode,
|
|
2399
2870
|
analyzable: analyzable,
|
|
2400
|
-
|
|
2871
|
+
movableStatements: movableStatements
|
|
2401
2872
|
});
|
|
2402
2873
|
return;
|
|
2403
2874
|
}
|
|
@@ -2405,7 +2876,8 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
2405
2876
|
context: context,
|
|
2406
2877
|
sourceCode: sourceCode,
|
|
2407
2878
|
analyzable: analyzable,
|
|
2408
|
-
markerOffset: markerOffset
|
|
2879
|
+
markerOffset: markerOffset,
|
|
2880
|
+
movableSet: new Set(movableStatements)
|
|
2409
2881
|
});
|
|
2410
2882
|
}
|
|
2411
2883
|
return {
|
|
@@ -2514,19 +2986,28 @@ var LINE_PREFIX_REGEX = /^(\s*\*?\s?)(.*)$/;
|
|
|
2514
2986
|
});
|
|
2515
2987
|
}
|
|
2516
2988
|
/**
|
|
2517
|
-
*
|
|
2989
|
+
* Computes, per line, whether it sits inside a fenced code block (a ```` ``` ```` block, typically
|
|
2990
|
+
* an `@example` body) and therefore must not be treated as a tag boundary. Fence delimiter lines
|
|
2991
|
+
* themselves are flagged too. Without this, `@`-prefixed lines inside a fence — decorators like
|
|
2992
|
+
* `@Global()` / `@Module()`, or JSDoc snippets — would be mis-parsed as standalone JSDoc tags.
|
|
2518
2993
|
*
|
|
2519
2994
|
* @param lines - Parsed lines in source order.
|
|
2520
|
-
* @returns
|
|
2521
|
-
*/ function
|
|
2522
|
-
var
|
|
2995
|
+
* @returns Boolean mask where `true` marks a line that must not start a tag.
|
|
2996
|
+
*/ function computeFenceMask(lines) {
|
|
2997
|
+
var mask = lines.map(function() {
|
|
2998
|
+
return false;
|
|
2999
|
+
});
|
|
3000
|
+
var fenceOpen = false;
|
|
2523
3001
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2524
3002
|
try {
|
|
2525
3003
|
for(var _iterator = lines.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2526
3004
|
var _step_value = _sliced_to_array$7(_step.value, 2), i = _step_value[0], line = _step_value[1];
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
3005
|
+
var isDelimiter = line.text.trimStart().startsWith('```');
|
|
3006
|
+
if (isDelimiter) {
|
|
3007
|
+
mask[i] = true;
|
|
3008
|
+
fenceOpen = !fenceOpen;
|
|
3009
|
+
} else {
|
|
3010
|
+
mask[i] = fenceOpen;
|
|
2530
3011
|
}
|
|
2531
3012
|
}
|
|
2532
3013
|
} catch (err) {
|
|
@@ -2543,6 +3024,32 @@ var LINE_PREFIX_REGEX = /^(\s*\*?\s?)(.*)$/;
|
|
|
2543
3024
|
}
|
|
2544
3025
|
}
|
|
2545
3026
|
}
|
|
3027
|
+
return mask;
|
|
3028
|
+
}
|
|
3029
|
+
/**
|
|
3030
|
+
* Returns true when the line at `index` opens a JSDoc tag and is not masked out by a code fence.
|
|
3031
|
+
*
|
|
3032
|
+
* @param lines - Parsed lines in source order.
|
|
3033
|
+
* @param fenceMask - Mask from {@link computeFenceMask} marking fenced lines.
|
|
3034
|
+
* @param index - Line index to test.
|
|
3035
|
+
* @returns True when the line begins a tag that should be treated as a tag boundary.
|
|
3036
|
+
*/ function isTagStart(lines, fenceMask, index) {
|
|
3037
|
+
return !fenceMask[index] && TAG_LINE_REGEX$1.test(lines[index].text);
|
|
3038
|
+
}
|
|
3039
|
+
/**
|
|
3040
|
+
* Returns the index of the first line that begins with a JSDoc `@tag`, or `-1` when none exists.
|
|
3041
|
+
*
|
|
3042
|
+
* @param lines - Parsed lines in source order.
|
|
3043
|
+
* @param fenceMask - Mask from {@link computeFenceMask} marking fenced lines.
|
|
3044
|
+
* @returns Zero-based line index of the first tag, or `-1` when no tag is present.
|
|
3045
|
+
*/ function findFirstTagIndex(lines, fenceMask) {
|
|
3046
|
+
var firstTagIndex = -1;
|
|
3047
|
+
for(var i = 0; i < lines.length; i += 1){
|
|
3048
|
+
if (isTagStart(lines, fenceMask, i)) {
|
|
3049
|
+
firstTagIndex = i;
|
|
3050
|
+
break;
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
2546
3053
|
return firstTagIndex;
|
|
2547
3054
|
}
|
|
2548
3055
|
/**
|
|
@@ -2640,15 +3147,16 @@ var LINE_PREFIX_REGEX = /^(\s*\*?\s?)(.*)$/;
|
|
|
2640
3147
|
* Collects the tag line at `startIndex` plus every following non-tag continuation line.
|
|
2641
3148
|
*
|
|
2642
3149
|
* @param lines - All parsed lines in the comment.
|
|
3150
|
+
* @param fenceMask - Mask from {@link computeFenceMask} marking fenced lines.
|
|
2643
3151
|
* @param startIndex - Index of the `@tag` opening line.
|
|
2644
3152
|
* @returns The collected tag lines and the index of the next unconsumed line.
|
|
2645
|
-
*/ function collectTagLines(lines, startIndex) {
|
|
3153
|
+
*/ function collectTagLines(lines, fenceMask, startIndex) {
|
|
2646
3154
|
var tagLines = [
|
|
2647
3155
|
lines[startIndex]
|
|
2648
3156
|
];
|
|
2649
3157
|
var j = startIndex + 1;
|
|
2650
3158
|
while(j < lines.length){
|
|
2651
|
-
if (
|
|
3159
|
+
if (isTagStart(lines, fenceMask, j)) break;
|
|
2652
3160
|
tagLines.push(lines[j]);
|
|
2653
3161
|
j += 1;
|
|
2654
3162
|
}
|
|
@@ -2679,15 +3187,16 @@ var LINE_PREFIX_REGEX = /^(\s*\*?\s?)(.*)$/;
|
|
|
2679
3187
|
* Builds a single parsed-tag record starting at `startIndex` in the line array.
|
|
2680
3188
|
*
|
|
2681
3189
|
* @param lines - All parsed lines in the comment.
|
|
3190
|
+
* @param fenceMask - Mask from {@link computeFenceMask} marking fenced lines.
|
|
2682
3191
|
* @param startIndex - Index of the `@tag` opening line.
|
|
2683
3192
|
* @returns The parsed tag and the next unconsumed line index.
|
|
2684
|
-
*/ function parseTagAt(lines, startIndex) {
|
|
3193
|
+
*/ function parseTagAt(lines, fenceMask, startIndex) {
|
|
2685
3194
|
var line = lines[startIndex];
|
|
2686
3195
|
var match = TAG_LINE_REGEX$1.exec(line.text);
|
|
2687
3196
|
var tagName = match[1];
|
|
2688
3197
|
var _extractTypeAnnotation = extractTypeAnnotation(match[2]), type = _extractTypeAnnotation.type, afterType = _extractTypeAnnotation.rest;
|
|
2689
3198
|
var _extractParamName = extractParamName$1(tagName, afterType), name = _extractParamName.name, afterName = _extractParamName.rest;
|
|
2690
|
-
var _collectTagLines = collectTagLines(lines, startIndex), tagLines = _collectTagLines.tagLines, nextIndex = _collectTagLines.nextIndex;
|
|
3199
|
+
var _collectTagLines = collectTagLines(lines, fenceMask, startIndex), tagLines = _collectTagLines.tagLines, nextIndex = _collectTagLines.nextIndex;
|
|
2691
3200
|
var description = buildTagDescription(afterName, tagLines);
|
|
2692
3201
|
return {
|
|
2693
3202
|
tag: {
|
|
@@ -2706,18 +3215,19 @@ var LINE_PREFIX_REGEX = /^(\s*\*?\s?)(.*)$/;
|
|
|
2706
3215
|
* Parses every `@tag` block starting from `firstTagIndex` to the end of the line array.
|
|
2707
3216
|
*
|
|
2708
3217
|
* @param lines - All parsed lines in the comment.
|
|
3218
|
+
* @param fenceMask - Mask from {@link computeFenceMask} marking fenced lines.
|
|
2709
3219
|
* @param firstTagIndex - Index where tag parsing should begin (`-1` skips entirely).
|
|
2710
3220
|
* @returns All parsed tags in source order.
|
|
2711
|
-
*/ function parseTags(lines, firstTagIndex) {
|
|
3221
|
+
*/ function parseTags(lines, fenceMask, firstTagIndex) {
|
|
2712
3222
|
var tags = [];
|
|
2713
3223
|
if (firstTagIndex !== -1) {
|
|
2714
3224
|
var i = firstTagIndex;
|
|
2715
3225
|
while(i < lines.length){
|
|
2716
|
-
if (!
|
|
3226
|
+
if (!isTagStart(lines, fenceMask, i)) {
|
|
2717
3227
|
i += 1;
|
|
2718
3228
|
continue;
|
|
2719
3229
|
}
|
|
2720
|
-
var _parseTagAt = parseTagAt(lines, i), tag = _parseTagAt.tag, nextIndex = _parseTagAt.nextIndex;
|
|
3230
|
+
var _parseTagAt = parseTagAt(lines, fenceMask, i), tag = _parseTagAt.tag, nextIndex = _parseTagAt.nextIndex;
|
|
2721
3231
|
tags.push(tag);
|
|
2722
3232
|
i = nextIndex;
|
|
2723
3233
|
}
|
|
@@ -2741,14 +3251,15 @@ var LINE_PREFIX_REGEX = /^(\s*\*?\s?)(.*)$/;
|
|
|
2741
3251
|
*/ function parseJsdocComment(commentValue) {
|
|
2742
3252
|
var singleLine = !commentValue.includes('\n');
|
|
2743
3253
|
var lines = buildParsedLines(commentValue);
|
|
2744
|
-
var
|
|
3254
|
+
var fenceMask = computeFenceMask(lines);
|
|
3255
|
+
var firstTagIndex = findFirstTagIndex(lines, fenceMask);
|
|
2745
3256
|
var descriptionLines = firstTagIndex === -1 ? lines.slice() : lines.slice(0, firstTagIndex);
|
|
2746
3257
|
var trimmedDescription = trimBlankBoundaries(descriptionLines);
|
|
2747
3258
|
var description = trimmedDescription.map(function(l) {
|
|
2748
3259
|
return l.text;
|
|
2749
3260
|
}).join('\n');
|
|
2750
3261
|
var descriptionParagraphs = buildDescriptionParagraphs(trimmedDescription);
|
|
2751
|
-
var tags = parseTags(lines, firstTagIndex);
|
|
3262
|
+
var tags = parseTags(lines, fenceMask, firstTagIndex);
|
|
2752
3263
|
return {
|
|
2753
3264
|
lines: lines,
|
|
2754
3265
|
descriptionLines: descriptionLines,
|