1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    15
    Vote Rating
    1
    m.sudharsanreddy is on a distinguished road

      0  

    Default Avoid trailing comma in array and object literals code review.

    Avoid trailing comma in array and object literals code review.


    Hi All,
    I am analyzing JavaScript code quality in Sonar.
    Its reporting "Avoid trailing comma in array and object literals." in the below code, which is highlighted in red color .

    Ext.apply(Ext.form.VTypes, { usPhone: function(v) { return /^\d{3}-\d{3}-\d{4}$/.test(v); }, usPhoneText: 'Please enter a US Phone number in the format 999-999-9999', usPhoneMask: /[\d\s\(\)\-]/i });

    Ext.define('AddressState', { extend: 'Ext.data.Model', fields: [ {type: 'string', name: 'abbr'}, {type: 'string', name: 'name'}, {type: 'string', name: 'slogan'} ] });

    If I remove highleted in Red comma Ext js will not accept.
    How to fix this issue. Please help me on this... we have 40 blockers all issues are same.

    Thanks in Advance...

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,000
    Vote Rating
    650
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    It's not wrong because the alternative is not valid syntax. Define is a method, the class name is the first parameter, the class definition is the second:

    Code:
    myFoo('name', {
        foo: 'bar'
    });
    You can't pass arguments like this because it's a syntax error:

    Code:
    myFoo('name' {
        foo: 'bar'
    });
    The tool you're using is bogus.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User
    Join Date
    Aug 2012
    Posts
    15
    Vote Rating
    1
    m.sudharsanreddy is on a distinguished road

      0  

    Default


    Hi Evant,

    Thanks for your response..

    I am using JavaScript plugin in Sonar.

    Is there any best plugin to check javascript code as per the coding standard.

    Thanks

  4. #4
    Ext JS Premium Member westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    928
    Vote Rating
    48
    westy is a jewel in the rough westy is a jewel in the rough westy is a jewel in the rough westy is a jewel in the rough

      0  

    Default


    Try a linter like javascriptlint or Douglas Crockford's original JSLint.
    Product Architect
    Altus Ltd.

  5. #5
    Sencha User
    Join Date
    Aug 2012
    Posts
    15
    Vote Rating
    1
    m.sudharsanreddy is on a distinguished road

      0  

    Default


    Hi Westy,

    I am using sonar server for code review. Sonar has java script plugin in built.
    I am not aware how to use javascriptlint or Douglas Crockford's original JSLint in saonr.

    If any body know how to use please let me know.

    Thanks,
    Sud

  6. #6
    Sencha User
    Join Date
    Aug 2012
    Posts
    15
    Vote Rating
    1
    m.sudharsanreddy is on a distinguished road

      0  

    Default


    Hi All,

    Please help me how to use javascriptlint or Douglas Crockford's original JSLint in sonar.

    Thanks in Advance...!

Thread Participants: 2