close

no-alias-methods

Added in v0.8.2

Configuration

rslint.config.ts
import { defineConfig, rstestPlugin } from '@rslint/core';

export default defineConfig([
  rstestPlugin.configs.recommended,
  {
    rules: {
      'rstest/no-alias-methods': 'error',
    },
  },
]);

Rule Details

Requires canonical matcher names so assertions use one consistent vocabulary. For example, it replaces toBeCalled with toHaveBeenCalled and toThrowError with toThrow.

The rule checks normal dot access and static bracket access. Computed matcher names are ignored because their value is only known at runtime.

Incorrect

expect(handler).toBeCalled();
expect(handler).lastCalledWith('ready');

Correct

expect(handler).toHaveBeenCalled();
expect(handler).toHaveBeenLastCalledWith('ready');

Autofix

Replaces static dot and bracket matcher aliases with canonical names while preserving the original access style.