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

function-call-argument-newline work when function goes across multiple lines #12794

Closed
mitchellwarr opened this issue Jan 16, 2020 · 4 comments
Closed
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue 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

@mitchellwarr
Copy link

What rule do you want to change?
function-call-argument-newline

Does this change cause the rule to produce more or fewer warnings?
more

How will the change be implemented? (New option, new default behavior, etc.)?
new option

Please provide some example code that this change will affect:

foo("one", "two", "three");
// or
foo(
   "one", 
   "two",
   "three"
);
// not
foo("one", "two",
  "three");

bar("one", "two", { one: 1, two: 2 });
// or
bar(
  "one",
  "two",
  {
     one: 1,
     two: 2
  }
);
// not
bar("one", "two", {
    one: 1,
    two: 2
});

baz(
  "one",
  "two",
   (x) => {
      console.log(x);
   }
);
// not
baz("one", "two", (x) => {
    console.log(x);
});

What does the rule currently do for this code?
Currently this rule will require a newline for arguments "always", "never", or "consistent" which means either all args are on a newline or all are on the same line.

What will the rule do after it's changed?
With a multi line rule, it should look if the parentheses are on different lines. Currently this is valid:

baz("one", "two", (x) => {
    console.log(x);
});

because it sees it as all being on one line (i suspect) but there should be a way to say that "no, these should each have their own line"

Are you willing to submit a pull request to implement this change?
I dont really understand how eslint works and I dont have a lot of time. Maybe if I get time.

@mitchellwarr mitchellwarr 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 16, 2020
@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 16, 2020
@kaicataldo
Copy link
Member

It sounds like you're looking for an option like array-bracket-newline's multiline option. From the docs (emphasis my own):

"multiline": true (default) requires line breaks if there are line breaks inside elements or between elements. If this is false, this condition is disabled.

This seems like a reasonable addition to me! I've put my 👍 of support.

@mdjermanovic
Copy link
Member

Hi @mitchellwarr, thanks for the issue!

I think this is a generally reasonable proposal, but there are some details that probably need discussion.

In particular, this is different from how "multiline" options work in some similar rules, like in the array-element-newline rule (I believe that's the most similar rule). There, the condition doesn't depend on [] brackets, but on the multiline elements (linebreaks inside elements, not between elements). Also, this proposal allows multiple valid choices for the same code.

It would be nice (although not necessary) to have equivalent options in similar rules. On the other hand, this proposal as it is now might make more sense than the existing options in other rules.

@kaicataldo
Copy link
Member

Sorry, I should have been clearer. I'm generally in support of adding an option like this, but do agree with @mdjermanovic that we should try to align the API with existing rules for consistency.

@eslint-deprecated eslint-deprecated bot added the auto closed The bot closed this issue label Feb 16, 2020
@eslint-deprecated
Copy link

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 reach accepted status after 21 days tend to
never be accepted, 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.

Thanks for contributing to ESLint and we appreciate your understanding.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Aug 16, 2020
@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 Aug 16, 2020
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 auto closed The bot closed this issue 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

3 participants