@dereekb/dbx-web 13.10.6 → 13.10.7

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.
@@ -0,0 +1,1096 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Module that holds Angular component decorators.
5
+ */ var ANGULAR_CORE_MODULE = '@angular/core';
6
+ /**
7
+ * Decorators that mark a class with a component-scoped DestroyRef lifecycle.
8
+ *
9
+ * `@Injectable` is intentionally excluded — services often expose long-lived
10
+ * Subjects as part of their public API and cleaning them on destroy is wrong.
11
+ */ var ANGULAR_COMPONENT_DECORATORS = new Set([
12
+ 'Component',
13
+ 'Directive',
14
+ 'Pipe'
15
+ ]);
16
+ /**
17
+ * Module that holds the dbx-components RxJS extras (SubscriptionObject).
18
+ */ var DEREEKB_RXJS_MODULE = '@dereekb/rxjs';
19
+ /**
20
+ * Module that holds Subject/BehaviorSubject/etc.
21
+ */ var RXJS_MODULE = 'rxjs';
22
+ /**
23
+ * Module that holds the cleanup helpers (cleanSubscription, completeOnDestroy, clean).
24
+ */ var DEREEKB_DBX_CORE_MODULE = '@dereekb/dbx-core';
25
+ /**
26
+ * Identifier name for the `SubscriptionObject` class.
27
+ */ var SUBSCRIPTION_OBJECT_NAME = 'SubscriptionObject';
28
+ /**
29
+ * Identifier names for RxJS Subject classes that should be wrapped with `completeOnDestroy`.
30
+ */ var SUBJECT_NAMES = new Set([
31
+ 'Subject',
32
+ 'BehaviorSubject',
33
+ 'ReplaySubject',
34
+ 'AsyncSubject'
35
+ ]);
36
+ /**
37
+ * Helper imported from `@dereekb/dbx-core` that replaces a manual SubscriptionObject creation.
38
+ */ var CLEAN_SUBSCRIPTION_HELPER = 'cleanSubscription';
39
+ /**
40
+ * Helper imported from `@dereekb/dbx-core` that wraps a Subject so it completes on destroy.
41
+ */ var COMPLETE_ON_DESTROY_HELPER = 'completeOnDestroy';
42
+ /**
43
+ * Underlying Destroyable/DestroyFunction primitive helper from `@dereekb/dbx-core`.
44
+ *
45
+ * Accepted as a wrapper for `new SubscriptionObject(...)` since `SubscriptionObject`
46
+ * is `Destroyable`. Not accepted for raw Subjects since those are neither
47
+ * `Destroyable` nor `DestroyFunction` and would not actually call `.complete()`.
48
+ */ var CLEAN_HELPER = 'clean';
49
+ /**
50
+ * Creates an empty {@link ImportRegistry}.
51
+ *
52
+ * @returns A fresh empty registry.
53
+ */ function createImportRegistry() {
54
+ return {
55
+ bySource: new Map(),
56
+ localToSource: new Map(),
57
+ sourceToDeclaration: new Map(),
58
+ lastImportDeclaration: null
59
+ };
60
+ }
61
+ /**
62
+ * Records an `ImportDeclaration` node in the registry. Call from the rule's
63
+ * `ImportDeclaration` visitor for every import in the file.
64
+ *
65
+ * @param registry - The registry to mutate.
66
+ * @param node - The ImportDeclaration AST node.
67
+ */ function trackImportDeclaration(registry, node) {
68
+ var _registry_bySource_get, _node_specifiers;
69
+ var _node_source;
70
+ var source = (_node_source = node.source) === null || _node_source === void 0 ? void 0 : _node_source.value;
71
+ if (!source) {
72
+ return;
73
+ }
74
+ registry.lastImportDeclaration = node;
75
+ registry.sourceToDeclaration.set(source, node);
76
+ var localNames = (_registry_bySource_get = registry.bySource.get(source)) !== null && _registry_bySource_get !== void 0 ? _registry_bySource_get : new Set();
77
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
78
+ try {
79
+ for(var _iterator = ((_node_specifiers = node.specifiers) !== null && _node_specifiers !== void 0 ? _node_specifiers : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
80
+ var specifier = _step.value;
81
+ if (specifier.type === 'ImportSpecifier' || specifier.type === 'ImportDefaultSpecifier' || specifier.type === 'ImportNamespaceSpecifier') {
82
+ var _specifier_local;
83
+ var localName = (_specifier_local = specifier.local) === null || _specifier_local === void 0 ? void 0 : _specifier_local.name;
84
+ if (localName) {
85
+ localNames.add(localName);
86
+ registry.localToSource.set(localName, source);
87
+ }
88
+ }
89
+ }
90
+ } catch (err) {
91
+ _didIteratorError = true;
92
+ _iteratorError = err;
93
+ } finally{
94
+ try {
95
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
96
+ _iterator.return();
97
+ }
98
+ } finally{
99
+ if (_didIteratorError) {
100
+ throw _iteratorError;
101
+ }
102
+ }
103
+ }
104
+ registry.bySource.set(source, localNames);
105
+ }
106
+ /**
107
+ * Returns true when the given local identifier name was imported from the given module.
108
+ *
109
+ * @param registry - The import registry built from the file's import declarations.
110
+ * @param localName - The local identifier (as it appears in code).
111
+ * @param fromSource - The expected source-module string.
112
+ * @returns True when the local name maps to the given source.
113
+ */ function isImportedFrom(registry, localName, fromSource) {
114
+ return registry.localToSource.get(localName) === fromSource;
115
+ }
116
+ /**
117
+ * Extracts the decorator name from a decorator AST node.
118
+ *
119
+ * Handles `@Foo()` (CallExpression) and `@Foo` (Identifier). Returns the empty
120
+ * string for anything else.
121
+ *
122
+ * @param decorator - The decorator AST node.
123
+ * @returns The decorator name, or empty string when unrecognized.
124
+ */ function getDecoratorName(decorator) {
125
+ var expression = decorator === null || decorator === void 0 ? void 0 : decorator.expression;
126
+ if (!expression) {
127
+ return '';
128
+ }
129
+ if (expression.type === 'CallExpression') {
130
+ var _expression_callee, _expression_callee1, _expression_callee_property;
131
+ if (((_expression_callee = expression.callee) === null || _expression_callee === void 0 ? void 0 : _expression_callee.type) === 'Identifier') {
132
+ return expression.callee.name;
133
+ }
134
+ if (((_expression_callee1 = expression.callee) === null || _expression_callee1 === void 0 ? void 0 : _expression_callee1.type) === 'MemberExpression' && ((_expression_callee_property = expression.callee.property) === null || _expression_callee_property === void 0 ? void 0 : _expression_callee_property.type) === 'Identifier') {
135
+ return expression.callee.property.name;
136
+ }
137
+ }
138
+ if (expression.type === 'Identifier') {
139
+ return expression.name;
140
+ }
141
+ return '';
142
+ }
143
+ /**
144
+ * Returns the first decorator on the class that names a component-tier
145
+ * Angular decorator (`@Component`, `@Directive`, `@Pipe`) imported from
146
+ * `@angular/core`, or null when none match.
147
+ *
148
+ * @param classNode - The ClassDeclaration / ClassExpression AST node.
149
+ * @param registry - The file's import registry, used to verify the decorator
150
+ * identifier really came from `@angular/core` (and not a local alias).
151
+ * @returns The matching decorator and its name, or null.
152
+ */ function findAngularComponentDecorator(classNode, registry) {
153
+ var decorators = classNode === null || classNode === void 0 ? void 0 : classNode.decorators;
154
+ var result = null;
155
+ if (decorators && decorators.length > 0) {
156
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
157
+ try {
158
+ for(var _iterator = decorators[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
159
+ var decorator = _step.value;
160
+ var name = getDecoratorName(decorator);
161
+ if (ANGULAR_COMPONENT_DECORATORS.has(name) && isImportedFrom(registry, name, ANGULAR_CORE_MODULE)) {
162
+ result = {
163
+ decorator: decorator,
164
+ name: name
165
+ };
166
+ break;
167
+ }
168
+ }
169
+ } catch (err) {
170
+ _didIteratorError = true;
171
+ _iteratorError = err;
172
+ } finally{
173
+ try {
174
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
175
+ _iterator.return();
176
+ }
177
+ } finally{
178
+ if (_didIteratorError) {
179
+ throw _iteratorError;
180
+ }
181
+ }
182
+ }
183
+ }
184
+ return result;
185
+ }
186
+ /**
187
+ * Returns the property name of a class member when its key is a simple Identifier or string Literal.
188
+ *
189
+ * Returns null for computed/symbol/private keys.
190
+ *
191
+ * @param member - A ClassBody member AST node.
192
+ * @returns The property name, or null when not a simple key.
193
+ */ function getClassMemberName(member) {
194
+ var key = member === null || member === void 0 ? void 0 : member.key;
195
+ if (!key || member.computed) {
196
+ return null;
197
+ }
198
+ if (key.type === 'Identifier') {
199
+ return key.name;
200
+ }
201
+ if (key.type === 'Literal' && typeof key.value === 'string') {
202
+ return key.value;
203
+ }
204
+ return null;
205
+ }
206
+ /**
207
+ * Finds the `ngOnDestroy` method declaration on the given class, if any.
208
+ *
209
+ * @param classNode - The ClassDeclaration / ClassExpression AST node.
210
+ * @returns The MethodDefinition AST node for `ngOnDestroy`, or null.
211
+ */ function findNgOnDestroyMethod(classNode) {
212
+ var _classNode_body;
213
+ var members = classNode === null || classNode === void 0 ? void 0 : (_classNode_body = classNode.body) === null || _classNode_body === void 0 ? void 0 : _classNode_body.body;
214
+ var result = null;
215
+ if (members) {
216
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
217
+ try {
218
+ for(var _iterator = members[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
219
+ var member = _step.value;
220
+ if (member.type === 'MethodDefinition' && member.kind === 'method' && getClassMemberName(member) === 'ngOnDestroy') {
221
+ result = member;
222
+ break;
223
+ }
224
+ }
225
+ } catch (err) {
226
+ _didIteratorError = true;
227
+ _iteratorError = err;
228
+ } finally{
229
+ try {
230
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
231
+ _iterator.return();
232
+ }
233
+ } finally{
234
+ if (_didIteratorError) {
235
+ throw _iteratorError;
236
+ }
237
+ }
238
+ }
239
+ }
240
+ return result;
241
+ }
242
+ /**
243
+ * If the given expression is a `CallExpression` whose callee is one of the
244
+ * accepted identifier names, returns the matching name. Otherwise null.
245
+ *
246
+ * @example
247
+ * ```
248
+ * isCalledIdentifier(node, ['cleanSubscription', 'clean']) // returns 'cleanSubscription'
249
+ * ```
250
+ *
251
+ * @param node - The expression AST node.
252
+ * @param names - The accepted identifier names.
253
+ * @returns The matched name, or null.
254
+ */ function isCalledIdentifier(node, names) {
255
+ if ((node === null || node === void 0 ? void 0 : node.type) !== 'CallExpression') {
256
+ return null;
257
+ }
258
+ var callee = node.callee;
259
+ if ((callee === null || callee === void 0 ? void 0 : callee.type) === 'Identifier' && names.has(callee.name)) {
260
+ return callee.name;
261
+ }
262
+ return null;
263
+ }
264
+ /**
265
+ * Returns true when the given AST node is a `this.<propName>` MemberExpression.
266
+ *
267
+ * @param node - The AST node to check.
268
+ * @param propName - The expected property name.
269
+ * @returns True when the node is `this.<propName>`.
270
+ */ function isThisMemberAccess(node, propName) {
271
+ var _node_object, _node_property;
272
+ return (node === null || node === void 0 ? void 0 : node.type) === 'MemberExpression' && ((_node_object = node.object) === null || _node_object === void 0 ? void 0 : _node_object.type) === 'ThisExpression' && !node.computed && ((_node_property = node.property) === null || _node_property === void 0 ? void 0 : _node_property.type) === 'Identifier' && node.property.name === propName;
273
+ }
274
+ /**
275
+ * Builds a fix operation that ensures `importName` is imported from
276
+ * `fromSource` in the file. Returns null when the import is already present.
277
+ *
278
+ * Side effect: mutates the registry to mark the import as present, so two
279
+ * separate report fixes in the same lint pass don't both insert the same import.
280
+ *
281
+ * @param input - The fixer, registry, and import names.
282
+ * @returns A fix operation, or null when the import is already present.
283
+ */ function ensureNamedImportFix(input) {
284
+ var fixer = input.fixer, registry = input.registry, importName = input.importName, fromSource = input.fromSource;
285
+ var existing = registry.bySource.get(fromSource);
286
+ if (existing === null || existing === void 0 ? void 0 : existing.has(importName)) {
287
+ return null;
288
+ }
289
+ var declaration = registry.sourceToDeclaration.get(fromSource);
290
+ var result = null;
291
+ if (declaration) {
292
+ var _declaration_specifiers;
293
+ var lastSpecifier = (_declaration_specifiers = declaration.specifiers) === null || _declaration_specifiers === void 0 ? void 0 : _declaration_specifiers[declaration.specifiers.length - 1];
294
+ if (lastSpecifier) {
295
+ var updatedSet = existing !== null && existing !== void 0 ? existing : new Set();
296
+ updatedSet.add(importName);
297
+ registry.bySource.set(fromSource, updatedSet);
298
+ registry.localToSource.set(importName, fromSource);
299
+ result = fixer.insertTextAfter(lastSpecifier, ", ".concat(importName));
300
+ }
301
+ } else if (registry.lastImportDeclaration) {
302
+ var updatedSet1 = existing !== null && existing !== void 0 ? existing : new Set();
303
+ updatedSet1.add(importName);
304
+ registry.bySource.set(fromSource, updatedSet1);
305
+ registry.localToSource.set(importName, fromSource);
306
+ result = fixer.insertTextAfter(registry.lastImportDeclaration, "\nimport { ".concat(importName, " } from '").concat(fromSource, "';"));
307
+ }
308
+ return result;
309
+ }
310
+ /**
311
+ * Returns true when the given PropertyDefinition declares a `static` member.
312
+ *
313
+ * @param node - The PropertyDefinition AST node.
314
+ * @returns True when the node has `static` modifier.
315
+ */ function isStaticProperty(node) {
316
+ return (node === null || node === void 0 ? void 0 : node.static) === true;
317
+ }
318
+ /**
319
+ * Returns true when the given PropertyDefinition uses `declare`
320
+ * (`declare readonly foo: T`) — i.e. has no runtime initializer.
321
+ *
322
+ * @param node - The PropertyDefinition AST node.
323
+ * @returns True when the property is declared abstractly.
324
+ */ function isDeclareProperty(node) {
325
+ return (node === null || node === void 0 ? void 0 : node.declare) === true;
326
+ }
327
+ /**
328
+ * The Angular `OnDestroy` lifecycle interface name.
329
+ */ var ON_DESTROY_INTERFACE_NAME = 'OnDestroy';
330
+ /**
331
+ * Locates an `implements OnDestroy` clause on the class whose `OnDestroy`
332
+ * identifier resolves to the import from `@angular/core`. Returns null when
333
+ * no matching clause exists.
334
+ *
335
+ * @param classNode - The ClassDeclaration / ClassExpression AST node.
336
+ * @param registry - The file's import registry.
337
+ * @returns The match details, or null.
338
+ */ function findOnDestroyImplementsClause(classNode, registry) {
339
+ var _ref;
340
+ var allImplements = (_ref = classNode === null || classNode === void 0 ? void 0 : classNode.implements) !== null && _ref !== void 0 ? _ref : [];
341
+ var result = null;
342
+ for(var index = 0; index < allImplements.length; index += 1){
343
+ var clauseSpecifier = allImplements[index];
344
+ var expression = clauseSpecifier === null || clauseSpecifier === void 0 ? void 0 : clauseSpecifier.expression;
345
+ if ((expression === null || expression === void 0 ? void 0 : expression.type) === 'Identifier' && expression.name === ON_DESTROY_INTERFACE_NAME && isImportedFrom(registry, ON_DESTROY_INTERFACE_NAME, ANGULAR_CORE_MODULE)) {
346
+ result = {
347
+ allImplements: allImplements,
348
+ clauseSpecifier: clauseSpecifier,
349
+ index: index
350
+ };
351
+ break;
352
+ }
353
+ }
354
+ return result;
355
+ }
356
+ /**
357
+ * Computes the source range to remove for the given `implements` specifier so
358
+ * that the surrounding `implements` clause stays well-formed.
359
+ *
360
+ * Behavior:
361
+ * - When the specifier is the only entry, the entire `implements <X>` clause
362
+ * is removed, including the leading whitespace before the `implements`
363
+ * keyword (so `class Foo implements OnDestroy {` becomes `class Foo {`).
364
+ * - When the specifier is the first of several, the specifier and the
365
+ * following comma+whitespace are removed.
366
+ * - Otherwise, the preceding comma+whitespace and the specifier are removed.
367
+ *
368
+ * @param match - The `implements OnDestroy` match details.
369
+ * @param sourceCode - The ESLint sourceCode service.
370
+ * @returns A `[start, end]` range tuple suitable for `fixer.removeRange`.
371
+ */ function getImplementsSpecifierRemovalRange(match, sourceCode) {
372
+ var allImplements = match.allImplements, clauseSpecifier = match.clauseSpecifier, index = match.index;
373
+ var result;
374
+ if (allImplements.length === 1) {
375
+ var implementsKeyword = sourceCode.getTokenBefore(clauseSpecifier, {
376
+ filter: function filter(token) {
377
+ return token.type === 'Keyword' && token.value === 'implements';
378
+ }
379
+ });
380
+ var tokenBeforeImplements = implementsKeyword ? sourceCode.getTokenBefore(implementsKeyword) : null;
381
+ var startPos = tokenBeforeImplements ? tokenBeforeImplements.range[1] : implementsKeyword ? implementsKeyword.range[0] : clauseSpecifier.range[0];
382
+ result = [
383
+ startPos,
384
+ clauseSpecifier.range[1]
385
+ ];
386
+ } else if (index === 0) {
387
+ result = [
388
+ clauseSpecifier.range[0],
389
+ allImplements[1].range[0]
390
+ ];
391
+ } else {
392
+ result = [
393
+ allImplements[index - 1].range[1],
394
+ clauseSpecifier.range[1]
395
+ ];
396
+ }
397
+ return result;
398
+ }
399
+
400
+ /**
401
+ * Identifier names accepted as the wrapper around a manual `new SubscriptionObject(...)`.
402
+ */ var ACCEPTED_WRAPPERS$1 = new Set([
403
+ CLEAN_SUBSCRIPTION_HELPER,
404
+ CLEAN_HELPER
405
+ ]);
406
+ /**
407
+ * ESLint rule that requires class-field initializers of `new SubscriptionObject(...)`
408
+ * to be replaced with `cleanSubscription(...)` (which auto-registers cleanup with
409
+ * Angular's DestroyRef) on `@Component` / `@Directive` / `@Pipe` classes.
410
+ *
411
+ * Fires only when `SubscriptionObject` is imported from `@dereekb/rxjs`.
412
+ *
413
+ * Auto-fix:
414
+ * - Rewrites the initializer to `cleanSubscription(...)` (preserving any constructor argument).
415
+ * - Inserts the `cleanSubscription` named import from `@dereekb/dbx-core` if missing.
416
+ * - Removes any matching `this.<field>.destroy();` line from the same class's `ngOnDestroy`.
417
+ */ var dbxWebRequireCleanSubscriptionRule = {
418
+ meta: {
419
+ type: 'problem',
420
+ fixable: 'code',
421
+ docs: {
422
+ description: 'Require cleanSubscription() instead of new SubscriptionObject() in Angular component, directive, or pipe classes',
423
+ recommended: true
424
+ },
425
+ messages: {
426
+ missingCleanSubscription: 'Replace `new SubscriptionObject(...)` with `cleanSubscription(...)` from @dereekb/dbx-core. cleanSubscription registers cleanup with Angular DestroyRef automatically, removing the need for manual destroy() in ngOnDestroy.'
427
+ },
428
+ schema: []
429
+ },
430
+ create: function create(context) {
431
+ var registry = createImportRegistry();
432
+ var sourceCode = context.sourceCode;
433
+ var visitClass = function visitClass(classNode) {
434
+ var _ref;
435
+ var _classNode_body;
436
+ var matchedDecorator = findAngularComponentDecorator(classNode, registry);
437
+ if (!matchedDecorator) {
438
+ return;
439
+ }
440
+ var members = (_ref = (_classNode_body = classNode.body) === null || _classNode_body === void 0 ? void 0 : _classNode_body.body) !== null && _ref !== void 0 ? _ref : [];
441
+ var ngOnDestroy = findNgOnDestroyMethod(classNode);
442
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
443
+ try {
444
+ var _loop = function() {
445
+ var member = _step.value;
446
+ if (member.type !== 'PropertyDefinition' || isStaticProperty(member) || isDeclareProperty(member)) {
447
+ return "continue";
448
+ }
449
+ var propName = getClassMemberName(member);
450
+ var initializer = member.value;
451
+ if (!propName || !initializer) {
452
+ return "continue";
453
+ }
454
+ if (!isUnwrappedSubscriptionObjectNew(initializer, registry)) {
455
+ return "continue";
456
+ }
457
+ context.report({
458
+ node: initializer,
459
+ messageId: 'missingCleanSubscription',
460
+ fix: function fix(fixer) {
461
+ return buildSubscriptionObjectFix({
462
+ fixer: fixer,
463
+ newExpr: initializer,
464
+ propName: propName,
465
+ ngOnDestroy: ngOnDestroy,
466
+ registry: registry,
467
+ sourceCode: sourceCode
468
+ });
469
+ }
470
+ });
471
+ };
472
+ for(var _iterator = members[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
473
+ } catch (err) {
474
+ _didIteratorError = true;
475
+ _iteratorError = err;
476
+ } finally{
477
+ try {
478
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
479
+ _iterator.return();
480
+ }
481
+ } finally{
482
+ if (_didIteratorError) {
483
+ throw _iteratorError;
484
+ }
485
+ }
486
+ }
487
+ };
488
+ return {
489
+ ImportDeclaration: function ImportDeclaration(node) {
490
+ trackImportDeclaration(registry, node);
491
+ },
492
+ ClassDeclaration: function ClassDeclaration(classNode) {
493
+ visitClass(classNode);
494
+ },
495
+ ClassExpression: function ClassExpression(classNode) {
496
+ visitClass(classNode);
497
+ }
498
+ };
499
+ }
500
+ };
501
+ /**
502
+ * Returns true when the given initializer is a bare `new SubscriptionObject(...)`
503
+ * expression where `SubscriptionObject` resolves to the import from `@dereekb/rxjs`.
504
+ *
505
+ * Returns false when the expression is wrapped (e.g. `cleanSubscription(...)` or
506
+ * `clean(new SubscriptionObject(...))`).
507
+ *
508
+ * @param expression - The initializer expression AST node.
509
+ * @param registry - The file's import registry.
510
+ * @returns True when the expression is a flagged unwrapped `new SubscriptionObject(...)`.
511
+ */ function isUnwrappedSubscriptionObjectNew(expression, registry) {
512
+ var result = false;
513
+ if (!isCalledIdentifier(expression, ACCEPTED_WRAPPERS$1) && expression.type === 'NewExpression') {
514
+ var callee = expression.callee;
515
+ if ((callee === null || callee === void 0 ? void 0 : callee.type) === 'Identifier' && callee.name === SUBSCRIPTION_OBJECT_NAME && isImportedFrom(registry, SUBSCRIPTION_OBJECT_NAME, DEREEKB_RXJS_MODULE)) {
516
+ result = true;
517
+ }
518
+ }
519
+ return result;
520
+ }
521
+ /**
522
+ * Builds the composite fix for one violating property.
523
+ *
524
+ * @param input - The flagged expression, its property name, the class's ngOnDestroy node, the import registry, and source-code services.
525
+ * @returns A list of fix operations, or null when no fix is producible.
526
+ */ function buildSubscriptionObjectFix(input) {
527
+ var _newExpr_callee;
528
+ var fixer = input.fixer, newExpr = input.newExpr, propName = input.propName, ngOnDestroy = input.ngOnDestroy, registry = input.registry, sourceCode = input.sourceCode;
529
+ var calleeRange = (_newExpr_callee = newExpr.callee) === null || _newExpr_callee === void 0 ? void 0 : _newExpr_callee.range;
530
+ var fixes = null;
531
+ if (calleeRange) {
532
+ var collected = [];
533
+ collected.push(fixer.replaceTextRange([
534
+ newExpr.range[0],
535
+ calleeRange[1]
536
+ ], CLEAN_SUBSCRIPTION_HELPER));
537
+ var importFix = ensureNamedImportFix({
538
+ fixer: fixer,
539
+ registry: registry,
540
+ importName: CLEAN_SUBSCRIPTION_HELPER,
541
+ fromSource: DEREEKB_DBX_CORE_MODULE
542
+ });
543
+ if (importFix) {
544
+ collected.push(importFix);
545
+ }
546
+ if (ANGULAR_COMPONENT_DECORATORS.size > 0 && ngOnDestroy) {
547
+ collectNgOnDestroyRemovalFixes({
548
+ fixer: fixer,
549
+ ngOnDestroy: ngOnDestroy,
550
+ propName: propName,
551
+ methodName: 'destroy',
552
+ sourceCode: sourceCode,
553
+ fixes: collected
554
+ });
555
+ }
556
+ fixes = collected;
557
+ }
558
+ return fixes;
559
+ }
560
+ /**
561
+ * Pushes fixes that remove `this.<propName>.<methodName>()` ExpressionStatements
562
+ * from `ngOnDestroy`'s body. Removes the statement node and any preceding
563
+ * indentation on the same line so a blank line isn't left behind.
564
+ *
565
+ * @param input - The fixer, ngOnDestroy method, target property/method names, source-code service, and fix collector.
566
+ */ function collectNgOnDestroyRemovalFixes(input) {
567
+ var _ngOnDestroy_value_body, _ngOnDestroy_value;
568
+ var fixer = input.fixer, ngOnDestroy = input.ngOnDestroy, propName = input.propName, methodName = input.methodName, sourceCode = input.sourceCode, fixes = input.fixes;
569
+ var body = (_ngOnDestroy_value = ngOnDestroy.value) === null || _ngOnDestroy_value === void 0 ? void 0 : (_ngOnDestroy_value_body = _ngOnDestroy_value.body) === null || _ngOnDestroy_value_body === void 0 ? void 0 : _ngOnDestroy_value_body.body;
570
+ if (!body) {
571
+ return;
572
+ }
573
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
574
+ try {
575
+ for(var _iterator = body[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
576
+ var statement = _step.value;
577
+ var _call_callee, _member_property;
578
+ if (statement.type !== 'ExpressionStatement') {
579
+ continue;
580
+ }
581
+ var call = statement.expression;
582
+ if ((call === null || call === void 0 ? void 0 : call.type) !== 'CallExpression' || ((_call_callee = call.callee) === null || _call_callee === void 0 ? void 0 : _call_callee.type) !== 'MemberExpression') {
583
+ continue;
584
+ }
585
+ var member = call.callee;
586
+ if (member.computed || ((_member_property = member.property) === null || _member_property === void 0 ? void 0 : _member_property.type) !== 'Identifier' || member.property.name !== methodName) {
587
+ continue;
588
+ }
589
+ if (!isThisMemberAccess(member.object, propName)) {
590
+ continue;
591
+ }
592
+ fixes.push(fixer.removeRange(getStatementRangeWithLeadingWhitespace(statement, sourceCode)));
593
+ }
594
+ } catch (err) {
595
+ _didIteratorError = true;
596
+ _iteratorError = err;
597
+ } finally{
598
+ try {
599
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
600
+ _iterator.return();
601
+ }
602
+ } finally{
603
+ if (_didIteratorError) {
604
+ throw _iteratorError;
605
+ }
606
+ }
607
+ }
608
+ }
609
+ /**
610
+ * Returns the range to remove for a statement, expanded to include any
611
+ * leading whitespace on the same line and the trailing newline. This avoids
612
+ * leaving a blank line after fix application.
613
+ *
614
+ * @param statement - The ExpressionStatement AST node.
615
+ * @param sourceCode - The ESLint sourceCode service.
616
+ * @returns A range tuple `[start, end]` to pass to `fixer.removeRange`.
617
+ */ function getStatementRangeWithLeadingWhitespace(statement, sourceCode) {
618
+ var sourceText = sourceCode.text;
619
+ var start = statement.range[0];
620
+ var end = statement.range[1];
621
+ var lineStart = start;
622
+ while(lineStart > 0 && sourceText[lineStart - 1] !== '\n'){
623
+ lineStart -= 1;
624
+ }
625
+ var lineEnd = end;
626
+ if (lineEnd < sourceText.length && sourceText[lineEnd] === '\n') {
627
+ lineEnd += 1;
628
+ }
629
+ return [
630
+ lineStart,
631
+ lineEnd
632
+ ];
633
+ }
634
+
635
+ /**
636
+ * Identifier names accepted as the wrapper around a manual `new <Subject>(...)`.
637
+ *
638
+ * Only `completeOnDestroy` is accepted — `clean()` does not call `.complete()`
639
+ * on a Subject (Subjects are neither `Destroyable` nor `DestroyFunction`).
640
+ */ var ACCEPTED_WRAPPERS = new Set([
641
+ COMPLETE_ON_DESTROY_HELPER
642
+ ]);
643
+ /**
644
+ * ESLint rule that requires class-field initializers of `new Subject(...)`,
645
+ * `new BehaviorSubject(...)`, `new ReplaySubject(...)`, and `new AsyncSubject(...)`
646
+ * to be wrapped with `completeOnDestroy(...)` from `@dereekb/dbx-core` on
647
+ * `@Component` / `@Directive` / `@Pipe` classes.
648
+ *
649
+ * Fires only when the Subject identifier is imported from `rxjs`.
650
+ *
651
+ * Auto-fix:
652
+ * - Wraps the initializer with `completeOnDestroy(...)`.
653
+ * - Inserts the `completeOnDestroy` named import from `@dereekb/dbx-core` if missing.
654
+ * - Removes any matching `this.<field>.complete();` line from the same class's `ngOnDestroy`.
655
+ */ var dbxWebRequireCompleteOnDestroyRule = {
656
+ meta: {
657
+ type: 'problem',
658
+ fixable: 'code',
659
+ docs: {
660
+ description: 'Require completeOnDestroy() wrapping new Subject/BehaviorSubject/ReplaySubject/AsyncSubject in Angular component, directive, or pipe classes',
661
+ recommended: true
662
+ },
663
+ messages: {
664
+ missingCompleteOnDestroy: 'Wrap `new {{subjectName}}(...)` with `completeOnDestroy(...)` from @dereekb/dbx-core. completeOnDestroy registers cleanup with Angular DestroyRef automatically, removing the need for manual complete() in ngOnDestroy.'
665
+ },
666
+ schema: []
667
+ },
668
+ create: function create(context) {
669
+ var registry = createImportRegistry();
670
+ var sourceCode = context.sourceCode;
671
+ var visitClass = function visitClass(classNode) {
672
+ var _ref;
673
+ var _classNode_body;
674
+ var matchedDecorator = findAngularComponentDecorator(classNode, registry);
675
+ if (!matchedDecorator) {
676
+ return;
677
+ }
678
+ var members = (_ref = (_classNode_body = classNode.body) === null || _classNode_body === void 0 ? void 0 : _classNode_body.body) !== null && _ref !== void 0 ? _ref : [];
679
+ var ngOnDestroy = findNgOnDestroyMethod(classNode);
680
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
681
+ try {
682
+ var _loop = function() {
683
+ var member = _step.value;
684
+ if (member.type !== 'PropertyDefinition' || isStaticProperty(member) || isDeclareProperty(member)) {
685
+ return "continue";
686
+ }
687
+ var propName = getClassMemberName(member);
688
+ var initializer = member.value;
689
+ if (!propName || !initializer) {
690
+ return "continue";
691
+ }
692
+ var subjectName = unwrappedSubjectNewName(initializer, registry);
693
+ if (!subjectName) {
694
+ return "continue";
695
+ }
696
+ context.report({
697
+ node: initializer,
698
+ messageId: 'missingCompleteOnDestroy',
699
+ data: {
700
+ subjectName: subjectName
701
+ },
702
+ fix: function fix(fixer) {
703
+ return buildSubjectFix({
704
+ fixer: fixer,
705
+ newExpr: initializer,
706
+ propName: propName,
707
+ ngOnDestroy: ngOnDestroy,
708
+ registry: registry,
709
+ sourceCode: sourceCode
710
+ });
711
+ }
712
+ });
713
+ };
714
+ for(var _iterator = members[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
715
+ } catch (err) {
716
+ _didIteratorError = true;
717
+ _iteratorError = err;
718
+ } finally{
719
+ try {
720
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
721
+ _iterator.return();
722
+ }
723
+ } finally{
724
+ if (_didIteratorError) {
725
+ throw _iteratorError;
726
+ }
727
+ }
728
+ }
729
+ };
730
+ return {
731
+ ImportDeclaration: function ImportDeclaration(node) {
732
+ trackImportDeclaration(registry, node);
733
+ },
734
+ ClassDeclaration: function ClassDeclaration(classNode) {
735
+ visitClass(classNode);
736
+ },
737
+ ClassExpression: function ClassExpression(classNode) {
738
+ visitClass(classNode);
739
+ }
740
+ };
741
+ }
742
+ };
743
+ /**
744
+ * Returns the Subject class name when the given initializer is a bare
745
+ * `new Subject/BehaviorSubject/ReplaySubject/AsyncSubject(...)` whose
746
+ * identifier resolves to the import from `rxjs`. Returns null otherwise
747
+ * (including when the expression is already wrapped).
748
+ *
749
+ * @param expression - The initializer expression AST node.
750
+ * @param registry - The file's import registry.
751
+ * @returns The matched Subject identifier name, or null.
752
+ */ function unwrappedSubjectNewName(expression, registry) {
753
+ var result = null;
754
+ if (!isCalledIdentifier(expression, ACCEPTED_WRAPPERS) && expression.type === 'NewExpression') {
755
+ var callee = expression.callee;
756
+ if ((callee === null || callee === void 0 ? void 0 : callee.type) === 'Identifier' && SUBJECT_NAMES.has(callee.name) && isImportedFrom(registry, callee.name, RXJS_MODULE)) {
757
+ result = callee.name;
758
+ }
759
+ }
760
+ return result;
761
+ }
762
+ /**
763
+ * Builds the composite fix for one violating property.
764
+ *
765
+ * @param input - The flagged expression, its property name, the class's ngOnDestroy node, the import registry, and source-code services.
766
+ * @returns A list of fix operations.
767
+ */ function buildSubjectFix(input) {
768
+ var fixer = input.fixer, newExpr = input.newExpr, propName = input.propName, ngOnDestroy = input.ngOnDestroy, registry = input.registry, sourceCode = input.sourceCode;
769
+ var fixes = [];
770
+ fixes.push(fixer.insertTextBefore(newExpr, "".concat(COMPLETE_ON_DESTROY_HELPER, "(")));
771
+ fixes.push(fixer.insertTextAfter(newExpr, ')'));
772
+ var importFix = ensureNamedImportFix({
773
+ fixer: fixer,
774
+ registry: registry,
775
+ importName: COMPLETE_ON_DESTROY_HELPER,
776
+ fromSource: DEREEKB_DBX_CORE_MODULE
777
+ });
778
+ if (importFix) {
779
+ fixes.push(importFix);
780
+ }
781
+ if (ngOnDestroy) {
782
+ collectNgOnDestroyRemovalFixes({
783
+ fixer: fixer,
784
+ ngOnDestroy: ngOnDestroy,
785
+ propName: propName,
786
+ methodName: 'complete',
787
+ sourceCode: sourceCode,
788
+ fixes: fixes
789
+ });
790
+ }
791
+ return fixes;
792
+ }
793
+
794
+ /**
795
+ * Identifier names that, when used to wrap a class field initializer, mean the
796
+ * field's cleanup is registered with Angular DestroyRef and a manual
797
+ * `.destroy()` / `.complete()` call in ngOnDestroy is redundant.
798
+ */ var HELPER_NAMES = new Set([
799
+ CLEAN_SUBSCRIPTION_HELPER,
800
+ COMPLETE_ON_DESTROY_HELPER,
801
+ CLEAN_HELPER
802
+ ]);
803
+ /**
804
+ * Method names on a wrapped field whose call inside ngOnDestroy is redundant.
805
+ */ var REDUNDANT_METHODS = new Set([
806
+ 'destroy',
807
+ 'complete'
808
+ ]);
809
+ /**
810
+ * ESLint rule that flags `ngOnDestroy()` bodies whose statements are entirely
811
+ * redundant `this.<field>.destroy()` / `this.<field>.complete()` calls on
812
+ * fields whose initializer is wrapped with `cleanSubscription`,
813
+ * `completeOnDestroy`, or `clean`.
814
+ *
815
+ * Auto-fix:
816
+ * - Removes each redundant statement, plus its leading whitespace and trailing newline.
817
+ * - Removes the `ngOnDestroy` method declaration when its body becomes empty.
818
+ * - When the `ngOnDestroy` method is removed entirely, also removes the
819
+ * `implements OnDestroy` clause from the class (verified against the
820
+ * `@angular/core` import). The now-unused `OnDestroy` import is left for
821
+ * `eslint-plugin-unused-imports` to clean up.
822
+ * - When a class declares `implements OnDestroy` from `@angular/core` but has
823
+ * no `ngOnDestroy()` method (e.g. left over from a previous run), the
824
+ * orphaned implements clause is removed.
825
+ */ var dbxWebNoRedundantOnDestroyRule = {
826
+ meta: {
827
+ type: 'suggestion',
828
+ fixable: 'code',
829
+ docs: {
830
+ description: 'Disallow redundant ngOnDestroy calls when fields are already wrapped with cleanSubscription/completeOnDestroy/clean',
831
+ recommended: true
832
+ },
833
+ messages: {
834
+ redundantCleanupCall: 'Redundant `this.{{name}}.{{method}}()` — `{{name}}` is initialized via `{{wrapper}}(...)` which already registers cleanup with Angular DestroyRef.',
835
+ redundantNgOnDestroy: '`ngOnDestroy()` only contains redundant cleanup calls for fields wrapped with cleanSubscription/completeOnDestroy/clean. Remove the method.',
836
+ emptyNgOnDestroy: '`ngOnDestroy()` has an empty body. Remove the method.',
837
+ orphanedImplementsOnDestroy: 'Class declares `implements OnDestroy` but has no `ngOnDestroy()` method. Remove the implements clause.'
838
+ },
839
+ schema: []
840
+ },
841
+ create: function create(context) {
842
+ var registry = createImportRegistry();
843
+ var sourceCode = context.sourceCode;
844
+ var visitClass = function visitClass(classNode) {
845
+ var _ngOnDestroy_value_body, _ngOnDestroy_value;
846
+ var matchedDecorator = findAngularComponentDecorator(classNode, registry);
847
+ if (!matchedDecorator) {
848
+ return;
849
+ }
850
+ var ngOnDestroy = findNgOnDestroyMethod(classNode);
851
+ var body = ngOnDestroy === null || ngOnDestroy === void 0 ? void 0 : (_ngOnDestroy_value = ngOnDestroy.value) === null || _ngOnDestroy_value === void 0 ? void 0 : (_ngOnDestroy_value_body = _ngOnDestroy_value.body) === null || _ngOnDestroy_value_body === void 0 ? void 0 : _ngOnDestroy_value_body.body;
852
+ if (!ngOnDestroy || !body) {
853
+ var implementsMatch = findOnDestroyImplementsClause(classNode, registry);
854
+ if (implementsMatch) {
855
+ context.report({
856
+ node: implementsMatch.clauseSpecifier,
857
+ messageId: 'orphanedImplementsOnDestroy',
858
+ fix: function fix(fixer) {
859
+ return [
860
+ fixer.removeRange(getImplementsSpecifierRemovalRange(implementsMatch, sourceCode))
861
+ ];
862
+ }
863
+ });
864
+ }
865
+ return;
866
+ }
867
+ if (body.length === 0) {
868
+ context.report({
869
+ node: ngOnDestroy,
870
+ messageId: 'emptyNgOnDestroy',
871
+ fix: function fix(fixer) {
872
+ return buildRemoveNgOnDestroyFixes({
873
+ fixer: fixer,
874
+ ngOnDestroy: ngOnDestroy,
875
+ classNode: classNode,
876
+ registry: registry,
877
+ sourceCode: sourceCode
878
+ });
879
+ }
880
+ });
881
+ return;
882
+ }
883
+ var wrappedFields = collectWrappedFieldNames(classNode);
884
+ var redundantStatements = [];
885
+ var hasNonRedundantStatement = false;
886
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
887
+ try {
888
+ for(var _iterator = body[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
889
+ var statement = _step.value;
890
+ var match = matchRedundantCleanupStatement(statement, wrappedFields);
891
+ if (match) {
892
+ redundantStatements.push(match);
893
+ } else {
894
+ hasNonRedundantStatement = true;
895
+ }
896
+ }
897
+ } catch (err) {
898
+ _didIteratorError = true;
899
+ _iteratorError = err;
900
+ } finally{
901
+ try {
902
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
903
+ _iterator.return();
904
+ }
905
+ } finally{
906
+ if (_didIteratorError) {
907
+ throw _iteratorError;
908
+ }
909
+ }
910
+ }
911
+ if (redundantStatements.length === 0) {
912
+ return;
913
+ }
914
+ if (hasNonRedundantStatement) {
915
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
916
+ try {
917
+ var _loop = function() {
918
+ var entry = _step1.value;
919
+ context.report({
920
+ node: entry.statement,
921
+ messageId: 'redundantCleanupCall',
922
+ data: {
923
+ name: entry.fieldName,
924
+ method: entry.method,
925
+ wrapper: entry.wrapper
926
+ },
927
+ fix: function fix(fixer) {
928
+ return [
929
+ fixer.removeRange(getStatementRangeWithLeadingWhitespace(entry.statement, sourceCode))
930
+ ];
931
+ }
932
+ });
933
+ };
934
+ for(var _iterator1 = redundantStatements[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true)_loop();
935
+ } catch (err) {
936
+ _didIteratorError1 = true;
937
+ _iteratorError1 = err;
938
+ } finally{
939
+ try {
940
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
941
+ _iterator1.return();
942
+ }
943
+ } finally{
944
+ if (_didIteratorError1) {
945
+ throw _iteratorError1;
946
+ }
947
+ }
948
+ }
949
+ } else {
950
+ context.report({
951
+ node: ngOnDestroy,
952
+ messageId: 'redundantNgOnDestroy',
953
+ fix: function fix(fixer) {
954
+ return buildRemoveNgOnDestroyFixes({
955
+ fixer: fixer,
956
+ ngOnDestroy: ngOnDestroy,
957
+ classNode: classNode,
958
+ registry: registry,
959
+ sourceCode: sourceCode
960
+ });
961
+ }
962
+ });
963
+ }
964
+ };
965
+ return {
966
+ ImportDeclaration: function ImportDeclaration(node) {
967
+ trackImportDeclaration(registry, node);
968
+ },
969
+ ClassDeclaration: function ClassDeclaration(classNode) {
970
+ visitClass(classNode);
971
+ },
972
+ ClassExpression: function ClassExpression(classNode) {
973
+ visitClass(classNode);
974
+ }
975
+ };
976
+ }
977
+ };
978
+ /**
979
+ * Walks the class members and returns a map of property name to the wrapper
980
+ * helper used in its initializer (`cleanSubscription`, `completeOnDestroy`, or
981
+ * `clean`). Properties whose initializer is not a recognized wrapper are
982
+ * omitted.
983
+ *
984
+ * @param classNode - The ClassDeclaration / ClassExpression AST node.
985
+ * @returns Map of field name to wrapper helper name.
986
+ */ function collectWrappedFieldNames(classNode) {
987
+ var _ref;
988
+ var _classNode_body;
989
+ var result = new Map();
990
+ var members = (_ref = (_classNode_body = classNode.body) === null || _classNode_body === void 0 ? void 0 : _classNode_body.body) !== null && _ref !== void 0 ? _ref : [];
991
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
992
+ try {
993
+ for(var _iterator = members[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
994
+ var member = _step.value;
995
+ if (member.type !== 'PropertyDefinition' || isStaticProperty(member) || isDeclareProperty(member)) {
996
+ continue;
997
+ }
998
+ var propName = getClassMemberName(member);
999
+ var wrapper = propName ? wrapperNameFromInitializer(member.value) : null;
1000
+ if (propName && wrapper) {
1001
+ result.set(propName, wrapper);
1002
+ }
1003
+ }
1004
+ } catch (err) {
1005
+ _didIteratorError = true;
1006
+ _iteratorError = err;
1007
+ } finally{
1008
+ try {
1009
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1010
+ _iterator.return();
1011
+ }
1012
+ } finally{
1013
+ if (_didIteratorError) {
1014
+ throw _iteratorError;
1015
+ }
1016
+ }
1017
+ }
1018
+ return result;
1019
+ }
1020
+ /**
1021
+ * Returns the name of the cleanup helper wrapping the given initializer
1022
+ * expression, or null when the expression is not wrapped.
1023
+ *
1024
+ * @param expression - The initializer expression, or null/undefined.
1025
+ * @returns The wrapper helper name (`cleanSubscription` etc.) or null.
1026
+ */ function wrapperNameFromInitializer(expression) {
1027
+ return expression ? isCalledIdentifier(expression, HELPER_NAMES) : null;
1028
+ }
1029
+ /**
1030
+ * Returns details for a redundant cleanup statement, or null when the
1031
+ * statement is anything other than a redundant `this.<field>.<destroy|complete>()` call.
1032
+ *
1033
+ * @param statement - The body statement AST node.
1034
+ * @param wrappedFields - Map of class field names to their wrapper helper names.
1035
+ * @returns Match details, or null.
1036
+ */ function matchRedundantCleanupStatement(statement, wrappedFields) {
1037
+ var result = null;
1038
+ if (statement.type === 'ExpressionStatement') {
1039
+ var _call_arguments, _call_callee;
1040
+ var call = statement.expression;
1041
+ var isZeroArgMemberCall = (call === null || call === void 0 ? void 0 : call.type) === 'CallExpression' && ((_call_arguments = call.arguments) === null || _call_arguments === void 0 ? void 0 : _call_arguments.length) === 0 && ((_call_callee = call.callee) === null || _call_callee === void 0 ? void 0 : _call_callee.type) === 'MemberExpression';
1042
+ if (isZeroArgMemberCall) {
1043
+ var _callee_property, _callee_object, _callee_object_property;
1044
+ var callee = call.callee;
1045
+ var methodName = !callee.computed && ((_callee_property = callee.property) === null || _callee_property === void 0 ? void 0 : _callee_property.type) === 'Identifier' ? callee.property.name : null;
1046
+ if (methodName && REDUNDANT_METHODS.has(methodName) && ((_callee_object = callee.object) === null || _callee_object === void 0 ? void 0 : _callee_object.type) === 'MemberExpression' && ((_callee_object_property = callee.object.property) === null || _callee_object_property === void 0 ? void 0 : _callee_object_property.type) === 'Identifier' && !callee.object.computed) {
1047
+ var fieldName = callee.object.property.name;
1048
+ var wrapper = isThisMemberAccess(callee.object, fieldName) ? wrappedFields.get(fieldName) : undefined;
1049
+ if (wrapper) {
1050
+ result = {
1051
+ statement: statement,
1052
+ fieldName: fieldName,
1053
+ method: methodName,
1054
+ wrapper: wrapper
1055
+ };
1056
+ }
1057
+ }
1058
+ }
1059
+ }
1060
+ return result;
1061
+ }
1062
+ /**
1063
+ * Builds the fix list for removing the entire `ngOnDestroy` method along with
1064
+ * any matching `implements OnDestroy` clause from the class declaration.
1065
+ *
1066
+ * @param input - The fixer, method node, class node, registry, and source-code service.
1067
+ * @returns The fix operations to apply.
1068
+ */ function buildRemoveNgOnDestroyFixes(input) {
1069
+ var fixer = input.fixer, ngOnDestroy = input.ngOnDestroy, classNode = input.classNode, registry = input.registry, sourceCode = input.sourceCode;
1070
+ var fixes = [
1071
+ fixer.removeRange(getStatementRangeWithLeadingWhitespace(ngOnDestroy, sourceCode))
1072
+ ];
1073
+ var implementsMatch = findOnDestroyImplementsClause(classNode, registry);
1074
+ if (implementsMatch) {
1075
+ fixes.push(fixer.removeRange(getImplementsSpecifierRemovalRange(implementsMatch, sourceCode)));
1076
+ }
1077
+ return fixes;
1078
+ }
1079
+
1080
+ /**
1081
+ * ESLint plugin for dbx-web rules.
1082
+ *
1083
+ * Register as a plugin in your flat ESLint config, then enable individual rules
1084
+ * under the chosen plugin prefix (e.g. 'dereekb-dbx-web/require-clean-subscription').
1085
+ */ var dbxWebEslintPlugin = {
1086
+ rules: {
1087
+ 'require-clean-subscription': dbxWebRequireCleanSubscriptionRule,
1088
+ 'require-complete-on-destroy': dbxWebRequireCompleteOnDestroyRule,
1089
+ 'no-redundant-on-destroy': dbxWebNoRedundantOnDestroyRule
1090
+ }
1091
+ };
1092
+
1093
+ exports.dbxWebEslintPlugin = dbxWebEslintPlugin;
1094
+ exports.dbxWebNoRedundantOnDestroyRule = dbxWebNoRedundantOnDestroyRule;
1095
+ exports.dbxWebRequireCleanSubscriptionRule = dbxWebRequireCleanSubscriptionRule;
1096
+ exports.dbxWebRequireCompleteOnDestroyRule = dbxWebRequireCompleteOnDestroyRule;