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

Fix: nested indenting for offsetTernaryExpressions: true (fixes #13971) #13972

Merged

Conversation

brodybits
Copy link
Contributor

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[x] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

resolves #13971

This update applies one more condition for the consequent to avoid extra indenting in a nested ternary expression like this:

condition1
  ? condition2
    ? Promise.resolve(1)
    : Promise.resolve(2)
  : Promise.resolve(3)

Note that the condition was mostly copied from the condition that @sheerun had included for the alternate in PR #12556 (bb6cf50).

Is there anything you'd like reviewers to focus on?

I hope there is enough information in issue #13971 to explain the issue and in this PR to understand the solution. I would be happy to add some more test cases and documentation updates if needed.

This PR can help unblock the following issues and updates in some other projects:

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Jan 1, 2021
@eslint-deprecated
Copy link

Hi @brodybits!, thanks for the Pull Request

The pull request title isn't properly formatted. We ask that you update the message to match this format, as we use it to generate changelogs and automate releases.

  • The commit message tag must be one of the following:

    The Tag is one of the following:

    • Fix - for a bug fix.
    • Update - either for a backwards-compatible enhancement or for a rule change that adds reported problems.
    • New - implements a new feature.
    • Breaking - for a backwards-incompatible enhancement or feature.
    • Docs - changes to documentation only.
    • Build - changes to build process only.
    • Upgrade - for a dependency upgrade.
    • Chore - for anything that isn't user-facing (for example, refactoring, adding tests, etc.).

    You can use the labels of the issue you are working on to determine the best tag.

  • There should be a space following the initial tag and colon, for example 'New: Message'.

  • The first letter of the tag should be in uppercase

Read more about contributing to ESLint here

@brodybits brodybits changed the title resolve extra indenting with offsetTernaryExpressions: true Fix: resolve extra indenting with offsetTernaryExpressions: true Jan 1, 2021
@sheerun
Copy link
Contributor

sheerun commented Jan 1, 2021

looks good :)

@nzakas nzakas changed the title Fix: resolve extra indenting with offsetTernaryExpressions: true Fix: resolve extra indenting with offsetTernaryExpressions: true (fixes #13971) Jan 29, 2021
@eslint-deprecated
Copy link

Hi @brodybits!, thanks for the Pull Request

The pull request title isn't properly formatted. We ask that you update the message to match this format, as we use it to generate changelogs and automate releases.

  • The length of the commit message must be less than or equal to 72

Read more about contributing to ESLint here

1 similar comment
@eslint-deprecated
Copy link

Hi @brodybits!, thanks for the Pull Request

The pull request title isn't properly formatted. We ask that you update the message to match this format, as we use it to generate changelogs and automate releases.

  • The length of the commit message must be less than or equal to 72

Read more about contributing to ESLint here

@brodybits brodybits changed the title Fix: resolve extra indenting with offsetTernaryExpressions: true (fixes #13971) Fix: nested indenting for offsetTernaryExpressions: true (fixes #13971) Jan 29, 2021
Co-authored-by: Adam Stankiewicz <sheerun@sher.pl>
@brodybits brodybits force-pushed the fix-indenting-of-offset-ternary-expressions branch from 02e0133 to 8ed37bb Compare January 29, 2021 19:41
@brodybits
Copy link
Contributor Author

I have rebased and updated the title again to fit within the 72 characters, hope it is good to go. I will not likely be active on GitHub for the next 25-30 hours. Thanks!

Copy link
Member

@btmills btmills left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @brodybits! Glad to see this could be fixed with a single condition.

@btmills btmills merged commit e1da90f into eslint:master Jan 30, 2021
@brodybits brodybits deleted the fix-indenting-of-offset-ternary-expressions branch January 30, 2021 22:47
@brodybits
Copy link
Contributor Author

Much appreciated, this will unblock issues on "Standard JS" and prettier-standard.

This was referenced Mar 17, 2021
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Jul 30, 2021
@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 Jul 30, 2021
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 triage An ESLint team member will look at this issue soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extra indenting in a nested ternary with offsetTernaryExpressions: true from Standard JS config
3 participants