Skip to content

no-func-assign

Reports an assignment to a function that is declared by name (function f() {} f = 0;), also f++.

A function declaration is hoisted, so calls above the assignment run the original and calls below run the new value. The name then means two things in one scope, and the declaration reads as the only definition.

To fix, assign to another variable, or declare the function with let f = function () {} where reassigning is intended.

Reported
...
import * as ns from "ns";
...
function g() {} g = 3; (function h() { h = 1; });
...
const o = { c }; const [q] = [c]; var v = 1; v = 2; let l = 1; l = 2;
js:
lint:
rules:
no-func-assign: warn # off, warn (default), error

Enabled by the presets: js/eslint-recommended, js/biome-recommended, js/oxlint.

Suppress one line with sudsy-disable-next-line no-func-assign in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
eslint no-func-assign full