diff --git a/.eslintrc.json b/.eslintrc.json index 90fee1985ab..5e1c5f82daa 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -10,7 +10,44 @@ "extends": ["prettier"], "plugins": ["prettier"], "rules": { + // Formatting "prettier/prettier": "error", + + // Syntax and logic errors + "for-direction": "error", + "getter-return": "error", + "no-async-promise-executor": "error", + "no-constant-condition": "error", + "no-control-regex": "error", + "no-debugger": "error", + "no-dupe-args": "error", + "no-dupe-else-if": "error", + "no-dupe-keys": "error", + "no-duplicate-case": "error", + "no-empty": "error", + "no-empty-character-class": "error", + "no-ex-assign": "error", + "no-extra-boolean-cast": "error", + "no-extra-semi": "error", + "no-func-assign": "error", + "no-import-assign": "error", + "no-inner-declarations": "error", + "no-invalid-regexp": "error", + "no-irregular-whitespace": "error", + "no-misleading-character-class": "error", + "no-obj-calls": "error", + "no-prototype-builtins": "error", + "no-regex-spaces": "error", + "no-setter-return": "error", + "no-sparse-arrays": "error", + "no-unexpected-multiline": "error", + "no-unreachable": "error", + "no-unsafe-finally": "error", + "no-unsafe-negation": "error", + "use-isnan": "error", + "valid-typeof": "error", + + // Additional rules we find useful "prefer-const": "error" } } diff --git a/assets/javascripts/audit_log.js b/assets/javascripts/audit_log.js index fc7b13702de..7e7a59b0e6f 100644 --- a/assets/javascripts/audit_log.js +++ b/assets/javascripts/audit_log.js @@ -88,7 +88,9 @@ function loadAuditLogTable() { if (url) { return '' + htmlEscape(data) + ''; } - } catch (e) {} + } catch (e) { + // Intentionally ignore all errors + } } return data; } diff --git a/assets/javascripts/job_templates.js b/assets/javascripts/job_templates.js index b167274adb0..8f837c14976 100644 --- a/assets/javascripts/job_templates.js +++ b/assets/javascripts/job_templates.js @@ -51,7 +51,7 @@ function templateRemoved(chosen, deselected) { function addFailed(data) { // display something without alert - if (data.hasOwnProperty('responseJSON')) { + if (Object.prototype.hasOwnProperty.call(data, 'responseJSON')) { alert(data.responseJSON.error); } else { alert('unknown error'); @@ -225,7 +225,7 @@ function buildMediumGroup(group, media) { $.each(media, function (index, temp) { var a = archs[temp.product.arch]; if (!a) a = {}; - if (!a.hasOwnProperty(temp.test_suite.name)) { + if (!Object.prototype.hasOwnProperty.call(a, temp.test_suite.name)) { a[temp.test_suite.name] = []; table.data('product-' + temp.product.arch, temp.product.id); a['_id'] = temp.product.id; @@ -260,7 +260,10 @@ function buildMediumGroup(group, media) { select.attr('id', group + '-' + arch + '-' + test); select.attr('data-product-id', archs[arch]['_id']); select.addClass('chosen-select'); - if (archs.hasOwnProperty(arch) && archs[arch].hasOwnProperty(test)) { + if ( + Object.prototype.hasOwnProperty.call(archs, arch) && + Object.prototype.hasOwnProperty.call(archs[arch], test) + ) { $.each(archs[arch][test], function (mi, temp) { var option = select.find("option[value='" + temp.machine.name + "']").prop('selected', true); // remember the id for DELETE @@ -470,22 +473,24 @@ function submitTemplateEditor(button) { }) .fail(function (data) { result.text('There was a problem applying the changes:'); - if (!data.hasOwnProperty('responseJSON')) { + if (!Object.prototype.hasOwnProperty.call(data, 'responseJSON')) { $('
') .text('Invalid server response: ' + data.statusText) .appendTo(result); return; } var data = data.responseJSON; - if (data.hasOwnProperty('error')) { + if (Object.prototype.hasOwnProperty.call(data, 'error')) { var errors = data.error; var list = $('