# no-class-assign

> Disallow assigning to the name of a class

You can assign to a class declaration's name like a `let` variable. After that the class is gone, and every `new Logger()` and `instanceof Logger` in the file works with the new value. That's almost always a mistake.

This rule is on by default in JavaScript files. It's off in TypeScript files, where TypeScript reports the same mistake.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

On by default as an error. To turn it off:

```toml bunfig.toml
[lint.rules]
"no-class-assign" = "off" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```js
class Logger {}

Logger = createLogger();
```

Not reported:

{/* good */}
```js
class Logger {}

const logger = createLogger();
```

A variable that holds a class expression is an ordinary variable:

{/* good */}
```js
let Store = class {};

Store = class extends Store {};
```
