Skip to content

Functions Rules

Function call spacing, declaration style, naming conventions, and parameters

6 rules6 auto-isFixable1 isConfigurable

function-call-spacing

auto-isFixable

No space between function name and opening parenthesis

Why: Standard JavaScript convention
Correct
javascript
myFunction(arg);console.log("message");
Incorrect
javascript
myFunction (arg);console.log ("message");
eslint.config.js
javascript
"code-style/function-call-spacing": "error"

function-declaration-style

auto-isFixable

Convert function declarations to const arrow function expressions

Why: Auto-fix companion to ESLint's func-style rule
Correct
javascript
export const getToken = (): string | null => getCookie(tokenKey);
Incorrect
javascript
export function getToken(): string | null {    return getCookie(tokenKey);}
eslint.config.js
javascript
"code-style/function-declaration-style": "error"

function-naming-convention

auto-isFixable

Functions use camelCase, start with verb (get/set/fetch/post/put/patch/delete/...), end with Handler suffix. Functions in reducers/ folder are exempted (folder-based-naming-convention enforces Reducer suffix there instead).

Why: Function names should describe actions clearly. Verb prefix communicates intent; Handler suffix marks callables consistently. Reducers follow the `<name>Reducer` convention — combining Handler with Reducer would produce ugly compound names like `authReducerHandler`.
Correct
javascript
function getUserDataHandler() {}function clickHandler() {}const postDataHandler = async () => {};
Incorrect
javascript
function handleClick() {}function getUserData() {}const postData = async () => {};
eslint.config.js
javascript
"code-style/function-naming-convention": "error"

function-object-destructure

auto-isFixableisConfigurable

Non-component functions should accept typed params and destructure in the body. Detects dot notation access of object params and suggests destructuring. Also enforces dot notation for module imports (configurable via moduleImportStyle option). Supports nested destructure with aliases, JSX usage, and three styles: smart (default), strict-dot, destructure.

Why: Keeping function signatures clean and short improves readability. Dot notation for module imports (e.g., `api.getUser()` instead of `const { getUser } = api`) improves searchability and prevents naming collisions. JSX usage allowed to keep destructure since `<Button />` reads cleaner than `<ui.Button />`.

Options

OptionTypeDefaultDescription
moduleImportStyle"smart" | "strict-dot" | "destructure""smart"How to handle module imports. 'smart' (default): enforce dot notation but keep destructure when used only as JSX elements. 'strict-dot': pure dot notation even for JSX (<ui.Button />). 'destructure': opposite direction — enforce destructure of module imports, autofix dot notation to destructure.
eslint.config.js
javascript
"code-style/function-object-destructure": ["error", { moduleImportStyle: "smart" }]
Correct
javascript
const createUserHandler = async (data: CreateUserParamsInterface) => {    const { age, email, name } = data;}; // Module import — dot notationimport { api } from "@/api";const user = api.getUser(id); // JSX exception (smart mode default) — destructure keptimport { ui } from "@/utils";const { Button } = ui;<Button>Click</Button>
Incorrect
javascript
const createUserHandler = async ({ age, email, name }: CreateUserParamsInterface) => {}; // Module import destructured (smart/strict-dot modes flag this)import { api } from "@/api";const { getUser } = api;const user = getUser(id);
eslint.config.js
javascript
"code-style/function-object-destructure": "error"

function-params-per-line

auto-isFixable

When multiline, each parameter on its own line

Why: Mixed formatting is confusing; one per line is scannable
Correct
javascript
function createUser(    name,    email,    password,) {}
Incorrect
javascript
function createUser(name,    email, password,    role) {}
eslint.config.js
javascript
"code-style/function-params-per-line": "error"

no-empty-lines-in-function-params

auto-isFixable

No empty lines between parameters

Why: Empty lines in parameter lists waste space
Correct
javascript
function createUser(    name,    email,    role,) {}
Incorrect
javascript
function createUser(    name,     email,     role,) {}
eslint.config.js
javascript
"code-style/no-empty-lines-in-function-params": "error"