src/content/docs/linter/rules/no-function-assign.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.0.0` - Diagnostic Category: [`lint/suspicious/noFunctionAssign`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule doesn't have a fix. - The default severity of this rule is [**error**](/reference/diagnostics#error). - Sources: - Same as [`no-func-assign`](https://eslint.org/docs/latest/rules/no-func-assign){
"linter": {
"rules": {
"suspicious": {
"noFunctionAssign": "error"
}
}
}
}
Disallow reassigning function declarations.
function foo() { };
foo = bar;
function foo() {
foo = bar;
}
foo = bar;
function foo() { };
[foo] = bar;
function foo() { };
({ x: foo = 0 } = bar);
function foo() { };
function foo() {
[foo] = bar;
}
(function () {
({ x: foo = 0 } = bar);
function foo() { };
})();
function foo() {
var foo = bar;
}
function foo(foo) {
foo = bar;
}
function foo() {
var foo;
foo = bar;
}
var foo = () => {};
foo = bar;
var foo = function() {};
foo = bar;
var foo = function() {
foo = bar;
};
import bar from 'bar';
function foo() {
var foo = bar;
}