Bug 1687235 - Enable ESLint rule no-setter-return for toolkit and services. r=mossop

Differential Revision: https://phabricator.services.mozilla.com/D102153
This commit is contained in:
Mark Banner 2021-01-26 13:43:58 +00:00
parent c4afa9e9ad
commit 930543e681
38 changed files with 35 additions and 178 deletions

View File

@ -669,27 +669,6 @@ module.exports = {
"dom/media/PeerConnection.jsm",
"mobile/android/chrome/geckoview/SessionStateAggregator.js",
"mobile/android/modules/geckoview/DelayedInit.jsm",
"services/sync/modules/record.js",
"toolkit/actors/AutoCompleteChild.jsm",
"toolkit/components/autocomplete/tests/unit/test_stopSearch.js",
"toolkit/components/enterprisepolicies/EnterprisePoliciesParent.jsm",
"toolkit/components/extensions/ExtensionParent.jsm",
"toolkit/components/osfile/modules/osfile_async_front.jsm",
"toolkit/components/osfile/modules/osfile_shared_allthreads.jsm",
"toolkit/content/aboutSupport.js",
"toolkit/content/customElements.js",
"toolkit/content/preferencesBindings.js",
"toolkit/content/tests/chrome/test_custom_element_base.xhtml",
"toolkit/content/viewZoomOverlay.js",
"toolkit/content/widgets/*.js",
"toolkit/modules/NewTabUtils.jsm",
"toolkit/modules/tests/modules/Task.jsm",
"toolkit/mozapps/extensions/AddonManager.jsm",
"toolkit/mozapps/extensions/internal/PluginProvider.jsm",
"toolkit/mozapps/extensions/internal/XPIDatabase.jsm",
"toolkit/mozapps/extensions/test/browser/head.js",
"toolkit/mozapps/extensions/test/xpcshell/head_addons.js",
"toolkit/mozapps/handling/content/dialog.js",
],
rules: {
"no-setter-return": "off",

View File

@ -350,7 +350,7 @@ CryptoWrapper.prototype = {
// Keep both plaintext and encrypted versions of the id to verify integrity
set id(val) {
super.id = val;
return (this.cleartext.id = val);
this.cleartext.id = val;
},
};

View File

@ -25,9 +25,7 @@ AutoCompleteInput.prototype = {
textValue: "hello",
disableAutoComplete: false,
completeDefaultIndex: false,
set popupOpen(val) {
return val;
}, // ignore
set popupOpen(val) {}, // ignore
get popupOpen() {
return false;
},
@ -44,9 +42,7 @@ AutoCompleteInput.prototype = {
popup: {
selectBy() {},
invalidate() {},
set selectedIndex(val) {
return val;
}, // ignore
set selectedIndex(val) {}, // ignore
get selectedIndex() {
return -1;
},

View File

@ -339,7 +339,6 @@ EnterprisePoliciesManager.prototype = {
if (val != Ci.nsIEnterprisePolicies.INACTIVE) {
Services.ppmm.sharedData.set("EnterprisePolicies:Status", val);
}
return val;
},
get status() {

View File

@ -640,8 +640,6 @@ class DevToolsExtensionPageContextParent extends ExtensionPageContextParent {
}
this._devToolsToolbox = toolbox;
return toolbox;
}
get devToolsToolbox() {

View File

@ -1584,7 +1584,7 @@ OS.Shared = {
return SharedAll.Config.DEBUG;
},
set DEBUG(x) {
return (SharedAll.Config.DEBUG = x);
SharedAll.Config.DEBUG = x;
},
};
Object.freeze(OS.Shared);

View File

@ -1346,7 +1346,7 @@ Object.defineProperty(exports.OS.Shared, "DEBUG", {
return Config.DEBUG;
},
set(x) {
return (Config.DEBUG = x);
Config.DEBUG = x;
},
});
Object.defineProperty(exports.OS.Shared, "TEST", {
@ -1354,7 +1354,7 @@ Object.defineProperty(exports.OS.Shared, "TEST", {
return Config.TEST;
},
set(x) {
return (Config.TEST = x);
Config.TEST = x;
},
});

View File

@ -1558,7 +1558,7 @@ Serializer.prototype = {
},
set _currentLine(val) {
return (this._lines[this._lines.length - 1] = val);
this._lines[this._lines.length - 1] = val;
},
_serializeElement(elem) {

View File

@ -742,7 +742,6 @@
class BaseText extends MozElements.BaseControlMixin(Base) {
set label(val) {
this.setAttribute("label", val);
return val;
}
get label() {
@ -751,7 +750,6 @@
set crop(val) {
this.setAttribute("crop", val);
return val;
}
get crop() {
@ -760,7 +758,6 @@
set image(val) {
this.setAttribute("image", val);
return val;
}
get image() {
@ -769,7 +766,6 @@
set command(val) {
this.setAttribute("command", val);
return val;
}
get command() {
@ -784,7 +780,6 @@
if (this.labelElement) {
this.labelElement.accessKey = val;
}
return val;
}
get accessKey() {

View File

@ -522,7 +522,6 @@ const Preferences = (window.Preferences = (function() {
}
this.emit("change");
}
return val;
}
get locked() {
@ -603,13 +602,13 @@ const Preferences = (window.Preferences = (function() {
set valueFromPreferences(val) {
// Exit early if nothing to do.
if (this.readonly || this.valueFromPreferences == val) {
return val;
return;
}
// The special value undefined means 'reset preference to default'.
if (val === undefined) {
Services.prefs.clearUserPref(this.id);
return val;
return;
}
// Force a resync of preferences with value.
@ -657,7 +656,6 @@ const Preferences = (window.Preferences = (function() {
if (!this.batching) {
Services.prefs.savePrefFile(null);
}
return val;
}
}

View File

@ -288,7 +288,6 @@
set disabled(val) {
if (val) this.setAttribute("disabled", "true");
else this.removeAttribute("disabled");
return val;
}
get tabIndex() {
@ -298,7 +297,6 @@
set tabIndex(val) {
if (val) this.setAttribute("tabIndex", val);
else this.removeAttribute("tabIndex");
return val;
}
}
@ -363,4 +361,3 @@
]]>
</script>
</window>

View File

@ -29,7 +29,6 @@ var ZoomManager = {
set useFullZoom(aVal) {
Services.prefs.setBoolPref("browser.zoom.full", aVal);
return aVal;
},
get zoom() {
@ -57,7 +56,6 @@ var ZoomManager = {
set zoom(aVal) {
this.setZoomForBrowser(gBrowser, aVal);
return aVal;
},
setZoomForBrowser: function ZoomManager_setZoomForBrowser(aBrowser, aVal) {

View File

@ -188,7 +188,6 @@
set smoothScroll(val) {
this.setAttribute("smoothscroll", !!val);
return val;
}
get smoothScroll() {

View File

@ -178,7 +178,6 @@
set disableAutoComplete(val) {
this.setAttribute("disableautocomplete", val);
return val;
}
get disableAutoComplete() {
@ -187,7 +186,6 @@
set completeDefaultIndex(val) {
this.setAttribute("completedefaultindex", val);
return val;
}
get completeDefaultIndex() {
@ -196,7 +194,6 @@
set completeSelectedIndex(val) {
this.setAttribute("completeselectedindex", val);
return val;
}
get completeSelectedIndex() {
@ -205,7 +202,6 @@
set forceComplete(val) {
this.setAttribute("forcecomplete", val);
return val;
}
get forceComplete() {
@ -214,7 +210,6 @@
set minResultsForPopup(val) {
this.setAttribute("minresultsforpopup", val);
return val;
}
get minResultsForPopup() {
@ -224,7 +219,6 @@
set timeout(val) {
this.setAttribute("timeout", val);
return val;
}
get timeout() {
@ -234,7 +228,6 @@
set searchParam(val) {
this.setAttribute("autocompletesearchparam", val);
return val;
}
get searchParam() {
@ -258,8 +251,6 @@
// "input" event is automatically dispatched by the editor if
// necessary.
this._setValueInternal(val, true);
return this.value;
}
get textValue() {
@ -272,9 +263,7 @@
return true;
}
set crop(val) {
return false;
}
set crop(val) {}
get crop() {
return false;
@ -293,7 +282,7 @@
}
set value(val) {
return this._setValueInternal(val, false);
this._setValueInternal(val, false);
}
get value() {
@ -309,7 +298,6 @@
*/
set maxRows(val) {
this.setAttribute("maxrows", val);
return val;
}
get maxRows() {
@ -321,7 +309,6 @@
*/
set maxdropmarkerrows(val) {
this.setAttribute("maxdropmarkerrows", val);
return val;
}
get maxdropmarkerrows() {
@ -333,7 +320,6 @@
*/
set tabScrolling(val) {
this.setAttribute("tabscrolling", val);
return val;
}
get tabScrolling() {
@ -345,7 +331,6 @@
*/
set ignoreBlurWhileSearching(val) {
this.setAttribute("ignoreblurwhilesearching", val);
return val;
}
get ignoreBlurWhileSearching() {
@ -356,7 +341,6 @@
*/
set highlightNonMatches(val) {
this.setAttribute("highlightnonmatches", val);
return val;
}
get highlightNonMatches() {

View File

@ -159,7 +159,6 @@
this.richlistbox.selectedItem || this.richlistbox.firstElementChild
);
}
return val;
}
get selectedIndex() {
@ -185,9 +184,7 @@
return Number(this.getAttribute("overflowpadding"));
}
set view(val) {
return val;
}
set view(val) {}
get view() {
return this.mInput.controller;

View File

@ -115,7 +115,6 @@
set type(val) {
this.setAttribute("type", val);
return val;
}
get type() {
@ -128,7 +127,6 @@
} else {
this.removeAttribute("disabled");
}
return val;
}
get disabled() {
@ -137,7 +135,6 @@
set group(val) {
this.setAttribute("group", val);
return val;
}
get group() {
@ -153,7 +150,6 @@
} else {
this.removeAttribute("open");
}
return val;
}
get open() {
@ -173,8 +169,6 @@
} else {
this.removeAttribute("checked");
}
return val;
}
get checked() {

View File

@ -70,7 +70,6 @@
event.initEvent("CheckboxStateChange", true, true);
this.dispatchEvent(event);
}
return val;
}
get checked() {

View File

@ -168,7 +168,6 @@
set buttons(val) {
this._configureButtons(val);
return val;
}
get buttons() {
@ -177,7 +176,6 @@
set defaultButton(val) {
this._setDefaultButton(val);
return val;
}
get defaultButton() {

View File

@ -278,7 +278,6 @@
set findMode(val) {
this._findMode = val;
this._updateBrowserWithState();
return val;
}
get findMode() {
@ -287,7 +286,6 @@
set prefillWithSelection(val) {
this.setAttribute("prefillwithselection", val);
return val;
}
get prefillWithSelection() {
@ -340,7 +338,6 @@
this._browser.finder.addResultListener(this);
}
return val;
}
get browser() {

View File

@ -10,13 +10,12 @@
class MozDeck extends MozXULElement {
set selectedIndex(val) {
if (this.selectedIndex == val) {
return val;
return;
}
this.setAttribute("selectedIndex", val);
var event = document.createEvent("Events");
event.initEvent("select", true, true);
this.dispatchEvent(event);
return val;
}
get selectedIndex() {
@ -33,7 +32,6 @@
++selectedIndex;
}
this.selectedIndex = selectedIndex;
return val;
}
get selectedPanel() {

View File

@ -60,7 +60,6 @@
class MozMenuBase extends MozMenuItemBaseMixin(Base) {
set open(val) {
this.openMenu(val);
return val;
}
get open() {

View File

@ -115,7 +115,8 @@
set value(val) {
// if the new value is null, we still need to remove the old value
if (val == null) {
return (this.selectedItem = val);
this.selectedItem = val;
return;
}
var arr = null;
@ -130,8 +131,6 @@
this.selectedItem = null;
this.setAttribute("value", val);
}
return val;
}
// nsIDOMXULSelectControlElement
@ -152,7 +151,6 @@
// nsIDOMXULMenuListElement
set image(val) {
this.setAttribute("image", val);
return val;
}
// nsIDOMXULMenuListElement
@ -167,7 +165,6 @@
set description(val) {
this.setAttribute("description", val);
return val;
}
get description() {
@ -177,7 +174,6 @@
// nsIDOMXULMenuListElement
set open(val) {
this.openMenu(val);
return val;
}
// nsIDOMXULMenuListElement
@ -208,7 +204,6 @@
} else {
this.selectedItem = null;
}
return val;
}
// nsIDOMXULSelectControlElement
@ -237,11 +232,11 @@
set selectedItem(val) {
var oldval = this.mSelectedInternal;
if (oldval == val) {
return val;
return;
}
if (val && !this.contains(val)) {
return val;
return;
}
if (oldval) {
@ -278,8 +273,6 @@
event = document.createEvent("Events");
event.initEvent("ValueChange", true, true);
this.dispatchEvent(event);
return val;
}
// nsIDOMXULSelectControlElement

View File

@ -81,7 +81,7 @@
if (!v) {
this.initialize();
}
return (super.hidden = v);
super.hidden = v;
}
removeAttribute(name) {

View File

@ -211,7 +211,6 @@
break;
}
}
return val;
}
get value() {
@ -228,7 +227,6 @@
for (var i = 0; i < children.length; ++i) {
children[i].disabled = val;
}
return val;
}
get disabled() {
@ -254,7 +252,6 @@
set selectedIndex(val) {
this.selectedItem = this._getRadioChildren()[val];
return val;
}
get selectedIndex() {
@ -320,8 +317,6 @@
}
}
}
return val;
}
get selectedItem() {
@ -350,7 +345,6 @@
children[i].removeAttribute("focused");
}
}
return val;
}
get focusedItem() {

View File

@ -209,7 +209,6 @@
if (kids && kids.item(0)) {
this.selectItem(kids[0]);
}
return val;
}
get value() {
if (this.selectedItems.length) {
@ -226,7 +225,6 @@
// nsIDOMXULSelectControlElement
set selType(val) {
this.setAttribute("seltype", val);
return val;
}
get selType() {
return this.getAttribute("seltype");
@ -235,7 +233,7 @@
// nsIDOMXULSelectControlElement
set currentItem(val) {
if (this._currentItem == val) {
return val;
return;
}
if (this._currentItem) {
@ -255,8 +253,6 @@
this._fireEvent(val, "DOMMenuItemActive");
}
}
return val;
}
get currentItem() {
return this._currentItem;
@ -951,7 +947,6 @@
else {
this.removeAttribute("searchlabel");
}
return val;
}
get searchLabel() {
@ -964,7 +959,6 @@
*/
set value(val) {
this.setAttribute("value", val);
return val;
}
get value() {
@ -980,8 +974,6 @@
} else {
this.removeAttribute("selected");
}
return val;
}
get selected() {
@ -1007,7 +999,6 @@
} else {
this.removeAttribute("current");
}
return val;
}
get current() {

View File

@ -39,7 +39,7 @@
return this.inputField[property];
},
set(val) {
return (this.inputField[property] = val);
this.inputField[property] = val;
},
});
}
@ -118,7 +118,6 @@
set timeout(val) {
this.setAttribute("timeout", val);
return val;
}
get timeout() {
@ -135,7 +134,6 @@
this.setAttribute("aria-autocomplete", "list");
this._searchButtonIcon.setAttribute("role", "none");
}
return val;
}
get searchButton() {
@ -154,7 +152,6 @@
if (this._timer) {
clearTimeout(this._timer);
}
return val;
}
get value() {
@ -172,7 +169,6 @@
} else {
this.removeAttribute("disabled");
}
return val;
}
get disabled() {

View File

@ -27,7 +27,6 @@
set src(val) {
this._bundle = null;
this.setAttribute("src", val);
return val;
}
get src() {

View File

@ -42,7 +42,6 @@
set handleCtrlTab(val) {
this.setAttribute("handleCtrlTab", val);
return val;
}
get handleCtrlTab() {
@ -72,7 +71,6 @@
tabs.selectedIndex = val;
}
this.setAttribute("selectedIndex", val);
return val;
}
get selectedIndex() {
@ -87,7 +85,6 @@
tabs.selectedItem = val;
}
}
return val;
}
get selectedTab() {
@ -102,7 +99,6 @@
tabpanels.selectedPanel = val;
}
}
return val;
}
get selectedPanel() {
@ -185,7 +181,7 @@
set selectedIndex(val) {
if (val < 0 || val >= this.children.length) {
return val;
return;
}
let panel = this._selectedPanel;
@ -200,7 +196,6 @@
event.initEvent("select", true, true);
this.dispatchEvent(event);
}
return val;
}
get selectedIndex() {
@ -218,7 +213,6 @@
++selectedIndex;
}
this.selectedIndex = selectedIndex;
return val;
}
get selectedPanel() {
@ -404,7 +398,6 @@
set value(val) {
this.setAttribute("value", val);
return val;
}
get value() {
@ -428,8 +421,6 @@
this.removeAttribute("selected");
this.removeAttribute("visuallyselected");
}
return val;
}
set linkedPanel(val) {
@ -511,7 +502,6 @@
break;
}
}
return val;
}
get value() {
@ -549,7 +539,6 @@
this.tabbox.tabpanels.selectedPanel = linkedPanel;
}
}
return val;
}
get selectedIndex() {
@ -568,7 +557,6 @@
// such as -1 if |val| isn't one of our child nodes.
this.selectedIndex = this.getIndexOfItem(val);
}
return val;
}
get selectedItem() {
@ -614,8 +602,6 @@
let evt = new CustomEvent("AriaFocus");
val.dispatchEvent(evt);
}
return val;
}
get ariaFocusedItem() {

View File

@ -300,7 +300,6 @@
set href(val) {
this.setAttribute("href", val);
return val;
}
get href() {

View File

@ -385,7 +385,6 @@
set ordinal(val) {
this.style.MozBoxOrdinalGroup = val;
this.setAttribute("ordinal", val);
return val;
}
get ordinal() {
@ -1040,7 +1039,6 @@
} else {
this.removeAttribute("editable");
}
return val;
}
get editable() {
@ -1051,7 +1049,6 @@
*/
set selType(val) {
this.setAttribute("seltype", val);
return val;
}
get selType() {
@ -1060,9 +1057,8 @@
set currentIndex(val) {
if (this.view) {
return (this.view.selection.currentIndex = val);
this.view.selection.currentIndex = val;
}
return val;
}
get currentIndex() {
@ -1078,7 +1074,6 @@
} else {
this.removeAttribute("keepcurrentinview");
}
return val;
}
get keepCurrentInView() {
@ -1091,7 +1086,6 @@
} else {
this.removeAttribute("enableColumnDrag");
}
return val;
}
get enableColumnDrag() {
@ -1112,7 +1106,6 @@
} else {
this.removeAttribute("disableKeyNavigation");
}
return val;
}
get disableKeyNavigation() {

View File

@ -145,7 +145,7 @@
}
set title(val) {
return (document.title = val);
document.title = val;
}
get title() {
@ -154,7 +154,7 @@
set canAdvance(val) {
this.getButton("next").disabled = !val;
return (this._canAdvance = val);
this._canAdvance = val;
}
get canAdvance() {
@ -163,7 +163,7 @@
set canRewind(val) {
this.getButton("back").disabled = !val;
return (this._canRewind = val);
this._canRewind = val;
}
get canRewind() {
@ -180,7 +180,7 @@
set currentPage(val) {
if (!val) {
return val;
return;
}
this._currentPage = val;
@ -195,8 +195,6 @@
this._advanceFocusToPage(val);
this._fireEvent(val, "pageshow");
return val;
}
get currentPage() {
@ -205,14 +203,12 @@
set pageIndex(val) {
if (val < 0 || val >= this.pageCount) {
return val;
return;
}
var page = this.wizardPages[val];
this._pageStack[this._pageStack.length - 1] = page;
this.currentPage = page;
return val;
}
get pageIndex() {
@ -512,7 +508,6 @@
set next(val) {
this.setAttribute("next", val);
this.parentNode._accessMethod = "random";
return val;
}
}

View File

@ -193,7 +193,6 @@ LinksStorage.prototype = {
set _storedVersion(aValue) {
Services.prefs.setIntPref("browser.newtabpage.storageVersion", aValue);
this.__storedVersion = aValue;
return aValue;
},
/**

View File

@ -491,7 +491,7 @@ Task.Debugging = {
if (!x) {
gCurrentTask = null;
}
return (gMaintainStack = x);
gMaintainStack = x;
},
/**

View File

@ -3051,7 +3051,6 @@ var AddonManagerInternal = {
if (aValue != gAutoUpdateDefault) {
Services.prefs.setBoolPref(PREF_EM_AUTOUPDATE_DEFAULT, aValue);
}
return aValue;
},
get checkCompatibility() {
@ -3067,7 +3066,6 @@ var AddonManagerInternal = {
Services.prefs.clearUserPref(PREF_EM_CHECK_COMPATIBILITY);
}
}
return aValue;
},
get strictCompatibility() {
@ -3079,7 +3077,6 @@ var AddonManagerInternal = {
if (aValue != gStrictCompatibility) {
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, aValue);
}
return aValue;
},
get checkUpdateSecurityDefault() {
@ -3099,7 +3096,6 @@ var AddonManagerInternal = {
Services.prefs.clearUserPref(PREF_EM_CHECK_UPDATE_SECURITY);
}
}
return aValue;
},
get updateEnabled() {
@ -3111,7 +3107,6 @@ var AddonManagerInternal = {
if (aValue != gUpdateEnabled) {
Services.prefs.setBoolPref(PREF_EM_UPDATE_ENABLED, aValue);
}
return aValue;
},
_verifyThirdPartyInstall(browser, url, install, info, source) {

View File

@ -323,7 +323,7 @@ PluginWrapper.prototype = {
}
if (val === previousVal) {
return val;
return;
}
let { tags } = pluginFor(this);
@ -362,8 +362,6 @@ PluginWrapper.prototype = {
"userDisabled",
]);
}
return val;
},
async enable() {

View File

@ -984,7 +984,7 @@ AddonWrapper = class {
}
if (val == addon.applyBackgroundUpdates) {
return val;
return;
}
XPIDatabase.setAddonProperties(addon, {
@ -993,14 +993,12 @@ AddonWrapper = class {
AddonManagerPrivate.callAddonListeners("onPropertyChanged", this, [
"applyBackgroundUpdates",
]);
return val;
}
set syncGUID(val) {
let addon = addonFor(this);
if (addon.syncGUID == val) {
return val;
return;
}
if (addon.inDatabase) {
@ -1008,8 +1006,6 @@ AddonWrapper = class {
}
addon.syncGUID = val;
return val;
}
get install() {

View File

@ -1131,7 +1131,7 @@ MockAddon.prototype = {
set appDisabled(val) {
if (val == this._appDisabled) {
return val;
return;
}
AddonManagerPrivate.callAddonListeners("onPropertyChanged", this, [
@ -1142,8 +1142,6 @@ MockAddon.prototype = {
this._appDisabled = val;
var newActive = this.shouldBeActive;
this._updateActiveState(currentActive, newActive);
return val;
},
get userDisabled() {
@ -1188,7 +1186,7 @@ MockAddon.prototype = {
},
set permissions(val) {
return (this._permissions = val);
this._permissions = val;
},
get applyBackgroundUpdates() {

View File

@ -195,7 +195,7 @@ Object.defineProperty(this, "gUseRealCertChecks", {
return AddonTestUtils.useRealCertChecks;
},
set(val) {
return (AddonTestUtils.useRealCertChecks = val);
AddonTestUtils.useRealCertChecks = val;
},
});
@ -204,7 +204,7 @@ Object.defineProperty(this, "TEST_UNPACKED", {
return AddonTestUtils.testUnpacked;
},
set(val) {
return (AddonTestUtils.testUnpacked = val);
AddonTestUtils.testUnpacked = val;
},
});