Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

array-bracket-newline doesn't count multiline comment as multiline #9211

Closed
TWiStErRob opened this issue Sep 2, 2017 · 6 comments · Fixed by #9369
Closed

array-bracket-newline doesn't count multiline comment as multiline #9211

TWiStErRob opened this issue Sep 2, 2017 · 6 comments · Fixed by #9369
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules

Comments

@TWiStErRob
Copy link

Tell us about your environment

  • ESLint Version: 4.6.0
  • Node Version: 5.6.0
  • npm Version: 3.6.0

What parser (default, Babel-ESLint, etc.) are you using? default

Please show your full configuration:

{
	"rules": {
		"array-bracket-newline": ["warn", {
			"multiline": true
		}]
	}
}

What did you do? Please include the actual source code causing the issue.

var structure = {
	marriages: [/*
		{
			husband: { id: 1, name: "Hubby" },
			wife: { id: 2, name: "Wifey" }
		},
		...
	*/],
	// more stuff here
}

What did you expect to happen?
no warnings

What actually happened? Please include the actual, raw output from ESLint.

  2:13  warning  There should be no linebreak after '['   array-bracket-newline
  8:4   warning  There should be no linebreak before ']'  array-bracket-newline
@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Sep 2, 2017
@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Sep 2, 2017
@not-an-aardvark
Copy link
Member

Thanks for the report. I can reproduce this issue.

@i-ron-y
Copy link
Contributor

i-ron-y commented Sep 5, 2017

What is the intended behaviour here?

Should the original example be considered practically the same as ...

var structure = {
    marriages: [/* */],
    // more stuff here
}

... ? (i.e. The array in the original example technically doesn't have elements on a new line because all the new lines are part of the comment, which isn't an element.)

@not-an-aardvark
Copy link
Member

Based on the documentation, it seems like newlines should only be required in the brackets "if there are line breaks inside elements or between elements". Since the array in the example doesn't have any elements, there aren't any line breaks inside elements or between elements. So I think linkebreaks should be disallowed in this example, which means that the original code should be considered correct because it doesn't have linebreaks after the [ or before the ].

@platinumazure
Copy link
Member

This might be another case where it could make sense to work based on token/comment line breaks instead of element line breaks.

@philquinn
Copy link
Contributor

I have a PR to address this. Any reviews are welcome.

@TWiStErRob
Copy link
Author

Awesome, thank you! Confirmed working on my codebase.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Apr 5, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Apr 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants