Bug: `array-element-newline` fails when `multiline` = `true`
See original GitHub issueTell us about your environment
- ESLint Version: 4.3.0
- Node Version: *
- npm Version: *
What parser (default, Babel-ESLint, etc.) are you using? I had this happen locally, but I’ve been able to duplicate it using http://eslint.org/demo
Please show your full configuration:
Configuration
{
rules: {
"array-element-newline": [ "error", { "multiline": true } ]
}
}
What did you do? Please include the actual source code causing the issue.
var blah = [
0,
1
];
What did you expect to happen?
array-element-newline
rule should succeed
What actually happened? Please include the actual, raw output from ESLint.
The evaluated to a failure.
Output:
4:5 - There should be no linebreak here. (array-element-newline)
This can be easily reproduced if you go to http://eslint.org/demo, uncheck all rules, and insert the following text into the input box:
/*eslint array-element-newline: ["error", { "multiline": true }]*/
var blah = [
0,
1
];
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
array-element-newline - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >toml/array-element-newline | eslint-plugin-toml
This rule enforces line breaks between array elements. 1. 2. 3.
Read more >How do I handle newlines in JSON? - Stack Overflow
I used this function to strip newline or other characters in data to parse JSON data: function normalize_str($str) { $invalid = array( ...
Read more >Template literals (Template strings) - JavaScript | MDN
Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded ...
Read more >vue/max-attributes-per-line
An attribute is considered to be in a new line when there is a line break ... are acceptable per line in multi-line...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Wow, I didn’t notice that at all. Sorry to bug you guys with this.
Perhaps
multiline
should be renamed tomultiline-element
to avoid confusion. It actually took reading the doc a few times before I really caught the part that says “if there are line breaks inside elements”.Also, a multi-line option that enforces when any element is on a newline would be useful.
So… I might just be going crazy here but I swear you used to be able to enforce a rule where elements cannot overlap.
The most common case (maybe the only case) that I’m looking to solve is as follows:
What I would like to see is the ability to enforce that all array elements either share a single line or that no elements share lines. An oversimplification of this is that every line in a multiline array should end with a comma (except the last, depending on comma dangle).