Skip to main content

sort-call-signature

Require call signatures to be the first member in interfaces.

Targeted pattern scopeโ€‹

This rule targets interface call signatures that are not the first member in a TSInterfaceBody.

What this rule reportsโ€‹

This rule reports interface call signatures when they are not the first member in the interface body.

Why this rule existsโ€‹

Placing call signatures first gives function-like interfaces a consistent, discoverable shape.

โŒ Incorrectโ€‹

interface I {
x: string;
(): string;
}

โœ… Correctโ€‹

interface I {
(): string;
x: string;
}

Behavior and migration notesโ€‹

This rule reports only and does not provide an autofix.

Migration is mechanical: move call signatures above other members in each affected interface.

Optionsโ€‹

This rule has no options.

Additional examplesโ€‹

interface Factory {
new (): FactoryInstance;
(): FactoryInstance;
version: string;
}
// โŒ call signature is not first

interface FactoryFixed {
(): FactoryInstance;
new (): FactoryInstance;
version: string;
}
// โœ… valid

ESLint flat config exampleโ€‹

import etcMisc from "eslint-plugin-etc-misc";

export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/sort-call-signature": "error",
},
},
];

When not to use itโ€‹

Disable this rule if interface member order is not important in your style guide.

Package documentationโ€‹

Rule catalog ID: R066

Further readingโ€‹

Adoption resourcesโ€‹

  • Start at warning level in CI, then move to error after cleanup.
  • Use focused codemods/autofix batches per package or directory.