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

@brodybits brodybits commented Jan 1, 2021

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 label Jan 1, 2021
@eslint-deprecated
Copy link

eslint-deprecated bot commented Jan 1, 2021

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

eslint-deprecated bot commented Jan 29, 2021

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

eslint-deprecated bot commented Jan 29, 2021

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 Jan 29, 2021
@brodybits
Copy link
Contributor Author

brodybits commented Jan 29, 2021

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

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
13 checks passed
@brodybits brodybits deleted the fix-indenting-of-offset-ternary-expressions branch Jan 30, 2021
@brodybits
Copy link
Contributor Author

brodybits commented Jan 30, 2021

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 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 triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants