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

Add allowLineSeparatedGroups option to sort-keys rule #12759

Closed
nicogreenarry opened this issue Jan 8, 2020 · 9 comments · Fixed by #16138
Closed

Add allowLineSeparatedGroups option to sort-keys rule #12759

nicogreenarry opened this issue Jan 8, 2020 · 9 comments · Fixed by #16138
Assignees
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 enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects

Comments

@nicogreenarry
Copy link

nicogreenarry commented Jan 8, 2020

What rule do you want to change?
sort-keys

Does this change cause the rule to produce more or fewer warnings?
No changes, if the allowLineSeparatedGroups parameter is false or omitted, or fewer warnings if it is true.

How will the change be implemented? (New option, new default behavior, etc.)?
Add a new allowLineSeparatedGroups option, following the pattern of the tslint's object-literal-sort-keys rule.

Please provide some example code that this change will affect:

const person = {
  firstName: 'Nico',
  lastName: 'Greenarry',

  hobbies: ['cats', 'dodgeball', 'potlucks'],
};

What does the rule currently do for this code?

ESLint: Expected object keys to be in ascending order. 'hobbies' should be before 'lastName'. (sort-keys)

What will the rule do after it's changed?
If the allowLineSeparatedGroups option is true, then there would be no eslint exception.

Are you willing to submit a pull request to implement this change?
Yes. I haven't looked at the eslint codebase before, so I expect there to be a learning curve, but I'm willing to figure out how to implement it properly.

@nicogreenarry nicogreenarry added enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules triage An ESLint team member will look at this issue soon labels Jan 8, 2020
@nicogreenarry
Copy link
Author

I see that this option is specifically mentioned in the TSLint Migration Guide.
sort-lines in roadmap

If this functionality will be completed in due time, then feel free to close this issue. But if it hasn't yet been decided whether to add this option, then consider this my petition to add it!

@mdjermanovic mdjermanovic added 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 Jan 8, 2020
@mdjermanovic
Copy link
Member

I support this proposal 👍

It hasn't been decided yet. I think this is the same as #12275 which didn't reach consensus at the time so the issue was closed, but maybe it will be different this time.

This looks to me like a reasonable enhancement, useful to allow for grouping different kinds of properties (which isn't supported by this rule), e.g.:

/*eslint sort-keys: "error"*/

const obj = {
  a: 1,
  b: 2, 
  c: 3,
  
  bar() {}, // error: 'bar' should be before 'c'
  foo() {}
}

@kaicataldo
Copy link
Member

I support this, though I'm not convinced about the ignore-blank-lines option name. To me, it currently is ignoring blank lines, and this option would make it account for them. Would an option called groups be clear enough? Or lineSeparatedGroups?

@nicogreenarry
Copy link
Author

I see your point about the name. If there isn't a convention (explicit or otherwise) against long-ish option names, I'd prefer something like lineSeparatedGroups or allowLineSeparatedGroups for clarity.

@g-plane
Copy link
Member

g-plane commented Jan 10, 2020

Do we need a champion for this change?

@kaicataldo
Copy link
Member

@nicogreenarry In recent times I think we've trended towards longer, more explicit option names :) Do you mind updating the proposal with allowLineSeparatedGroups?

@g-plane I'll champion. We just need one more supporter.

@kaicataldo kaicataldo self-assigned this Jan 10, 2020
@nicogreenarry nicogreenarry changed the title Add ignore-blank-lines option to sort-keys rule Add allowLineSeparatedGroups option to sort-keys rule Jan 11, 2020
@nicogreenarry nicogreenarry changed the title Add allowLineSeparatedGroups option to sort-keys rule Add allowLineSeparatedGroups option to sort-keys rule Jan 11, 2020
@anikethsaha anikethsaha added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Aug 5, 2020
@anikethsaha
Copy link
Member

Marked this as accepted as this has a champion and supporters.

@JJoGeon
Copy link

JJoGeon commented Aug 6, 2020

Agree with the proposal too.
@nicogreenarry If you don't mind, can I work on this issue?
I'm new here and I'm looking for something to contribute. 😄

@nicogreenarry
Copy link
Author

@JJoGeon yes, by all means!

@nzakas nzakas added this to Needs Triage in Triage via automation Mar 25, 2021
@nzakas nzakas moved this from Needs Triage to RFC Opened in Triage Mar 25, 2021
@mdjermanovic mdjermanovic moved this from RFC Opened to Pull Request Opened in Triage Apr 2, 2021
@snitin315 snitin315 assigned snitin315 and unassigned kaicataldo Jul 17, 2022
Triage automation moved this from Pull Request Opened to Complete Jul 30, 2022
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Jan 27, 2023
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jan 27, 2023
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 enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
Archived in project
Triage
Complete
7 participants