For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt, and this page is available as Markdown at https://rslint.rs/rules/eslint/no-class-assign.md.
close

no-class-assign

Added in v0.1.14

Configuration

PresetConfigured Value
✅ js.configs.recommended"error"
rslint.config.ts
import { defineConfig, js } from '@rslint/core';

export default defineConfig([
  js.configs.recommended,
  {
    rules: {
      'no-class-assign': 'error',
    },
  },
]);

Rule Details

Disallows reassigning variables that were declared as class declarations. Reassigning a class declaration is almost always a mistake, as it overwrites the class with a different value. This rule checks for assignments, increment/decrement operations, and destructuring assignments that target a class name.

Examples of incorrect code for this rule:

class A {}
A = 0;

class B {}
B += 1;

class C {}
({ C } = obj);

Examples of correct code for this rule:

class A {}
var a = new A();

let B = class {};
B = 0; // B is a variable, not a class declaration

class C {}
function fn(C) {
  C = 0; // C is a parameter, not the class
}

Original Documentation