> 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.

# no-array-constructor

[Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1)
## Configuration

| Preset                              | Configured Value |
| ----------------------------------- | ---------------- |
| ✅ ts.configs.recommended            | `"error"`        |
| ✅ ts.configs.recommendedTypeChecked | `"error"`        |
| ✅ ts.configs.strict                 | `"error"`        |
| ✅ ts.configs.strictTypeChecked      | `"error"`        |


```ts title=rslint.config.ts
import { defineConfig, ts } from '@rslint/core';

export default defineConfig([
  ts.configs.recommended,
  {
    rules: {
      '@typescript-eslint/no-array-constructor': 'error',
    },
  },
]);
```

## Rule Details

Disallow generic `Array` constructors.

Use of the `Array` constructor to create arrays is generally discouraged in favor of array literal notation because of the single-argument pitfall and because the `Array` global may be redefined.

The rule allows single-argument calls since they are commonly used to create arrays with a specific size.

Examples of **incorrect** code for this rule:

```javascript
new Array();
Array();
new Array(x, y);
Array(x, y);
new Array(0, 1, 2);
Array(0, 1, 2);
```

Examples of **correct** code for this rule:

```typescript
[];
[x, y];
[0, 1, 2];
new Array(500); // single argument creates array with size
Array(someOtherArray.length);
new Array<Foo>(); // TypeScript generic syntax
new Array<Foo>(1, 2, 3);
```

## Original Documentation

- [typescript-eslint: no-array-constructor](https://typescript-eslint.io/rules/no-array-constructor)
- [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-array-constructor.ts)
