View Full Version : Avoid trailing comma in array and object literals code review

28 Jan 2013, 1:57 AM
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...

28 Jan 2013, 5:36 AM
Your testing is flawed then as that is 100% valid JavaScript.