no-func-assign
JavaScript / TypeScriptsuspiciousno fixdefault: warnjs/eslint-recommendedjs/biome-recommendedjs/oxlint
What it does
Section titled “What it does”Reports an assignment to a function that is declared by name (function f() {} f = 0;), also f++.
Why it matters
Section titled “Why it matters”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.
Example
Section titled “Example”...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;Configuration
Section titled “Configuration”js: lint: rules: no-func-assign: warn # off, warn (default), errorEnabled 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.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| eslint | no-func-assign |
full |