Skip to content

functionNameMatches

Reports function names that don't match the variable or property they're assigned to.

✅ This rule is included in the ts stylistic presets.

When a named function expression is assigned to a variable or property, the function name should match the assigned name. Mismatched names can cause confusion when debugging or reading stack traces, as the function name shown may differ from the variable used in code.

const value = function other() {};
let value = function other() {};
const object = { value: function other() {} };
class Example {
value = function other() {};
}

This rule is not configurable.

If you intentionally use different names for function expressions and their assigned variables (e.g., for specific debugging purposes), you might want to disable this rule.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.