# array-element-newline

Rule `eslint/array-element-newline`. Enforce line breaks after each array element

- Source: eslint
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Deprecated: yes
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1858 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `array-element-newline` | no | safe | package `eslint` | [docs](https://eslint.org/docs/latest/rules/array-element-newline) |

## Code examples

### Incorrect: the rule reports this

```js
var c = [1, 2];
var d = [1, 2, 3];
var e = [1, 2, 3
];
var f = [
  1, 2, 3
];
var g = [
    function foo() {
        dosomething();
    }, function bar() {
        dosomething();
    }
];
```

```js
var c = [
    1,
    2
];
var d = [
    1,
    2,
    3
];
var e = [
    function foo() {
        dosomething();
    },
    function bar() {
        dosomething();
    }
];
```

```js
var a = [
    1, 2,
    3
];
var b = [
    function foo() {
        dosomething();
    }, function bar() {
        dosomething();
    },
    function baz() {
        dosomething();
    }
];
```

### Correct: the rule accepts this

```js
var a = [];
var b = [1];
var c = [1,
    2];
var d = [1,
    2,
    3];
var d = [
  1,
  2,
  3
];
var e = [
    function foo() {
        dosomething();
    },
    function bar() {
        dosomething();
    }
];
```

```js
var a = [];
var b = [1];
var c = [1, 2];
var d = [1, 2, 3];
var e = [
    1, 2, 3];
var f = [
  1, 2, 3
];
var g = [
    function foo() {
        dosomething();
    }, function bar() {
        dosomething();
    }
];
```

```js
var a = [];
var b = [1];
var c = [1, 2];
var d = [1, 2, 3];
var e = [
    function foo() {
        dosomething();
    },
    function bar() {
        dosomething();
    }
];
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "array-element-newline": "error",
    },
  },
];
```

## Related rules

- [vue/array-element-newline](https://lintradar.dev/rules/vue/array-element-newline.md): Enforce line breaks after each array element in `<template>`
- [eslint/sort-keys](https://lintradar.dev/rules/eslint/sort-keys.md): Require object keys to be sorted
- [eslint/sort-imports](https://lintradar.dev/rules/eslint/sort-imports.md): Enforce sorted `import` declarations within modules
- [eslint/no-undefined](https://lintradar.dev/rules/eslint/no-undefined.md): Disallow the use of `undefined` as an identifier
- [eslint/id-length](https://lintradar.dev/rules/eslint/id-length.md): Enforce minimum and maximum identifier lengths
- [eslint/no-ternary](https://lintradar.dev/rules/eslint/no-ternary.md): Disallow ternary operators

---

Web page: https://lintradar.dev/rules/eslint/array-element-newline. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
