Skip to content

Commit dd4308d

Browse files
Run automated fixes (npx eslint-doc-generator && yarn lint-js -- --fix)
1 parent 0bec767 commit dd4308d

File tree

6 files changed

+27
-25
lines changed

6 files changed

+27
-25
lines changed

docs/rules/prefer-composition.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export class SomeComponent implements OnInit, OnDestroy {
5757
| Name | Description | Type |
5858
| :---------------- | :--------------------------------------------- | :------- |
5959
| `checkDecorators` | An optional array of decorator names to check. | String[] |
60+
| `superClass` | | String[] |
6061

6162
<!-- end auto-generated rule options list -->
6263

docs/rules/prefer-takeuntil.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class SomeComponent implements OnDestroy, OnInit {
6262
| `checkComplete` | Check for `complete` calls. | Boolean |
6363
| `checkDecorators` | An optional array of decorator names to check. | String[] |
6464
| `checkDestroy` | Check for `Subject`-based `ngOnDestroy`. | Boolean |
65+
| `superClass` | | String[] |
6566

6667
<!-- end auto-generated rule options list -->
6768

src/rules/prefer-composition.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const preferCompositionRule = ruleCreator({
3535
{
3636
properties: {
3737
checkDecorators: { type: 'array', items: { type: 'string' }, description: 'An optional array of decorator names to check.' },
38-
superClass: { type: "array", items: { type: "string" } },
38+
superClass: { type: 'array', items: { type: 'string' } },
3939
},
4040
type: 'object',
4141
description: stripIndent`
@@ -50,7 +50,7 @@ export const preferCompositionRule = ruleCreator({
5050
name: 'prefer-composition',
5151
create: (context) => {
5252
const { couldBeObservable, couldBeSubscription } = getTypeServices(context);
53-
const [{ checkDecorators = ["Component"], superClass = [] } = {}] = context.options;
53+
const [{ checkDecorators = ['Component'], superClass = [] } = {}] = context.options;
5454

5555
interface Entry {
5656
addCallExpressions: es.CallExpression[];
@@ -244,8 +244,8 @@ export const preferCompositionRule = ruleCreator({
244244
return true;
245245
}
246246

247-
const extendsSuperClassDeclaration =
248-
superClass.length === 0
247+
const extendsSuperClassDeclaration
248+
= superClass.length === 0
249249
? {}
250250
: {
251251
[`ClassDeclaration:matches(${superClass

src/rules/prefer-takeuntil.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ const messages = {
2121
} as const;
2222
type MessageIds = keyof typeof messages;
2323

24-
const ngOnDestroyMethodSelector =
25-
"MethodDefinition[key.name='ngOnDestroy'][kind='method']";
24+
const ngOnDestroyMethodSelector
25+
= 'MethodDefinition[key.name=\'ngOnDestroy\'][kind=\'method\']';
2626

2727
const defaultOptions: readonly {
2828
alias?: string[];
@@ -50,7 +50,7 @@ export const preferTakeuntilRule = ruleCreator({
5050
checkComplete: { type: 'boolean', description: 'Check for `complete` calls.' },
5151
checkDecorators: { type: 'array', items: { type: 'string' }, description: 'An optional array of decorator names to check.' },
5252
checkDestroy: { type: 'boolean', description: 'Check for `Subject`-based `ngOnDestroy`.' },
53-
superClass: { type: "array", items: { type: "string" } },
53+
superClass: { type: 'array', items: { type: 'string' } },
5454
},
5555
type: 'object',
5656
description: stripIndent`
@@ -166,33 +166,33 @@ export const preferTakeuntilRule = ruleCreator({
166166
if (extendsSuperClassDeclaration) {
167167
if (!superNgOnDestroyCallExpression) {
168168
check.descriptors.push({
169-
data: { method: "ngOnDestroy", name: "super" },
170-
messageId: "notCalled",
169+
data: { method: 'ngOnDestroy', name: 'super' },
170+
messageId: 'notCalled',
171171
node: ngOnDestroyDefinition.key,
172172
});
173173
}
174174
} else {
175175
if (!checkSubjectProperty(name, entry)) {
176176
check.descriptors.push({
177177
data: { name },
178-
messageId: "notDeclared",
178+
messageId: 'notDeclared',
179179
node: classDeclaration.id ?? classDeclaration,
180180
});
181181
}
182182
if (!checkSubjectCall(name, nextCallExpressions)) {
183183
check.descriptors.push({
184-
data: { method: "next", name },
185-
messageId: "notCalled",
184+
data: { method: 'next', name },
185+
messageId: 'notCalled',
186186
node: ngOnDestroyDefinition.key,
187187
});
188188
}
189189
if (
190-
checkComplete &&
191-
!checkSubjectCall(name, completeCallExpressions)
190+
checkComplete
191+
&& !checkSubjectCall(name, completeCallExpressions)
192192
) {
193193
check.descriptors.push({
194-
data: { method: "complete", name },
195-
messageId: "notCalled",
194+
data: { method: 'complete', name },
195+
messageId: 'notCalled',
196196
node: ngOnDestroyDefinition.key,
197197
});
198198
}
@@ -331,8 +331,8 @@ export const preferTakeuntilRule = ruleCreator({
331331
);
332332
}
333333

334-
const extendsSuperClassDeclaration =
335-
superClass.length === 0
334+
const extendsSuperClassDeclaration
335+
= superClass.length === 0
336336
? {}
337337
: {
338338
[`ClassDeclaration:matches(${superClass

tests/rules/prefer-composition.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ ruleTester({ types: true }).run('prefer-composition', preferCompositionRule, {
127127
`,
128128
options: [
129129
{
130-
superClass: ["BaseComponent"],
130+
superClass: ['BaseComponent'],
131131
},
132132
],
133133
},

tests/rules/prefer-takeuntil.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ ruleTester({ types: true }).run('prefer-takeuntil', preferTakeuntilRule, {
399399
`,
400400
options: [
401401
{
402-
superClass: ["BaseComponent"],
402+
superClass: ['BaseComponent'],
403403
checkComplete: true,
404404
},
405405
],
@@ -443,7 +443,7 @@ ruleTester({ types: true }).run('prefer-takeuntil', preferTakeuntilRule, {
443443
`,
444444
options: [
445445
{
446-
superClass: ["BaseComponent"],
446+
superClass: ['BaseComponent'],
447447
checkComplete: true,
448448
},
449449
],
@@ -776,11 +776,11 @@ ruleTester({ types: true }).run('prefer-takeuntil', preferTakeuntilRule, {
776776
{
777777
options: [
778778
{
779-
superClass: ["BaseComponent"],
779+
superClass: ['BaseComponent'],
780780
checkComplete: true,
781781
},
782782
],
783-
}
783+
},
784784
),
785785
fromFixture(
786786
stripIndent`
@@ -814,11 +814,11 @@ ruleTester({ types: true }).run('prefer-takeuntil', preferTakeuntilRule, {
814814
{
815815
options: [
816816
{
817-
superClass: ["BaseComponent"],
817+
superClass: ['BaseComponent'],
818818
checkComplete: true,
819819
},
820820
],
821-
}
821+
},
822822
),
823823
],
824824
});

0 commit comments

Comments
 (0)