no-method-signature
Disallow interface method signatures.
Targeted pattern scopeâ
This rule targets TSMethodSignature nodes in TypeScript interfaces.
What this rule reportsâ
- Method signatures inside interfaces, such as
run(): void
Why this rule existsâ
Readonly function-valued properties are more explicit and align with immutable interface design.
â Incorrectâ
interface Service {
run(input: string): number;
}
â Correctâ
interface Service {
readonly run: (input: string) => number;
}
Additional examplesâ
// â Optional method signature
interface Formatter {
format?(value: string): string;
}
// â
Optional readonly function property
interface Formatter {
readonly format?: (value: string) => string;
}
ESLint flat config exampleâ
import immutable from "eslint-plugin-immutable-2";
export default [
{
files: ["**/*.{ts,tsx,mts,cts}"],
plugins: { immutable },
rules: {
"immutable/no-method-signature": "error",
},
},
];
When not to use itâ
If your TypeScript style guide intentionally uses method signatures for readability (especially in public library interfaces with overload-heavy APIs), this rule may conflict with established conventions. In that case, keep a consistent method-signature style instead of mixing both forms.
Rule catalog ID: R907