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

Reserved words used as property/function/variable identifiers are formatted incorrectly #368

Closed
jdavisclark opened this issue Dec 10, 2013 · 2 comments · Fixed by #439
Closed

Comments

@jdavisclark
Copy link

From jdavisclark/JsFormat#89 :

If have the following code:

Handlebars.default.compile("hello world");

The formatted results is:

Handlebars.
default.compile("hello");

Regardless of how I feel about using keywords as property names, even if it usually works, some APIs do force you in to it, and not everyone likes getting around it with Handlebars["default"].compile(...)

Is this possible or is it one of those instances where it isn't going to happen since the source isn't really getting completely parsed? Somehow I'm still not really familiar with the jsbeautifier codebase...

@bitwiseman
Copy link
Member

Same as #309, #351, but this is a solid description of it. All of these are made more difficult to fix by #200, but not impossible.

@jdavisclark
Copy link
Author

@bitwiseman huh...looks like github remembers your last filter state of the issues view page/list and reapplys it when you come back... I was filtered to issues tagged as "discussion" and didn't notice it, so I missed 309 & 351. Sorry about that.

Was worried it might be a limitation due to #200. Thanks

bitwiseman added a commit to bitwiseman/js-beautify that referenced this issue Mar 28, 2014
This supports calling libraries which declare properties of objects using reserved words.
This does not support declaring these fields.

`var a = { 'throw': function() {} }` - works
`a.throw()` - works
`var a = { throw: function() {} }` - does not work

Fixes beautifier#309
Fixes beautifier#351
Fixes beautifier#368
Fixes beautifier#378
ledsun added a commit to ledsun/jsformat-atom that referenced this issue Jun 23, 2014
Because 'catch' formatting incorrectly for function of name 'catch'.
And it is fixed in beautifier/js-beautify#368 .
ledsun added a commit to ledsun/jsformat-atom that referenced this issue Jun 23, 2014
Because 'catch' formatting incorrectly for function of name 'catch'.
And it is fixed in beautifier/js-beautify#368 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants