no-mixed-interface
Keep interface members structurally consistent.
Targeted pattern scopeâ
This rule targets TSInterfaceDeclaration members and checks transitions between member shapes.
What this rule reportsâ
- Interfaces mixing method signatures and property signatures
- Interfaces mixing incompatible member kinds in sequence
Why this rule existsâ
Consistent member style improves readability and avoids accidental API shape drift.
â Incorrectâ
interface Api {
run(): void;
readonly label: string;
}
â Correctâ
interface Api {
readonly run: () => void;
readonly label: string;
}
Additional examplesâ
// â Mixed member styles in one interface
interface Repository {
find(id: string): Promise<Item>;
readonly save: (item: Item) => Promise<void>;
}
// â
Uniform function-property member style
interface Repository {
readonly find: (id: string) => Promise<Item>;
readonly save: (item: Item) => Promise<void>;
}
ESLint flat config exampleâ
import immutable from "eslint-plugin-immutable-2";
export default [
{
files: ["**/*.{ts,tsx,mts,cts}"],
plugins: { immutable },
rules: {
"immutable/no-mixed-interface": "error",
},
},
];
When not to use itâ
This rule may be too strict when you maintain ambient typings that must mirror external API shapes exactly. For declaration files sourced from third-party contracts, preserving upstream style can be more important than enforcing internal consistency.
Rule catalog ID: R908