# prefer-array-literal

Prefer an empty array literal over the canonical Array constructor

The canonical zero-argument `Array.new` call constructs the same empty array as `[]`.
Instead, you SHOULD use the array literal.

- Category: style
- Level: warning
- Fix: automatic
- Scope: module

## Reported

```ds title="main.ds"
function values(): int32[] {
    return Array.new();
}
```

## Accepted

```ds title="main.ds"
function values(): int32[] {
    return [];
}
```

## Prior art

- [ESLint · no-array-constructor](https://eslint.org/docs/latest/rules/no-array-constructor)
- [typescript-eslint · no-array-constructor](https://typescript-eslint.io/rules/no-array-constructor)
- [eslint-plugin-unicorn · no-new-array](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-new-array.md)

[language/linter/src/rules/style/prefer_array_literal.rs:8](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/style/prefer_array_literal.rs#L8)
