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.
Examples
Section titled “Examples”const value = function other() {};let value = function other() {};const object = { value: function other() {} };class Example { value = function other() {};}const value = function value() {};const value = function () {};const value = () => {};const object = { value: function value() {} };const object = { value: function () {} };class Example { value = function value() {};}class Example { #value = function other() {};}Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”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.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- ESLint:
func-name-matching
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.