Skip to content

Commit

Permalink
eslint: disallow nested ternaries (wikimedia-gadgets#1695)
Browse files Browse the repository at this point in the history
* eslint: disallow nested ternaries

* fix two nested ternaries
  • Loading branch information
NovemLinguae authored Jan 22, 2023
1 parent 14c681b commit ca7dc8b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": ["error", "always", { "line": { "exceptions": ["-"] }, "block": { "balanced": true } }],
"switch-colon-spacing": "error"
"switch-colon-spacing": "error",
"no-nested-ternary": "error"
},
"reportUnusedDisableDirectives": true
}
11 changes: 10 additions & 1 deletion modules/twinkleblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,16 @@ Twinkle.block.callback.filtered_block_groups = function twinkleblockCallbackFilt
}

var blockSettings = Twinkle.block.blockPresetsInfo[blockPreset.value];
var registrationRestrict = blockSettings.forRegisteredOnly ? Twinkle.block.isRegistered : blockSettings.forAnonOnly ? !Twinkle.block.isRegistered : true;

var registrationRestrict;
if (blockSettings.forRegisteredOnly) {
registrationRestrict = Twinkle.block.isRegistered;
} else if (blockSettings.forAnonOnly) {
registrationRestrict = !Twinkle.block.isRegistered;
} else {
registrationRestrict = true;
}

if (!(blockSettings.templateName && show_template) && registrationRestrict) {
var templateName = blockSettings.templateName || blockPreset.value;
return {
Expand Down
10 changes: 9 additions & 1 deletion morebits.js
Original file line number Diff line number Diff line change
Expand Up @@ -5981,7 +5981,15 @@ Morebits.simpleWindow.prototype = {
$(this.content).find('input[type="submit"], button[type="submit"]').each(function(key, value) {
value.style.display = 'none';
var button = document.createElement('button');
button.textContent = value.hasAttribute('value') ? value.getAttribute('value') : value.textContent ? value.textContent : msg('submit', 'Submit Query');

if (value.hasAttribute('value')) {
button.textContent = value.getAttribute('value');
} else if (value.textContent) {
button.textContent = value.textContent;
} else {
button.textContent = msg('submit', 'Submit Query');
}

button.className = value.className || 'submitButtonProxy';
// here is an instance of cheap coding, probably a memory-usage hit in using a closure here
button.addEventListener('click', function() {
Expand Down

0 comments on commit ca7dc8b

Please sign in to comment.