Skip to content

Commit

Permalink
fix(eslint): updater-explicit-return-type not applied when inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver committed Jun 7, 2023
1 parent 6d3e27e commit ff2f2c7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ class NotOk3 {
const updater = (item: Movie) => item
updater()
}
}`),
fromFixture(`
@Injectable()
export class CompetitorsStore2 extends CompetitorsStore1 {
override updateName = this.updater<string>((state, name: string) => ({ ...state, name }));
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [${messageId}]
updateName2 = this.updater(() => ({ name: 'test' }));
~~~~~~~~~~~~~~~~~~~~~~~~ [${messageId}]
}`),
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default createRule<Options, MessageIds>({
const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;
const withoutTypeAnnotation = `ArrowFunctionExpression:not([returnType.typeAnnotation])`;
const selectors = [
`ClassDeclaration[superClass.name='ComponentStore'] CallExpression[callee.object.type='ThisExpression'][callee.property.name='updater'] > ${withoutTypeAnnotation}`,
`ClassDeclaration[superClass.name=/Store/] CallExpression[callee.object.type='ThisExpression'][callee.property.name='updater'] > ${withoutTypeAnnotation}`,
storeNames &&
`${namedExpression(
storeNames
Expand Down
18 changes: 0 additions & 18 deletions modules/eslint-plugin/src/utils/helper-functions/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,6 @@ export function getLast<T extends readonly unknown[]>(items: T): T[number] {
return items.slice(-1)[0];
}

export function getDecoratorArguments({ expression }: TSESTree.Decorator) {
return isCallExpression(expression) ? expression.arguments : [];
}

export function getDecoratorName({
expression,
}: TSESTree.Decorator): string | undefined {
Expand All @@ -276,20 +272,6 @@ export function getDecoratorName({
: undefined;
}

export function getDecorator(
{
decorators,
}:
| TSESTree.PropertyDefinition
| TSESTree.ClassDeclaration
| TSESTree.MethodDefinition,
decoratorName: string
): TSESTree.Decorator | undefined {
return decorators?.find(
(decorator) => getDecoratorName(decorator) === decoratorName
);
}

export function getRawText(node: TSESTree.Node): string | null {
if (isIdentifier(node)) {
return node.name;
Expand Down

0 comments on commit ff2f2c7

Please sign in to comment.