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

Invalid JavaScript syntax: Unexpected end of file #606

Closed
inane opened this issue Feb 22, 2015 · 13 comments
Closed

Invalid JavaScript syntax: Unexpected end of file #606

inane opened this issue Feb 22, 2015 · 13 comments

Comments

@inane
Copy link

inane commented Feb 22, 2015

Hi!! Awesome JSDuck, very useful for my daily work.. great!

I have a issue with a javascript code, in a Sencha-touch view I have different lines with comments inside this component, here an example:

       {
                            xtype: 'selectfield',
                            itemId: 'headerOrderType',
                            name: 'ordertype',
                            label: x.Text.getText("SC_H_ORDER_TYPE_LABEL"),
                            displayField: 'ordertypetext',
                            valueField: 'ordertype',
                            // dynamically by cart controller
            options: [],
                            required: true,
                            hidden: false
         },

If I delete the line-comment works properly, Why?? I think this is a bug, if we add comments inside view components, jsduck is not working..

Thank you in advance ..

@nene
Copy link
Member

nene commented Feb 23, 2015

Hi @inane, thanks for reporting. Unfortunately I'm unable to reproduce this bug.

Please post a complete code example that causes the problem.

Also, naming the version of JSDuck might help.

@inane
Copy link
Author

inane commented Feb 23, 2015

Hi @nene it´s simple, if you add a line comment inside of a component, jsduck crash.

I am running JsDuck in Mac osX 10.10 with the latest version.

Thanks!

@nene
Copy link
Member

nene commented Feb 23, 2015

Please provide an example of such a component. It's not as obvious to me as it might seem to you.

@inane
Copy link
Author

inane commented Feb 23, 2015

Hello @nene here it goes the class.. if you look inside items you have line comment, and for me it is not working, I have deleted these lines in my code and it worked..

