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

Update prettifier library to 1.8.x #646

Closed
stan-p opened this issue Oct 16, 2018 · 4 comments
Closed

Update prettifier library to 1.8.x #646

stan-p opened this issue Oct 16, 2018 · 4 comments

Comments

@stan-p
Copy link

stan-p commented Oct 16, 2018

Everything worked fine before (for the same project, same code), but since one of the recent updates some incorrect indentation happens in certain JavaScript files when this package is run to prettify.

I did some testing, and it appears to me that the problem occurs when async/await syntax is used for object methods, and it affects every such method of the object (except the last one), resulting in duplicated indent at the beginning of each method (e.g. 4 spaces instead of 2). Every such misalignment propagates through the rest of the object properties, creating cumulative effect. Only exception from the pattern, as already mentioned, is when such method is the last property of the object - indentation is correct then.

Example for code w/o async/await syntax (all ok):

module.exports = {
  first: function() {
    doSomethingSync();
    doSomethingElseSync();
  },
  second: function() {
    doSomethingCompletelyDifferentSync();
  },
  third: function() {
    doSomethingUnexpectedSync();
  },
};

Example for similar code w/ async/await syntax (issue):

module.exports = {
  first: async function() {
      await doSomething();
      await doSomethingElse();
    },
    second: async function() {
        await doSomethingCompletelyDifferent();
      },
      third: async function() {
        await doSomethingUnexpected(); // No issue for the last property
      },
};
@victorporof
Copy link
Owner

Please file this issue at https://github.com/beautify-web/js-beautify

@stan-p
Copy link
Author

stan-p commented Oct 16, 2018

Thanks. I see it was already reported here - fixed 4 days ago.

@victorporof victorporof changed the title Incorrect indentation in a specific case (JS) Update prettifier library to 1.8.x Oct 17, 2018
@victorporof victorporof reopened this Oct 17, 2018
@bitwiseman
Copy link
Contributor

@PStanislav @victorporof
This fix is have been release in v1.8.8.

@victorporof
Copy link
Owner

Fixed db59fb5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants