Functions Rules
Function call spacing, declaration style, naming conventions, and parameters
On This Page
function-call-spacing
No space between function name and opening parenthesis
Why: Standard JavaScript convention
myFunction(arg);console.log("message");myFunction (arg);console.log ("message");"code-style/function-call-spacing": "error"function-declaration-style
Convert function declarations to const arrow function expressions
Why: Auto-fix companion to ESLint's func-style rule
export const getToken = (): string | null => getCookie(tokenKey);export function getToken(): string | null { return getCookie(tokenKey);}"code-style/function-declaration-style": "error"function-naming-convention
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`.
function getUserDataHandler() {}function clickHandler() {}const postDataHandler = async () => {};function handleClick() {}function getUserData() {}const postData = async () => {};"code-style/function-naming-convention": "error"function-object-destructure
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
| Option | Type | Default | Description |
|---|---|---|---|
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. |
"code-style/function-object-destructure": ["error", { moduleImportStyle: "smart" }]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>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);"code-style/function-object-destructure": "error"function-params-per-line
When multiline, each parameter on its own line
Why: Mixed formatting is confusing; one per line is scannable
function createUser( name, email, password,) {}function createUser(name, email, password, role) {}"code-style/function-params-per-line": "error"no-empty-lines-in-function-params
No empty lines between parameters
Why: Empty lines in parameter lists waste space
function createUser( name, email, role,) {}function createUser( name, email, role,) {}"code-style/no-empty-lines-in-function-params": "error"