Ext.define('x.view.cart.Header', {
extend: 'Ext.form.Panel',
xtype: 'cartHeader',
requires: [
'Ext.TitleBar',
'Ext.field.Search',
'Ext.Label',
'Ext.form.FieldSet',
'Ext.field.Radio',
'x.view.components.PartnerSuggest',
'x.view.components.Datepicker'
],

config: {
    items: [
        {
            xtype: 'titlebar',
            docked: 'top',
            title: x.Text.getText('SC_H_TITLE'),
            items: [
                {
                    xtype: 'button',
                    itemId: 'headerContinueToItem',
                    text: x.Text.getText("SC_H_CONTINUE_TO_ITEMS_BTN"),
                    ui: 'confirm',
                    disabled: false
                }
            ]
        },
        {
            layout: 'hbox',
            items: [
                {
                    flex: 1,
                    xtype: 'fieldset',
                    itemId: 'headerInformations',
                    title: x.Text.getText("SC_H_HEADER_TITLE"),
                    defaults: {
                        labelWidth: '40%'
                    },
                    items: [
                        {
                            xtype: 'searchfield',
                            itemId: 'headerPartnerField',
                            name: 'partnerId',
                            label: x.Text.getText("SC_H_PARTNER_LABEL"),
                            placeHolder: x.Text.getText('PARTNER_SUGGEST_PLACE_HOLDER'),
                            required: true,
                            hidden: false
                        },
                        {
                            xtype: 'selectfield',
                            itemId: 'headerSalesArea',
                            name: 'salesarea',
                            displayField: 'salesarea',
                            valueField: 'salesarea',
                            label: x.Text.getText("SC_H_SALES_AREA_LABEL"),
                            required: true,
                            hidden: false,
                            options: []
                        },
                        {
                            xtype: 'selectfield',
                            itemId: 'headerOrderType',
                            name: 'ordertype',
                            label: x.Text.getText("SC_H_ORDER_TYPE_LABEL"),
                            displayField: 'ordertypetext',
                            valueField: 'ordertype',
                            // dynamically by cart controller
                            options: [],
                            required: true,
                            hidden: false
                        },
                        {
                            xtype: 'datepicker',
                            itemId: 'headerRDD',
                            name: 'rdd',
                            label: x.Text.getText("SC_H_RDD_LABEL"),
                            required: true,
                            hidden: true
                            //value: new Date() //It will be disabled after setRDDConfigs implementation
                        },
                        {
                            xtype: 'togglefield',
                            itemId: 'headerCompleteDelivery',
                            name: 'completeDelivery',
                            label: x.Text.getText("SC_H_COMPLETE_DELIVERY_LABEL"),
                            hidden: true
                        },
                        {
                            xtype: 'togglefield',
                            itemId: 'headerInvoiceReview',
                            name: 'invoiceReview',
                            label: x.Text.getText("SC_H_INVOICE_REVIEW_LABEL"),
                            hidden: true
                        },
                        {
                            xtype: 'togglefield',
                            itemId: 'headerCombineOrder',
                            name: 'combineOrder',
                            label: x.Text.getText("SC_H_COMBINE_ORDER_LABEL"),
                            hidden: true
                        },
                        {
                            xtype: 'textfield',
                            itemId: 'headerPoNr',
                            name: 'poNr',
                            label: x.Text.getText("SC_H_PO_NR_LABEL"),
                            hidden: true
                        },
                        {
                            xtype: 'selectfield',
                            itemId: 'customerGroup4',
                            name: 'customerGroup4',
                            label: x.Text.getText("SC_H_CUSTOMER_GROUP_4"),
                            hidden: true
                        },
                        {
                            xtype: 'selectfield',
                            itemId: 'customerGroup5',
                            name: 'customerGroup5',
                            label: x.Text.getText("SC_H_CUSTOMER_GROUP_5"),
                            hidden: true
                        },
                        {
                            xtype: 'textfield',
                            itemId: 'headerOrderText',
                            name: 'orderText',
                            label: x.Text.getText("SC_H_ORDER_TEXT_LABEL"),
                            hidden: true
                        },
                        {
                            xtype: 'textfield',
                            itemId: 'headerDeliveryText',
                            name: 'deliveryText',
                            label: x.Text.getText("SC_H_DEVLIVERY_TEXT_LABEL"),
                            hidden: true
                        },
                        {
                            xtype: 'textfield',
                            itemId: 'headerInternalText',
                            name: 'internalText',
                            label: x.Text.getText("SC_H_INTERNAL_TEXT_LABEL"),
                            hidden: true
                        },
                        {
                            xtype: 'textfield',
                            itemId: 'headerAgentText',
                            name: 'agentText',
                            label: x.Text.getText("SC_H_TEXT_AGENT_LABEL"),
                            hidden: true
                        },
                        {
                            xtype: 'selectfield',
                            itemId: 'headerValutaDays',
                            name: 'valutaDays',
                            label: x.Text.getText("SC_H_VALUTADAYS_LABEL"),
                            hidden: true,
                            options: []
                        }
                    ]
                },
                {
                    flex: 1,
                    layout: 'vbox',
                    items: [
                        {
                            xtype: 'fieldset',
                            title: x.Text.getText("SC_H_SHIPTOPARTIES_TITLE"),
                            itemId: 'shiptoparties',
                            defaults: {
                                labelWidth: '40%'
                            },
                            items: [
                                //  switch Button changes between the two sub items
                                {
                                    xtype: 'togglefield',
                                    itemId: 'shipManually',
                                    name: 'shipManually',
                                    label: x.Text.getText("SC_H_SHIP_MANUALLY_LABEL"),
                                    hidden: true
                                },
                                // only one of the following is visible at a time
                                {
                                    xtype: 'container',
                                    itemId: 'shipToPartiesOptions',
                                    defaults: {
                                        xtype: 'radiofield',
                                        name: 'shipToPartyAddress',
                                        labelAlign: 'right',
                                        labelWidth: '90%'
                                    },
                                    items: [
                                        // dynamic child's by salesarea selection
                                    ]
                                },
                                {
                                    xtype: 'container',
                                    itemId: 'shipToPartiesManually',
                                    hidden: true,
                                    defaults: {
                                        xtype: 'textfield',
                                        labelWidth: '40%',
                                        hidden: true
                                    },
                                    items: [
                                        // Form fields
                                        {
                                            itemId: 'shipManuallyName1',
                                            name: 'name',
                                            label: x.Text.getText("SC_H_SHIP_MANUALLY_NAME1_LBL")
                                        },
                                        {
                                            itemId: 'shipManuallyName2',
                                            name: 'name2',
                                            label: x.Text.getText("SC_H_SHIP_MANUALLY_NAME2_LBL")
                                        },
                                        {
                                            itemId: 'shipManuallyStreet',
                                            name: 'street',
                                            label: x.Text.getText("SC_H_SHIP_MANUALLY_STR_LBL")
                                        },
                                        {
                                            itemId: 'shipManuallyPostCode',
                                            name: 'postcode',
                                            label: x.Text.getText("SC_H_SHIP_MANUALLY_PCODE_LBL")
                                        },
                                        {
                                            itemId: 'shipManuallyCity',
                                            name: 'city',
                                            label: x.Text.getText("SC_H_SHIP_MANUALLY_CITY_LBL")
                                        },
                                        {
                                            xtype: 'selectfield',
                                            itemId: 'shipManuallyCountry',
                                            name: 'country',
                                            label: x.Text.getText("SC_H_SHIP_MANUALLY_LAND_LBL")
                                        },
                                        {
                                            xtype: 'selectfield',
                                            itemId: 'shipManuallyRegion',
                                            name: 'region',
                                            label: x.Text.getText("SC_H_SHIP_MANUALLY_REG_LBL")
                                        },

                                        {
                                            itemId: 'shipManuallyPhone',
                                            name: 'phone',
                                            label: x.Text.getText("SC_H_SHIP_MANUALLY_PHONE_LBL")
                                        },
                                        {
                                            itemId: 'shipManuallyFax',
                                            name: 'fax',
                                            label: x.Text.getText("SC_H_SHIP_MANUALLY_FAX_LBL")
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}

});

@inane inane closed this as completed Feb 23, 2015
@nene
Copy link
Member

nene commented Feb 23, 2015

Problem solved?

@inane
Copy link
Author

inane commented Feb 23, 2015

Yes @nene for me it is solved but I think this is a jsduck bug, now I have commented my previous line-comment for /* comment */ instead of //comment and its working as well.. Only for your information.

Thanks for your support.

Óscar.

@nene
Copy link
Member

nene commented Feb 23, 2015

I tried parsing the given file with both JSDuck 5.3.4 and 6.0 beta. No errors in either case.

This file contains no doc-comments, so JSDuck won't output anything. Added some doc comments, but also no failure.

@inane
Copy link
Author

inane commented Feb 23, 2015

Tricky situation, I have tested with Windows and doesnt´work, same error.. Don´t care I have commented with this format /* comment */ and it works, and solved!

Thank you.

@garie
Copy link

garie commented Oct 19, 2015

I had this same problem with 3 of the ~40 files in my project. I found that if I replaced all carriage returns (\r) with newlines (\n), the problem no longer occurred. I think jsduck is not seeing carriage returns as a new line so the following could occur:

function asdf() {\n
    // some comment\r
}\n

which JSDuck is translating to:

function asdf() {
    // some comment }

which leads to the unexpected EOF error.

@garie
Copy link

garie commented Oct 19, 2015

@nene Maybe this issue should be reopened? I think either JSDuck should treat carriage returns as newlines or it should give a warning that makes the issue easier to diagnose.

@nene
Copy link
Member

nene commented Oct 20, 2015

Hi @garie, this certainly looks like a bug, but it's a different issue - \r not being treated as a newline.

Would you mind opening a separate issue for this?

PS. What's your reason for having lonely \r chars in the first place? I suppose you're not using old Mac OS. Mess created by editor? Generated code?

@garie
Copy link

garie commented Oct 21, 2015

I commented here because I suspect that @inane had the same issue but didn't realize. I will try to open a separate issue.

I am not positive how the \r chars got there but I suspect it is due to Visual Studio - if you have a mixture of different newline chars (usually from editing on both windows and mac, which we do quite often), it will ask if it should normalize them and give several options. One of those options is "Macintosh (CR)". It looks like we really wanted "Unix (LF)" but since we are using macs someone got it wrong.

@garie
Copy link

garie commented Oct 21, 2015

I opened a new issue.

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