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 and stylisticStrict 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
const value: () => void
value
= function
function (local function) other(): void
other
() {};
let
let value: () => void
value
= function
function (local function) other(): void
other
() {};
const
const object: {
value: () => void;
}
object
= {
value: () => void
value
: function
function (local function) other(): void
other
() {} };
class
class Example
Example
{
Example.value: () => void
value
= function
function (local function) other(): void
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 ❤️‍🔥 around the world by the Flint team and contributors.