question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Javascript ++ Operator get wrong indent

See original GitHub issue

Description

When I use ++, the next line get wrong indent. If I use += 1, or end with ; , the next line is ok.

Input

The code looked like this before beautification: before

Actual Output

The code actually looked like this after beautification: after

Environment

OS: macOS 10.13

Settings

Example:

"js": {
    "brace_style": "collapse-preserve-inline",
    "break_chained_methods": false,
    "comma_first": false,
    "e4x": false,
    "jslint_happy": false,
    "keep_array_indentation": false,
    "keep_function_indentation": false,
    "operator_position": "before-newline",
    "space_after_anon_function": false,
    "space_before_conditional": true,
    "space_in_empty_paren": false,
    "space_in_paren": false,
    "unescape_strings": false,
    "preserve_newlines": true,
    "max_preserve_newlines": 2
  }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
bitwisemancommented, Nov 1, 2017

@Gegoiuty Interesting. Here’s the minimal repro:

js

// happens
use(
  config => {
    window.store.loading++

      let extraParams = {}
  }
)

// does not happen.
use(
  config => {
    // loading
    loading++

    let extraParams = {}
  }
)

I don’t know when I’ll have time to look at this but at least we have a good repro vs non-repro example. Thanks!

0reactions
bitwisemancommented, May 4, 2018

Thanks! Create a fork, push to a branch there, and PR from there.

On Fri, May 4, 2018, 6:41 AM Oscar Walter notifications@github.com wrote:

Hello, I’v done a commit to resolve this issue (handled python and node changes), all the test pass (python and js). However I dont have the rights to push a new branch and create à PR.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/beautify-web/js-beautify/issues/1283#issuecomment-386604905, or mute the thread https://github.com/notifications/unsubscribe-auth/AB3kKc4ccX0ZVPB0WNl0gwbujerxzBTeks5tvFqcgaJpZM4QKVNL .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incorrect indentation on ternary operator with object literal #4203
I have made a demo similar to the original one to demonstrate the ternary formatting with tabs, which I think could use some...
Read more >
Emacs problematic JavaScript indentation - Stack Overflow
When I have parenthesis, and I have to break the expression, Emacs indent like this: this.offices.each(this.addOfficesToMap, this);.
Read more >
JS: Indentation and Spacing | CSE 154 Unofficial Style Guide
In JavaScript, each nested statement (e.g., a statement following a "{" brace) should be indented exactly once more than the previous line's indentation....
Read more >
Wrong formatting with "indent chained methods" enabled and ...
Wrong formatting with "indent chained methods" enabled and operators · Turn on "indent chained methods" in Editor > Code style > JavaScript >...
Read more >
indent - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found