From de0ebd99a1c3bfeafc3d4b9dd840c0e319da60b7 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Mon, 23 Oct 2017 15:01:10 +0200 Subject: [PATCH] jslint: type confusion resolve/mark several type confusions Signed-off-by: Dominik Csapak --- js/ClamAVDatabase.js | 6 ++++++ js/ClusterAdministration.js | 6 ++++-- js/ContactStatistics.js | 2 ++ js/Dashboard.js | 17 +++++++++++++---- js/DomainStatistics.js | 4 ++-- js/FetchmailEdit.js | 2 ++ js/HourlyMailDistribution.js | 3 ++- js/LDAPConfig.js | 16 +++++++++++----- js/MailProxyOptions.js | 6 ++++++ js/MailTracker.js | 8 ++++++-- js/MyNetworks.js | 3 +++ js/QuarantineView.js | 8 ++++++-- js/ReceiverStatistics.js | 2 ++ js/RelayDomains.js | 3 +++ js/RuleConfiguration.js | 7 ++++++- js/SenderStatistics.js | 2 ++ js/SpamDetectorLanguages.js | 5 ++++- js/SpamQuarantineOptions.js | 3 +++ js/SpamScoreDistribution.js | 2 +- js/Transport.js | 3 +++ js/UserBlackWhiteList.js | 3 +++ js/UserEdit.js | 2 ++ js/UserView.js | 2 ++ js/Utils.js | 3 +++ 24 files changed, 97 insertions(+), 21 deletions(-) diff --git a/js/ClamAVDatabase.js b/js/ClamAVDatabase.js index 80a8582..b6a3f30 100644 --- a/js/ClamAVDatabase.js +++ b/js/ClamAVDatabase.js @@ -11,8 +11,11 @@ Ext.define('PMG.ClamAVDatabaseConfig', { me.add_text_row('dbmirror', gettext('Database Mirror'), { deleteEmpty: true, defaultValue: 'database.clamav.net' }); + /*jslint confusion: true*/ + /*defaultValue is a string above*/ me.add_boolean_row('safebrowsing', gettext('Google Safe Browsing'), { defaultValue: 1 }); + /*jslint confusion: false*/ var baseurl = '/config/clamav'; @@ -107,7 +110,10 @@ Ext.define('PMG.ClamAVDatabaseStatus', { me.callParent(); + /*jslint confusion: true*/ + /*monStoreErrors is a bool above*/ Proxmox.Utils.monStoreErrors(me.getView(), me.store, true); + /*jslint confusion: false*/ } }); diff --git a/js/ClusterAdministration.js b/js/ClusterAdministration.js index 3a95ef9..d1a2ff3 100644 --- a/js/ClusterAdministration.js +++ b/js/ClusterAdministration.js @@ -77,7 +77,7 @@ Ext.define('PMG.ClusterAddNodeWindow', { { xtype: 'component', border: false, - padding: 10, + padding: '10 10 10 10', html: gettext("Please use the 'Join' button on the node you want to add, using the following IP address and fingerprint.") }, { @@ -103,6 +103,8 @@ Ext.define('PMG.ClusterAddNodeWindow', { ] }); +/*jslint confusion: true*/ +/* bind is a function and object */ Ext.define('PMG.ClusterAdministration', { extend: 'Ext.tab.Panel', xtype: 'pmgClusterAdministration', @@ -276,7 +278,7 @@ Ext.define('PMG.ClusterAdministration', { if (Ext.isArray(value)) { return value[0]; } - return value; + return value.toString(); }, dataIndex: 'loadavg' }, diff --git a/js/ContactStatistics.js b/js/ContactStatistics.js index f50b42f..948f6d0 100644 --- a/js/ContactStatistics.js +++ b/js/ContactStatistics.js @@ -1,4 +1,6 @@ /*global Proxmox*/ +/*jslint confusion: true*/ +/* filter is a function and object */ Ext.define('PMG.ContactDetails', { extend: 'Ext.grid.GridPanel', xtype: 'pmgContactDetails', diff --git a/js/Dashboard.js b/js/Dashboard.js index 4fc35fd..7dcc831 100644 --- a/js/Dashboard.js +++ b/js/Dashboard.js @@ -1,4 +1,11 @@ /*global Proxmox*/ +/*jslint confusion: true*/ +/* load is a function and string + * hours is a number and string + * timespan is a number and string + * bind is a function and object + * handler is a function and string + */ Ext.define('PMG.Dashboard', { extend: 'Ext.panel.Panel', xtype: 'pmgDashboard', @@ -18,7 +25,7 @@ Ext.define('PMG.Dashboard', { }, items: [{ xtype: 'form', - bodyPadding: 10, + bodyPadding: '10 10 10 10', defaultButton: 'savebutton', items: [{ xtype: 'proxmoxintegerfield', @@ -73,7 +80,7 @@ Ext.define('PMG.Dashboard', { var bytes_in = 0; var bytes_out = 0; var ptime = 0; - var avg_ptime = 0; + var avg_ptime; records.forEach(function(item) { bytes_in += item.data.bytes_in; @@ -260,7 +267,9 @@ Ext.define('PMG.Dashboard', { Ext.String.format(gettext('{0} hours'), '{hours}') + ')' }, - layout: 'column', + layout: { + type: 'column' + }, border: false, bodyPadding: '20 0 0 20', @@ -394,7 +403,7 @@ Ext.define('PMG.Dashboard', { iconCls: 'fa fa-list', title: gettext('Top Receivers'), - bodyPadding: 20, + bodyPadding: '20 20 20 20', layout: { type: 'vbox', pack: 'center', diff --git a/js/DomainStatistics.js b/js/DomainStatistics.js index 7762bb7..72784d4 100644 --- a/js/DomainStatistics.js +++ b/js/DomainStatistics.js @@ -54,7 +54,7 @@ Ext.define('PMG.DomainStatistics', { return v === '' ? '--- EMPTY ADDRESS ---' : Ext.htmlEncode(v); }; - me.items = { + me.items = [{ xtype: 'tabpanel', border: false, items: [ @@ -143,7 +143,7 @@ Ext.define('PMG.DomainStatistics', { ] } ] - }; + }]; me.callParent(); diff --git a/js/FetchmailEdit.js b/js/FetchmailEdit.js index f019d14..a268dfa 100644 --- a/js/FetchmailEdit.js +++ b/js/FetchmailEdit.js @@ -1,3 +1,5 @@ +/*jslint confusion: true*/ +/*value is string and number*/ Ext.define('PMG.FetchmailEdit', { extend: 'Proxmox.window.Edit', xtype: 'pmgFetchmailEdit', diff --git a/js/HourlyMailDistribution.js b/js/HourlyMailDistribution.js index bb96cc9..7f223d2 100644 --- a/js/HourlyMailDistribution.js +++ b/js/HourlyMailDistribution.js @@ -41,7 +41,8 @@ Ext.define('PMG.MailDistChart', { renderer: function(tooltip, record, item) { var start = record.get('index'); var end = start+1; - tooltip.setHtml('Time: ' + start + ' - ' + end + '
' + + tooltip.setHtml('Time: ' + start.toString() + + ' - ' + end.toString() + '
' + 'Count: ' + record.get(item.field)); } } diff --git a/js/LDAPConfig.js b/js/LDAPConfig.js index 27a9442..8294822 100644 --- a/js/LDAPConfig.js +++ b/js/LDAPConfig.js @@ -1,4 +1,12 @@ /*global Proxmox*/ +/*jslint confusion: true*/ +/*create is function and bool, + * reload is function and string, + * height is number and string, + * hidden is bool and string, + * bind is function and object, + * callback is function and string + */ Ext.define('pmg-ldap-config', { extend: 'Ext.data.Model', fields: [ 'profile', 'server1', 'server2', 'comment', @@ -364,9 +372,7 @@ Ext.define('PMG.LDAPConfig', { } }, - layout: { - type: 'border', - }, + layout: 'border', items: [ { @@ -496,10 +502,10 @@ Ext.define('PMG.LDAPConfigGrid', { store: { model: 'pmg-ldap-config', - sorters: { + sorters: [{ property: 'profile', order: 'DESC' - } + }] }, tbar: [ diff --git a/js/MailProxyOptions.js b/js/MailProxyOptions.js index c3ede9a..7312b5f 100644 --- a/js/MailProxyOptions.js +++ b/js/MailProxyOptions.js @@ -28,6 +28,8 @@ Ext.define('PMG.MailProxyOptions', { return Proxmox.Utils.yesText + ' (' + value + ')'; }; + /*jslint confusion: true*/ + /*defaultValue is string and number*/ me.add_combobox_row('verifyreceivers', gettext('Verify Receivers'), { renderer: render_verifyreceivers, defaultValue: '__default__', @@ -37,6 +39,7 @@ Ext.define('PMG.MailProxyOptions', { ['450', render_verifyreceivers('450') ], ['550', render_verifyreceivers('550') ]] }); + /*jslint confusion: false*/ me.add_boolean_row('greylist', gettext('Use Greylisting'), { defaultValue: 1 }); @@ -57,8 +60,11 @@ Ext.define('PMG.MailProxyOptions', { me.add_integer_row('message_rate_limit', gettext('Client Message Rate Limit'), { defaultValue: 0, minValue: 0 }); + /*jslint confusion: true*/ + /*defaultValue is string and number*/ me.add_text_row('banner', gettext('SMTPD Banner'), { deleteEmpty: true, defaultValue: 'ESMTP Proxmox' }); + /*jslint confusion: false*/ var baseurl = '/config/mail'; diff --git a/js/MailTracker.js b/js/MailTracker.js index a992c6a..991eecd 100644 --- a/js/MailTracker.js +++ b/js/MailTracker.js @@ -106,7 +106,9 @@ Ext.define('PMG.MailTrackerFilter', { xtype: 'promxoxDateTimeField' }, { - layout: 'hbox', + layout: { + type: 'hbox' + }, border: false, items: [ { @@ -145,7 +147,9 @@ Ext.define('PMG.MaiLogWindow', { height: 400, scrollable: true, - layout: 'auto', + layout: { + type: 'auto' + }, modal: true, bodyPadding: 5, diff --git a/js/MyNetworks.js b/js/MyNetworks.js index f5a6c6f..977af50 100644 --- a/js/MyNetworks.js +++ b/js/MyNetworks.js @@ -79,6 +79,8 @@ Ext.define('PMG.MyNetworks', { { text: gettext('Create'), handler: function() { + /*jslint confusion: true*/ + /* create is function and bool */ var config = { method: 'POST', url: "/api2/extjs/config/mynetworks", @@ -97,6 +99,7 @@ Ext.define('PMG.MyNetworks', { } ] }; + /*jslint confusion: false*/ var win = Ext.createWidget('proxmoxWindowEdit', config); diff --git a/js/QuarantineView.js b/js/QuarantineView.js index 2721d22..3d69d12 100644 --- a/js/QuarantineView.js +++ b/js/QuarantineView.js @@ -183,7 +183,9 @@ Ext.define('PMG.QuarantineView', { plugins: 'viewport', - layout: 'border', + layout: { + type: 'border' + }, items: [ { @@ -234,7 +236,9 @@ Ext.define('PMG.QuarantineView', { }, { xtype: 'panel', - layout: 'card', + layout: { + type: 'card' + }, region: 'center', border: false, reference: 'contentpanel' diff --git a/js/ReceiverStatistics.js b/js/ReceiverStatistics.js index bccd483..438db77 100644 --- a/js/ReceiverStatistics.js +++ b/js/ReceiverStatistics.js @@ -1,4 +1,6 @@ /*global Proxmox*/ +/*jslint confusion: true*/ +/* filter is a function and object */ Ext.define('PMG.ReceiverDetails', { extend: 'Ext.grid.GridPanel', xtype: 'pmgReceiverDetails', diff --git a/js/RelayDomains.js b/js/RelayDomains.js index 3b8e0ac..387355a 100644 --- a/js/RelayDomains.js +++ b/js/RelayDomains.js @@ -79,6 +79,8 @@ Ext.define('PMG.RelayDomains', { { text: gettext('Create'), handler: function() { + /*jslint confusion: true*/ + /* create is a function and boolean */ var config = { method: 'POST', url: "/api2/extjs/config/domains", @@ -97,6 +99,7 @@ Ext.define('PMG.RelayDomains', { } ] }; + /*jslint confusion: false*/ var win = Ext.createWidget('proxmoxWindowEdit', config); diff --git a/js/RuleConfiguration.js b/js/RuleConfiguration.js index 9f28472..a28fa87 100644 --- a/js/RuleConfiguration.js +++ b/js/RuleConfiguration.js @@ -1,4 +1,9 @@ /*global Proxmox*/ +/*jslint confusion: true*/ +/* create is a function and boolean, + * bind is a function and object, + * callback is a function and string + */ Ext.define('pmg-rule-list', { extend: 'Ext.data.Model', fields: [ @@ -26,7 +31,7 @@ Ext.define('PMG.RulesConfiguration', { selectedRuleChange: function(grid, selected, eOpts) { var me = this; var infoPanel = me.lookupReference('infopanel'); - var baseurl = undefined; + var baseurl; if (selected.length > 0) { baseurl = '/config/ruledb/rules/' + selected[0].data.id; diff --git a/js/SenderStatistics.js b/js/SenderStatistics.js index 89ad408..863700d 100644 --- a/js/SenderStatistics.js +++ b/js/SenderStatistics.js @@ -1,4 +1,6 @@ /*global Proxmox*/ +/*jslint confusion: true*/ +/* filter is a function and object */ Ext.define('PMG.SenderDetails', { extend: 'Ext.grid.GridPanel', xtype: 'pmgSenderDetails', diff --git a/js/SpamDetectorLanguages.js b/js/SpamDetectorLanguages.js index b30e3ab..b63c627 100644 --- a/js/SpamDetectorLanguages.js +++ b/js/SpamDetectorLanguages.js @@ -73,7 +73,10 @@ Ext.define('PMG.SpamDetectorLanguagesInputPanel', { if (!values.languages) { values['delete'] = 'languages'; } else if (Ext.isArray(values.languages)) { - values.languages = values.languages.join(' ') + /*jslint confusion: true*/ + /*languages is an array and string here*/ + values.languages = values.languages.join(' '); + /*jslint confusion: false*/ } return values; diff --git a/js/SpamQuarantineOptions.js b/js/SpamQuarantineOptions.js index 9eea97f..ca4c7b9 100644 --- a/js/SpamQuarantineOptions.js +++ b/js/SpamQuarantineOptions.js @@ -30,6 +30,8 @@ Ext.define('PMG.SpamQuarantineOptions', { return me.authmodeTextHash[value] || value; }; + /*jslint confusion: true*/ + /* defaultValue is a string and a number*/ me.add_combobox_row('authmode', gettext('Authentication mode'), { defaultValue: 'ticket', renderer: render_authmode, @@ -53,6 +55,7 @@ Ext.define('PMG.SpamQuarantineOptions', { ['outlook', render_reportstyle('outlook') ], ['custom', render_reportstyle('custom') ]] }); + /*jslint confusion: false*/ me.add_text_row('hostname', gettext('Quarantine Host'), { deleteEmpty: true, defaultValue: Proxmox.Utils.noneText }); diff --git a/js/SpamScoreDistribution.js b/js/SpamScoreDistribution.js index 6bd1170..866849b 100644 --- a/js/SpamScoreDistribution.js +++ b/js/SpamScoreDistribution.js @@ -21,7 +21,7 @@ Ext.define('PMG.SpamScoreDistribution', { if (rec.data.level >= 10) { return PMG.Utils.scoreText + ' >= 10'; } else { - return PMG.Utils.scoreText + ' ' + rec.data.level; + return PMG.Utils.scoreText + ' ' + rec.data.level.toString(); } } } diff --git a/js/Transport.js b/js/Transport.js index 7d1ca6e..ab37f67 100644 --- a/js/Transport.js +++ b/js/Transport.js @@ -100,6 +100,8 @@ Ext.define('PMG.Transport', { win.show(); }; + /*jslint confusion: true*/ + /*create is a function and boolean */ var tbar = [ { xtype: 'proxmoxButton', @@ -127,6 +129,7 @@ Ext.define('PMG.Transport', { }, remove_btn ]; + /*jslint confusion: false*/ Proxmox.Utils.monStoreErrors(me, store, true); diff --git a/js/UserBlackWhiteList.js b/js/UserBlackWhiteList.js index 477e188..2f20b92 100644 --- a/js/UserBlackWhiteList.js +++ b/js/UserBlackWhiteList.js @@ -38,6 +38,8 @@ Ext.define('PMG.UserBlackWhiteList', { }); }); + /*jslint confusion: true*/ + /* create is an function */ var config = { method: 'POST', url: url, @@ -45,6 +47,7 @@ Ext.define('PMG.UserBlackWhiteList', { isAdd: true, items: items }; + /*jslint confusion: false*/ if (me.listname === 'blacklist') { config.subject = gettext("Blacklist"); diff --git a/js/UserEdit.js b/js/UserEdit.js index 5811c24..bf66dcf 100644 --- a/js/UserEdit.js +++ b/js/UserEdit.js @@ -1,4 +1,6 @@ /*global Proxmox*/ +/*jslint confusion: true*/ +/* submitvalue is string and bool */ Ext.define('PMG.UserEdit', { extend: 'Proxmox.window.Edit', alias: 'widget.pmgUserEdit', diff --git a/js/UserView.js b/js/UserView.js index e1cb972..0a7fd70 100644 --- a/js/UserView.js +++ b/js/UserView.js @@ -1,4 +1,6 @@ /*global Proxmox*/ +/*jslint confusion: true*/ +/*renderer is string and function*/ Ext.define('pmg-users', { extend: 'Ext.data.Model', fields: [ diff --git a/js/Utils.js b/js/Utils.js index 7a8e611..ce806f0 100644 --- a/js/Utils.js +++ b/js/Utils.js @@ -736,8 +736,11 @@ Ext.define('PMG.Utils', { var from = Ext.htmlEncode(rec.data.from); var sender = Ext.htmlEncode(rec.data.sender); if (sender) { + /*jslint confusion: true*/ + /*format is a string above*/ from = Ext.String.format(gettext("{0} on behalf of {1}"), sender, from); + /*jslint confusion: false*/ } return '' + from + '
' + subject; },