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

New option proposal for requireObjectKeysOnNewLine #6205

Closed
ljharb opened this issue May 17, 2016 · 8 comments
Closed

New option proposal for requireObjectKeysOnNewLine #6205

ljharb opened this issue May 17, 2016 · 8 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules

Comments

@ljharb
Copy link
Sponsor Contributor

ljharb commented May 17, 2016

Per #5667 (comment)

The JSCS rule requireObjectKeysOnNewLine had an allExcept: ['sameLine'] option, that eslint currently lacks. The idea was to configure it so that the following code warned:

var obj = {
  foo: "foo", bar: "bar", baz: "baz"
};
var obj = {
  foo: "foo", bar: "bar",
  baz: "baz" };
var obj = {
  foo: "foo", bar: "bar",
  baz: "baz"
};
var obj = { foo: "foo",
  bar: "bar",
  baz: "baz"
};

and only the following did not:

var obj = { foo: "foo", bar: "bar", baz: "baz" };
var obj = {
  foo: "foo",
  bar: "bar",
  baz: "baz"
};

The allowMultiplePropertiesPerLine isn't quite the same thing. Can an option be added to support this behavior from jscs?

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label May 17, 2016
@platinumazure platinumazure added enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels May 17, 2016
@platinumazure
Copy link
Member

Marked as enhancement since there is a separate feature request issue (#5667) for the rule itself. Feel free to change the labels if I goofed.

@vitorbal
Copy link
Member

I mentioned this in #5667 (comment) already, but just to make sure this doesn't get lost:

The allowMultiplePropertiesPerLine option follows exactly the behavior of the allExcept: ["sameLine"] option from JSCS. When the option is present, both of the following are valid:

var obj = {
  foo: "foo", bar: "bar", baz: "baz"
};

var obj = { foo: "foo", bar: "bar", baz: "baz" };

You will notice that their example for "good" when that option is present also has the curly braces on separate lines.
I tested this against JSCS 3.0.3 just to be sure and can confirm it's true.

So what you're proposing would be a new option, and not a port of the JSCS option.

@ljharb
Copy link
Sponsor Contributor Author

ljharb commented May 17, 2016

Thanks for clarifying - in that case, I misunderstood the previous jscs behavior to be sufficient for my use cases. New option it is!

@ljharb ljharb changed the title JSCS compat: allExceptSameLine option for requireObjectKeysOnNewLine New option proposal for requireObjectKeysOnNewLine May 17, 2016
@ljharb
Copy link
Sponsor Contributor Author

ljharb commented May 17, 2016

Essentially what I want, then, is "either all on one line, or everything on its own line" - meaning, if it can't fit on one line, i never want multiples on the same line. I'm not sure what a good option name would be.

@mysticatea
Copy link
Member

I'm seeing a separate rule for line breaks inside braces: #6072

@vitorbal
Copy link
Member

True! I think it looks like it would satisfy what you want, @ljharb?

@ljharb
Copy link
Sponsor Contributor Author

ljharb commented May 18, 2016

Yes, absolutely the combination would work for me :-)

Feel free to close this in favor of #6072, otherwise I'll leave this open until the other one is closed.

@ljharb
Copy link
Sponsor Contributor Author

ljharb commented Jun 20, 2016

Seems fixed by #6223

@ljharb ljharb closed this as completed Jun 20, 2016
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 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 Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

5 participants