Skip to content

eslint/rules/functions ​

Functions: Declarations, parameters, return values and callbacks: consistent, small and predictable functions. Rules of ESLint, typescript-eslint and SonarJS (the Sonar way profile of SonarQube) on this subject, every rule listed; the TypeScript rules apply to TypeScript files only.

46 rules, 25 on. Source: lint/eslint/rules/functions.mjs.

RuleSettingFilesWhat it checksWhy
no-func-assignerrorJS + TSDisallow reassigning function declarations—
no-obj-callserrorJS + TSDisallow calling global object properties as functions—
arrow-body-styleoffJS + TSRequire braces around arrow function bodiesOff: breaks the prettier/prettier autofix (eslint-plugin-prettier docs).
consistent-returnoffJS + TSRequire return statements to either always or never specify valuesOff: TypeScript noImplicitReturns covers it.
default-param-lastinfoJS + TSEnforce default parameters to be lastReplaced by the TS version.
func-styleinfo, ["declaration",{"allowArrowFunctions":false}]JS + TSEnforce the consistent use of either function declarations or expressions assigned to variablesCustom: named functions use function foo(), not const foo = () =>.
max-lines-per-functionoffJS + TSEnforce a maximum number of lines of code in a functionOff: replaced by sonarjs/max-lines-per-function, like SonarQube.
max-nested-callbacksoffJS + TSEnforce a maximum depth that callbacks can be nestedOff: replaced by sonarjs/no-nested-functions, like SonarQube.
max-paramswarn, {"max":7,"countThis":"never"}JS + TSEnforce a maximum number of parameters in function definitions7 = SonarQube default (S107). Warn: a size limit: a justified exception (a data table, a state machine) may pass.
no-callererrorJS + TSDisallow the use of arguments.caller or arguments.callee—
no-empty-functionwarnJS + TSDisallow empty functionsReplaced by the TS version.
no-extra-binderrorJS + TSDisallow unnecessary calls to .bind()—
no-param-reassignwarn, {"props":true}JS + TSDisallow reassigning function parametersCustom: parameters' properties cannot be mutated either; libraries must expose methods instead.
no-return-assignwarn, "always"JS + TSDisallow assignment operators in return statementsNo assignment in return, even in parentheses.
no-useless-callinfoJS + TSDisallow unnecessary calls to .call() and .apply()—
no-useless-returnoffJS + TSDisallow redundant return statementsOff: replaced by sonarjs/no-redundant-jump, like SonarQube.
prefer-arrow-callbackoffJS + TSRequire using arrow functions for callbacksOff: breaks the prettier/prettier autofix (eslint-plugin-prettier docs).
prefer-rest-paramsinfoJS + TSRequire rest parameters instead of arguments—
sonarjs/max-lines-per-functionwarn, {"maximum":60}JS + TSFunctions should not have too many lines of codeCustom: outside Sonar way; replaces the core max-lines-per-function, like SonarQube. Warn: a size limit: a justified exception (a data table, a state machine) may pass.
sonarjs/bool-param-defaultoffJS + TSOptional boolean parameters should have default valueOff: not in the Sonar way profile of SonarQube.
sonarjs/prefer-immediate-returnoffJS + TSLocal variables should not be declared and then immediately returned or thrownOff: not in the Sonar way profile of SonarQube.
sonarjs/no-extra-argumentsoffJS + TSFunction calls should not pass extra argumentsOff: already a TypeScript compiler error.
sonarjs/no-parameter-reassignmentoffJS + TSInitial values of parameters, caught exceptions, and loop variables should not be ignoredOff: duplicate of no-param-reassign.
sonarjs/no-use-of-empty-return-valueoffJS + TSThe return value of void functions should not be usedOff: duplicate of @typescript-eslint/no-confusing-void-expression.
sonarjs/arrow-function-conventionoffJS + TSBraces and parentheses should be used consistently with arrow functionsOff: not in the Sonar way profile of SonarQube.
sonarjs/call-argument-linewarnJS + TSFunction call arguments should not start on new lines—
sonarjs/inconsistent-function-callwarnJS + TSFunctions should be called consistently with or without "new"—
sonarjs/no-function-declaration-in-blockoffJS + TSFunction declarations should not be made within blocksOff: not in the Sonar way profile of SonarQube.
sonarjs/no-identical-functionswarnJS + TSFunctions should not have identical implementations—
sonarjs/no-ignored-returnerrorJS + TSReturn values from functions without side effects should not be ignored—
sonarjs/no-inconsistent-returnsoffJS + TSFunctions should use "return" consistentlyOff: not in the Sonar way profile of SonarQube.
sonarjs/no-invariant-returnswarnJS + TSFunction returns should not be invariant—
sonarjs/no-literal-callerrorJS + TSLiterals should not be used as functions—
sonarjs/no-nested-functionswarnJS + TSFunctions should not be nested too deeplySonar way; replaces the core max-nested-callbacks, like SonarQube. Warn: a size limit: a justified exception (a data table, a state machine) may pass.
sonarjs/no-selector-parameterwarnJS + TSMethods should not contain selector parameters—
sonarjs/no-unused-function-argumentoffJS + TSUnused function parameters should be removedOff: not in the Sonar way profile of SonarQube.
no-func-assignoffTSDisallow reassigning function declarations—
no-obj-callsoffTSDisallow calling global object properties as functions—
@typescript-eslint/consistent-returnoffTSRequire return statements to either always or never specify valuesOff: TypeScript noImplicitReturns covers it.
default-param-lastoffTSEnforce default parameters to be lastReplaced by the TS version.
@typescript-eslint/default-param-lastinfoTSEnforce default parameters to be last—
max-paramsoffTSEnforce a maximum number of parameters in function definitions7 = SonarQube default (S107). Warn: a size limit: a justified exception (a data table, a state machine) may pass.
@typescript-eslint/max-paramswarn, {"max":7}TSEnforce a maximum number of parameters in function definitions7 = SonarQube default (S107). Warn: a size limit: a justified exception (a data table, a state machine) may pass.
no-empty-functionoffTSDisallow empty functionsReplaced by the TS version.
@typescript-eslint/no-empty-functionwarnTSDisallow empty functions—
@typescript-eslint/no-unnecessary-parameter-property-assignmentinfoTSDisallow unnecessary assignment of constructor property parameter—

Generated from the JSDoc of the sources.