func-style
eslint
No autofix
eslint.config.js
export default [
{
rules: {
"func-style": "error",
},
},
];Enforce the consistent use of either function declarations or expressions assigned to variables
function foo() {
// ...
}const foo = function() {
// ...
};
const foo1 = () => {};const foo = function(): void {};const foo = function() {
// ...
};
const foo1 = () => {};
// allowed as allowArrowFunctions : false is applied only for declarationfunction process(value: string): string;
function process(value: number): number;
function process(value: unknown) {
return value;
}function foo() {
// ...
}
// Methods (functions assigned to objects) are not checked by this rule
SomeObject.foo = function() {
// ...
};Examples from the ESLint documentation.
func-style
eslint
export default [
{
rules: {
"func-style": "error",
},
},
];func-style
eslint plugin · style
{
"rules": {
"func-style": "error"
}
}nursery/useConsistentFunctionStyle
nursery · since 2.5.14
{
"linter": {
"rules": {
"nursery": {
"useConsistentFunctionStyle": "error"
}
}
}
}Disallow async functions which have no await expression
Require identifiers to match a specified regular expression
Require variables within the same declaration block to be sorted