-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Rule Enhancement Proposal: object-property-newline with never and some options #6251
Comments
Ugh, I had gotten small trouble of labels and milestone by restoration of closed tabs. |
I like where you are headed with this. What does the I think some of the option names could be improved: Is
I believe you intended the latter, so maybe it should be |
Thank you!
Probably.
I thought those options are "conditions to need line breaks".
I'm not native. Is this strange? (but I have released
Indeed. let obj = {
[
key
]: value
}
let obj = {
key:
value
}
let obj = {
key() {
}
} |
@eslint/eslint-team Can we get more eyes on this proposal? I'm a little leery of the number of options (only in terms of, is this worth doing as multiple issues/PRs?), but that's not a huge issue. But we should really make sure we get the option names right. I'm going to offer one slightly different schema: In order to emphasize that most of the options are conditions for requiring the property newline, maybe they could be grouped in an object with a key indicating that? (I've also changed some of the other keys, but I'm not strongly attached to these names.) {
"object-property-newline": ["error", {
"requiredWhen": {
"propertyCount": 3, // Equivalent to minProperties
"longformPropertyCount": 3, // Equivalent to minLongformProperties
"hasMultilineProperty": true // Equivalent to multiline
}
}
} |
@platinumazure cool, i like your schema proposal, it reads very naturally. I was able to read it after a long time not following this issue and pretty much guess what the options would do. |
I would like to see an additional extension: Examples of correct code for this rule with the let obj = {
foo, bar, baz,
zug: 'flob',
nad: 'ban',
} Examples of incorrect code for this rule with the let obj = { //shorthand inconsistent
foo, bar,
baz,
zug: 'flob',
nad: 'ban',
}
obj = { //longform not on individual lines
foo, bar, baz, zug: 'flob', nad: 'ban',
} i think there should be a way to say that those three are OK, but i can’t think the best option: let obj = {
foo,
bar,
baz,
zug: 'flob',
nad: 'ban',
}
obj = {
foo, bar, baz,
zug: 'flob',
nad: 'ban',
}
obj = { foo, bar, baz, zug: 'flob', nad: 'ban' } |
@eslint/eslint-team Can we get some opinions to move this forward so we can start implementing? |
What about an option to ignore this on default params? I have
but still get an error on
|
I am considering contributing on this issue. I should be able to make a decision within 2 days. |
After an initial review, I propose to liquidate this issue with the following steps:
If there is any disagreement with this, please let me know. Thanks! |
Request for guidance: Further review has made it seem appropriate to add one step (step 3 below) to the plan proposed above, resulting in the following:
Is the newly inserted step 3 appropriate? |
A related discussion is at https://www.bountysource.com/issues/32238926-port-jscs-requireobjectkeysonnewline-rule. |
Are misnamed object options ever deprecated and given new names? I’m thinking of this |
@jrpool Sorry, will try to respond to your other comments soon. As to your last question, we do deprecate configuration names in favor of other ones as long as they are backwards compatible. |
Thanks, @kaicataldo. That helps. Would that mean introducing a synonymous preferred name with identical behavior? |
What about spaces between properties as well? Will the padding features be affected by this or has that not been taken into consideration? For example, rules to handle such a case: let object = {
type: Boolean,
property: {
key: 'value'
},
another: {
key: 'value'
},
key: function () {
// ...
}
} VS: let object = {
type: Boolean,
property: {
key: 'value'
},
another: {
key: 'value'
},
key: function () {
// ...
}
} |
In reply to @nijikokun, the current tests do not include cases with blank lines inside object literals, but I have added tests with such blank lines and verified that all the tests still pass. So the two examples that you provide seem to be indistinguishable, i.e. equivalent, to ESLint. |
@jrpool that is good to know, it would be cool if eslint could distinguish them so we can configure preferences for one or the other. |
Unfortunately, it looks like there wasn't enough interest from the team or community to implement this change. While we wish we'd be able to accommodate everyone's requests, we do need to prioritize. We've found that issues failing to be implemented after 90 days tend to never be implemented, and as such, we close those issues. This doesn't mean the idea isn't interesting or useful, just that it's not something the team can commit to. |
@nzakas This is a JSCS compatibility issue. Do we want to reopen and try to get this done? |
As this hasn't already been addressed, it seems like it's not very
important for JSCS compatibility, so I'd say let's keep it closed unless we
hear otherwise.
…On Fri, Sep 21, 2018 at 8:42 AM Kevin Partington ***@***.***> wrote:
@nzakas <https://github.com/nzakas> This is a JSCS compatibility issue.
Do we want to reopen and try to get this done?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6251 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AACWkgxz_-iSlhh4UR5tOrwJNvtwiRPxks5udQjygaJpZM4Imb1a>
.
--
______________________________
Nicholas C. Zakas
@SlickNet
Author, Principles of Object-Oriented JavaScript <http://amzn.to/29Pmfrm>
Author, Understanding ECMAScript 6 <http://amzn.to/29K1mIy>
|
Works for me. I was concerned about tracking this but the issue still shows up in the JSCS Compatibility project, so if someone decides to jump back to this later, they can. Happy to leave it closed. |
Rip |
From disallowObjectKeysOnNewLine.
I had forgotten to make this proposal in my previous vacation.
JSCS has disallowObjectKeysOnNewLine rule, but
object-property-newline
rule doesn't support it, so I think we need to add"always"
/"never"
and some other options intoobject-property-newline
rule. It would be similar options to #6072, #6073, and #6075. These options are "conditions to need line breaks". I like consistency, so I hope this proposal's option will be so also.There are too many options in this proposal.
In my head, those are for autofix.
(fixable) The
--fix
option on the command line automatically fixes problems reported by this rule.Options
1st option: when does it require line breaks between properties?
"always"
(default) - requires line breaks always."never"
- disallows line breaks always.multiline
(default isfalse
) - requires line breaks if there are line breaks inside of properties. If this isfalse
, this condition is disabled.minProperties
(default is0
) - requires line breaks if the number of properties is more than the given integer. If this is0
, this condition is disabled.minLongformProperties
(default is0
) - requires line breaks if the number of non-shorthand properties is more than the given integer. If this is0
, this condition is disabled. (object-property-newline
with enhanced object literals #6211)2nd option:
allowMultiplePropertiesPerLine
(default isfalse
) - allows all keys and values to be on the same line.always
Examples of incorrect code for this rule with the
"always"
option:Examples of correct code for this rule with the
"always"
option:never
Examples of incorrect code for this rule with the
"never"
option:Examples of correct code for this rule with the
"never"
option:multiline
Examples of incorrect code for this rule with the
{"multiline": true}
option:Examples of correct code for this rule with the
{"multiline": true}
option:minProperties
Examples of incorrect code for this rule with the
{"minProperties": 3}
option:Examples of correct code for this rule with the
{"minProperties": 3}
option:minLongformProperties
Examples of incorrect code for this rule with the
{"minLongformProperties": 3}
option:Examples of correct code for this rule with the
{"minLongformProperties": 3}
option:a combination of multiline and minLongformProperties
Examples of incorrect code for this rule with the
{"multiline": true, "minLongformProperties": 3}
option:Examples of correct code for this rule with the
{"multiline": true, "minLongformProperties": 3}
option:Related Rules
The text was updated successfully, but these errors were encountered: