Skip to content

typescript/array-type Style

🛠️ An auto-fix is available for this rule.

What it does

Require consistently using either T[] or Array<T> for arrays.

Why is this bad?

Using the Array type directly is not idiomatic. Instead, use the array type T[] or Array<T>.

Example

typescript
const arr: Array<number> = new Array<number>();
const arr: number[] = new Array<number>();

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny typescript/array-type
json
{
  "rules": {
    "typescript/array-type": "error"
  }
}

References

Released under the MIT License.