src/content/docs/linter/rules/no-floating-classes.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> :::caution This rule is part of the [nursery](/linter/#nursery) group. This means that it is experimental and the behavior can change at any time. ::: ## Summary - Rule available since: `v2.3.12` - Diagnostic Category: [`lint/nursery/noFloatingClasses`](/reference/diagnostics#diagnostic-category) - This rule doesn't have a fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Same as [`no-new`](https://eslint.org/docs/latest/rules/no-new){
"linter": {
"rules": {
"nursery": {
"noFloatingClasses": "error"
}
}
}
}
Disallow new operators outside of assignments or comparisons.
The goal of using new with a constructor is typically to create an object of a particular type and store that object in a variable, such as:
const person = new Person();
It's less common to use new and not store the result, such as:
new Person();
In this case, the created object is thrown away because its reference isn't stored anywhere, and in many cases, this means that the constructor should be replaced with a function that doesn't require new to be used.
new Thing();
const thing = new Thing();