Skip to content

Commit 41a5076

Browse files
fix(eslint): updater-explicit-return-type not applied when inheritance (#3928)
1 parent 6d3e27e commit 41a5076

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

modules/eslint-plugin/spec/rules/updater-explicit-return-type.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,16 @@ class NotOk3 {
122122
const updater = (item: Movie) => item
123123
updater()
124124
}
125+
}`),
126+
fromFixture(`
127+
@Injectable()
128+
export class CompetitorsStore2 extends CompetitorsStore1 {
129+
override updateName = this.updater<string>((state, name: string) => ({ ...state, name }));
130+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [${messageId}]
131+
132+
133+
updateName2 = this.updater(() => ({ name: 'test' }));
134+
~~~~~~~~~~~~~~~~~~~~~~~~ [${messageId}]
125135
}`),
126136
];
127137

modules/eslint-plugin/src/rules/component-store/updater-explicit-return-type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default createRule<Options, MessageIds>({
3333
const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;
3434
const withoutTypeAnnotation = `ArrowFunctionExpression:not([returnType.typeAnnotation])`;
3535
const selectors = [
36-
`ClassDeclaration[superClass.name='ComponentStore'] CallExpression[callee.object.type='ThisExpression'][callee.property.name='updater'] > ${withoutTypeAnnotation}`,
36+
`ClassDeclaration[superClass.name=/Store/] CallExpression[callee.object.type='ThisExpression'][callee.property.name='updater'] > ${withoutTypeAnnotation}`,
3737
storeNames &&
3838
`${namedExpression(
3939
storeNames

modules/eslint-plugin/src/utils/helper-functions/utils.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,6 @@ export function getLast<T extends readonly unknown[]>(items: T): T[number] {
260260
return items.slice(-1)[0];
261261
}
262262

263-
export function getDecoratorArguments({ expression }: TSESTree.Decorator) {
264-
return isCallExpression(expression) ? expression.arguments : [];
265-
}
266-
267263
export function getDecoratorName({
268264
expression,
269265
}: TSESTree.Decorator): string | undefined {
@@ -276,20 +272,6 @@ export function getDecoratorName({
276272
: undefined;
277273
}
278274

279-
export function getDecorator(
280-
{
281-
decorators,
282-
}:
283-
| TSESTree.PropertyDefinition
284-
| TSESTree.ClassDeclaration
285-
| TSESTree.MethodDefinition,
286-
decoratorName: string
287-
): TSESTree.Decorator | undefined {
288-
return decorators?.find(
289-
(decorator) => getDecoratorName(decorator) === decoratorName
290-
);
291-
}
292-
293275
export function getRawText(node: TSESTree.Node): string | null {
294276
if (isIdentifier(node)) {
295277
return node.name;

0 commit comments

Comments
 (0)