Skip to content

eslint/no-class-assign Correctness ​

✅ This rule is turned on by default.

What it does ​

Disallow reassigning class variables.

Why is this bad? ​

ClassDeclaration creates a variable that can be re-assigned, but the re-assignment is a mistake in most cases.

Example ​

javascript
class A {}
A = 123;
let a = new A(); // Error

How to use ​

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny no-class-assign
json
{
  "rules": {
    "no-class-assign": "error"
  }
}

References ​

Released under the MIT License.