# func-name-matching

Rule `eslint/func-name-matching`. Require function names to match the name of the variable or property to which they are assigned

- Source: eslint
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 2.5M weekly downloads of presets that enable it
- Trend: +96.2% last quarter
- Rank: #1480 by reach, #274 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `func-name-matching` | no | no | package `eslint` | [docs](https://eslint.org/docs/latest/rules/func-name-matching) |
| Oxlint | `func-name-matching` | no | no | plugin `eslint`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/func-name-matching.html) |
| Biome | `nursery/useMatchingFunctionName` | no | no | group nursery, since 2.6.0 | [docs](https://biomejs.dev/linter/rules/use-matching-function-name/) |

## Code examples

### Incorrect: the rule reports this

```js
let foo = function bar() {};
foo = function bar() {};
const obj = {foo: function bar() {}};
obj.foo = function bar() {};
obj['foo'] = function bar() {};
({['foo']: function bar() {}});

class C {
    foo = function bar() {};
}
```

```js
let foo = function foo() {};
foo = function foo() {};
const obj = {foo: function foo() {}};
obj.foo = function foo() {};
obj['foo'] = function foo() {};
({['foo']: function foo() {}});

class C {
    foo = function foo() {};
}
```

### Correct: the rule accepts this

```js
// equivalent to /*eslint func-name-matching: ["error", "always"]*/

const foo = function foo() {};
const foo1 = function() {};
const foo2 = () => {};
foo = function foo() {};

const obj = {foo: function foo() {}};
obj.foo = function foo() {};
obj['foo'] = function foo() {};
obj['foo//bar'] = function foo() {};
obj[foo] = function bar() {};

const obj1 = {[foo]: function bar() {}};
const obj2 = {'foo//bar': function foo() {}};
const obj3 = {foo: function() {}};

obj['x' + 2] = function bar(){};
const [ bar ] = [ function bar(){} ];
({[foo]: function bar() {}})

class C {
    foo = function foo() {};
    baz = function() {};
}

// private names are ignored
class D {
    #foo = function foo() {};
    #bar = function foo() {};
    baz() {
        this.#foo = function foo() {};
// …
```

```js
let foo = function bar() {};
const foo1 = function() {};
const foo2 = () => {};
foo = function bar() {};

const obj = {foo: function bar() {}};
obj.foo = function bar() {};
obj['foo'] = function bar() {};
obj['foo//bar'] = function foo() {};
obj[foo] = function foo() {};

const obj1 = {foo: function bar() {}};
const obj2 = {[foo]: function foo() {}};
const obj3 = {'foo//bar': function foo() {}};
const obj4 = {foo: function() {}};

obj['x' + 2] = function bar(){};
const [ bar ] = [ function bar(){} ];
({[foo]: function bar() {}})

class C {
    foo = function bar() {};
    baz = function() {};
}

// private names are ignored
class D {
    #foo = function foo() {};
    #bar = function foo() {};
    baz() {
        this.#foo = function foo() {};
        this.#foo = function bar() {};
// …
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "func-name-matching": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "func-name-matching": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "useMatchingFunctionName": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |
| [Alloy](https://lintradar.dev/presets/alloy.md) | ESLint | `eslint-config-alloy` | 166 | 31.4K | +32.4% |

## Related rules

- [eslint/no-eq-null](https://lintradar.dev/rules/eslint/no-eq-null.md): Disallow `null` comparisons without type-checking operators
- [eslint/no-restricted-imports](https://lintradar.dev/rules/eslint/no-restricted-imports.md): Disallow specified modules when loaded by `import`
- [eslint/no-warning-comments](https://lintradar.dev/rules/eslint/no-warning-comments.md): Disallow specified warning terms in comments
- [eslint/no-implicit-globals](https://lintradar.dev/rules/eslint/no-implicit-globals.md): Disallow declarations in the global scope
- [eslint/prefer-object-has-own](https://lintradar.dev/rules/eslint/prefer-object-has-own.md): Disallow use of `Object.prototype.hasOwnProperty.call()` and prefer use of `Object.hasOwn()`
- [eslint/prefer-named-capture-group](https://lintradar.dev/rules/eslint/prefer-named-capture-group.md): Enforce using named capture group in regular expression

---

Web page: https://lintradar.dev/rules/eslint/func-name-matching. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
