func-name-matching
eslint
No autofix
eslint.config.js
export default [
{
rules: {
"func-name-matching": "error",
},
},
];Require function names to match the name of the variable or property to which they are assigned
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() {};
}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() {};
}// 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() {};
// …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.
func-name-matching
eslint
export default [
{
rules: {
"func-name-matching": "error",
},
},
];func-name-matching
eslint plugin · style
{
"rules": {
"func-name-matching": "error"
}
}nursery/useMatchingFunctionName
nursery · since 2.6.0
{
"linter": {
"rules": {
"nursery": {
"useMatchingFunctionName": "error"
}
}
}
}Disallow null comparisons without type-checking operators
Disallow specified modules when loaded by import
Disallow specified warning terms in comments
Disallow declarations in the global scope
Disallow use of Object.prototype.hasOwnProperty.call() and prefer use of Object.hasOwn()
Enforce using named capture group in regular expression