Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upDocumentation conflicts with object-property-newline setting? #2007
Comments
|
The guideline is, if the entire construct can fit on one line, it should be on one line; if not, each item should be on its own line. In other words, for any of |
|
Actually, after rereading the ESLint documentation, it looks like I misunderstood the So it looks like ESLint doesn't have the configuration available to make the following happen: // correct
const obj = { foo: "foo", bar: "bar", baz: "baz" };
// correct
const obj2 = {
foo: "foo",
bar: "bar",
baz: "baz"
};
// incorrect, but ESLint allows it with `allowAllPropertiesOnSameLine` set to true
const obj3 = {
foo: "foo", bar: "bar", baz: "baz"
};According to what I thought the Airbnb style guide promoted (and what I believe you're confirming) is that But unfortunately we can't currently force the error to be picked up by ESLint (not without having |
|
Is there not a different rule that complains about that one? If not, then we should propose one to eslint :-) |
|
It looks like I'll go ahead and submit feature requests for all of the above when I have the time to work on the pull request for the implementation of those rules. |
|
you mean feature request like this? |
It seems like the documentation consistently promotes having a new line for each item in multiline lists, whether it be in a function invocation or in an array (both of which mention bad examples of not having each item on a new line).
And even the object examples (although not referring to this specific rule) seem to favor this approach.
With that said, what is the reasoning behind allowing object properties to all appear on the same line?
It would seem more consistent to remove that option for
object-property-newline. But at the very least, the reasoning and/or use case should probably be documented.