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

Support reserved words as property names #71

Closed
StevenACoffman opened this issue Aug 24, 2014 · 18 comments
Closed

Support reserved words as property names #71

StevenACoffman opened this issue Aug 24, 2014 · 18 comments
Assignees

Comments

@StevenACoffman
Copy link

I'm using Q and some of its methods are reserved words, like catch and finally.

In Q for example you can write:

Q($.ajax(...))
  .catch(function (response) {
    console.error(response);
  });

But this is formatted by atom-beautifier in:

Q($.ajax(...))
  .
catch (function (response) {
  console.error(response);
});

Because catch is interpreted as a keyword.

Is there a way to format this code properly without using the square bracket notation (i.e. Q($.ajax(...))'catch')?

This issue appears to have been resolved in js beautify:
beautifier/js-beautify#439

I'm not sure if atom-beautifier uses the same implementation.
Thanks!

@Glavin001 Glavin001 added the bug label Aug 25, 2014
@Glavin001 Glavin001 self-assigned this Aug 25, 2014
@Glavin001
Copy link
Owner

Thank you for making this issue and doing your research and finding that js-beautify issue.
Atom Beautify uses js-beautify for JavaScript, so this is surprising that the bug fix you linked to above did not apply. I will look into this when I can and get back to you.

@Glavin001
Copy link
Owner

@StevenACoffman I am unable to reproduce this issue. Could you please try again with the latest Atom Beautify package, v0.6.5? Thanks.

@Glavin001
Copy link
Owner

Let me know if this is still an issue and how you can reproduce it -- what is your configured options, etc -- and I can reopen this issue.

@StevenACoffman
Copy link
Author

I am using Atom 0.125.0 with Atom-Beautify 0.2.4.

This code below is an example of the problem behavior:

var Promise = require('bluebird');
function synchronousPromise() {
  Promise.resolve(console.log('hello'))
    .then(console.log('how are you'))
    .then(console.log('goodbye'))
    .catch(console.log('error occurred'));
}

The beautifier will reformat the .catch as:

var Promise = require('bluebird');
function synchronousPromise() {
  Promise.resolve(console.log('hello'))
    .then(console.log('how are you'))
    .then(console.log('goodbye'))
    .
  catch (console.log('error'));
}

This does not happen when I got to jsbeautifier.org and paste in the code there.

@Glavin001
Copy link
Owner

We are currently at version 0.7.0. Could you please update first?

@Glavin001
Copy link
Owner

On an unrelated note, I would like to refer you to the GitHub Flavoured Markdown cheat-sheet, where you can learn about how to make your comments easier to read with markdown styling: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet

Specifically the section for Code blocks: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code

😃

@StevenACoffman
Copy link
Author

In atom, when I went to preferences -> packages, Atom-Beautify did not show up as having available updates. This may be another problem.
I needed to uninstall the package, restart Atom, and then install it again. After having installed

Uncaught TypeError: Cannot read property of 'messagePanel' of undefined.
/Users/gears/.atom/packages/atom-beautify/lib/beautify.coffee:164

@Glavin001
Copy link
Owner

Thank you. On it right now.

@Glavin001
Copy link
Owner

I have unlinked my development directory and installed the latest Atom Beautify and am beautifying without any such issues.
Could you try to reload Atom Beautify again? Possibly check the version number (just so I have that recored here). Hopefully we can get this resolved for you quickly.

@StevenACoffman
Copy link
Author

Atom Beautify 0.7.0
Analytics userID: 23d4c686-6cc4-47c2-80ee-a596dbed4987

I restarted Atom (does that count as reloading Atom Beautify?).

When I turned both "Beautify on Save" and "Beautify Entire File On Save" off, I don't get the error even when I manually Beutify. When I turn them both on, I do get the error on Save.

@StevenACoffman
Copy link
Author

Thanks for helping. When I have "Beautify On Save" off, but "Beautify Entire File On Save" on, and save the file, I do not get the error when I save the file.

@StevenACoffman
Copy link
Author

This is my root directory .jsbeautifyrc

{
  "html": {
    "brace_style": "collapse",
    "indent_char": " ",
    "indent_scripts": "normal",
    "indent_size": 6,
    "max_preserve_newlines": 1,
    "preserve_newlines": true,
    "unformatted": ["a", "sub", "sup", "b", "i", "u"],
    "wrap_line_length": 0
  },
  "css": {
    "indent_char": " ",
    "indent_size": 4
  },
  "js": {
    "indent_with_tabs": false,
    "preserve_newlines": true,
    "max_preserve_newlines": 4,
    "jslint_happy": true,
    "brace_style": "collapse",
    "keep_array_indentation": false,
    "keep_function_indentation": false,
    "space_in_paren": false,
    "break_chained_methods": false,
    "eval_code": false,
    "unescape_strings": false,
    "e4x": false,
    "wrap_line_length": 120,
    "indent_size": 2,
    "indent_char": " ",
    "indent_level": 0
  },
  "sql": {
    "indent_size": 4,
    "indent_char": " ",
    "indent_level": 0,
    "indent_with_tabs": false
  }
}

@Glavin001
Copy link
Owner

Thanks! That is why I do not receive that error. I do not have Beautify when saved enabled.

@StevenACoffman
Copy link
Author

Thank you for bearing with me. Should I pursue the fact that Atom did not mark package Atom-Beautify 0.2.4 as having available updates, or is that an old and resolved issue? Other packages had been marked as having available updates, and I had successfully updated them on a weekly basis.

@Glavin001
Copy link
Owner

The lack of update notification may be an issue with apm renaming package, however I am not really sure of the implementation and if that could be the case. Atom Beautify was migrated (probably around v0.2.4) from the original creator to myself as the current maintainer.


I had to drive from work to school. Now I am back on the case! I have found where the issue is and am working on a patch.

@Glavin001
Copy link
Owner

@StevenACoffman I have patched #81. Please update to v0.7.1 and let's continue with this issue :).

@StevenACoffman
Copy link
Author

I can confirm both this that it is fixed and that you are my hero. Thanks for being so supportive and running all this stuff down.

@Glavin001
Copy link
Owner

Excellent! You're very welcome. I am glad to hear everything is working as expected. Let me know if you have any further questions or problems.

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

No branches or pull requests

2 participants