Bug 1881265 - Enable ESLint recommended rule getter-return. r=mossop,extension-reviewers,devtools-reviewers,omc-reviewers,nchevobbe,aminomancer,robwu

Differential Revision: https://phabricator.services.mozilla.com/D202318
This commit is contained in:
Mark Banner 2024-02-26 11:35:40 +00:00
parent 7cb64f026e
commit fa86f5170e
13 changed files with 42 additions and 32 deletions

View File

@ -124,7 +124,6 @@ module.exports = {
"consistent-this": ["error", "use-bind"],
eqeqeq: "error",
"func-name-matching": "error",
"getter-return": "error",
"guard-for-in": "error",
"max-nested-callbacks": ["error", 4],
"max-params": ["error", 6],

View File

@ -94,7 +94,6 @@ module.exports = {
"consistent-this": ["error", "use-bind"],
eqeqeq: "error",
"func-name-matching": "error",
"getter-return": "error",
"guard-for-in": "error",
"max-nested-callbacks": ["error", 4],
"max-params": ["error", 6],

View File

@ -123,7 +123,6 @@ module.exports = {
"consistent-this": ["error", "use-bind"],
eqeqeq: "error",
"func-name-matching": "error",
"getter-return": "error",
"guard-for-in": "error",
"max-nested-callbacks": ["error", 4],
"max-params": ["error", 6],

View File

@ -558,11 +558,17 @@ class MenuHelper {
return true;
}
get reportBrokenSite() {}
get reportBrokenSite() {
throw new Error("Should be defined in derived class");
}
get reportSiteIssue() {}
get reportSiteIssue() {
throw new Error("Should be defined in derived class");
}
get popup() {}
get popup() {
throw new Error("Should be defined in derived class");
}
get opened() {
return this.popup?.hasAttribute("panelopen");

View File

@ -73,14 +73,6 @@ DevToolsServerConnection.prototype = {
return this._prefix;
},
/**
* For a DevToolsServerConnection used in content processes,
* returns the prefix of the connection it originates from, from the parent process.
*/
get parentPrefix() {
this.prefix.replace(/child\d+\//, "");
},
_transport: null,
get transport() {
return this._transport;

View File

@ -175,6 +175,7 @@ add_task(async function testThenableJobAccessError() {
sandbox.thenable = {
get then() {
accessed = true;
return undefined;
},
};

View File

@ -800,7 +800,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
checkThrows(function() { trickyObject.hasOwnProperty = 33; }, /shadow/,
"Should reject shadowing of pre-existing inherited properties over Xrays");
checkThrows(function() { Object.defineProperty(trickyObject, 'rejectedProp', { get() {}}); },
checkThrows(function() { Object.defineProperty(trickyObject, 'rejectedProp', { get() { return undefined; }}); },
/accessor property/, "Should reject accessor property definition");
}

View File

@ -716,6 +716,7 @@ class ExtensionPageContextParent extends ProxyContextParent {
if (this.viewType !== "background") {
return this.appWindow;
}
return undefined;
}
get tabId() {
@ -724,6 +725,7 @@ class ExtensionPageContextParent extends ProxyContextParent {
if (data.tabId >= 0) {
return data.tabId;
}
return undefined;
}
unload() {

View File

@ -212,6 +212,7 @@ class DownloadItem {
let timeLeftInSeconds = sizeLeft / this.download.speed;
return new Date(Date.now() + timeLeftInSeconds * 1000);
}
return undefined;
}
get state() {

View File

@ -199,15 +199,16 @@ class TabBase {
}
/**
* @property {string | null} url
* @property {string | undefined} url
* Returns the current URL of this tab if the extension has permission
* to read it, or null otherwise.
* to read it, or undefined otherwise.
* @readonly
*/
get url() {
if (this.hasTabPermission) {
return this._url;
}
return undefined;
}
/**
@ -230,15 +231,16 @@ class TabBase {
}
/**
* @property {nsIURI | null} title
* @property {nsIURI | undefined} title
* Returns the current title of this tab if the extension has permission
* to read it, or null otherwise.
* to read it, or undefined otherwise.
* @readonly
*/
get title() {
if (this.hasTabPermission) {
return this._title;
}
return undefined;
}
/**
@ -253,15 +255,16 @@ class TabBase {
}
/**
* @property {nsIURI | null} faviconUrl
* @property {nsIURI | undefined} faviconUrl
* Returns the current faviron URL of this tab if the extension has permission
* to read it, or null otherwise.
* to read it, or undefined otherwise.
* @readonly
*/
get favIconUrl() {
if (this.hasTabPermission) {
return this._favIconUrl;
}
return undefined;
}
/**
@ -1165,9 +1168,9 @@ class WindowBase {
}
/**
* @property {nsIURI | null} title
* @property {nsIURI | undefined} title
* Returns the current title of this window if the extension has permission
* to read it, or null otherwise.
* to read it, or undefined otherwise.
* @readonly
*/
get title() {
@ -1176,6 +1179,7 @@ class WindowBase {
if (this.activeTab && this.activeTab.hasTabPermission) {
return this._title;
}
return undefined;
}
// The JSDoc validator does not support @returns tags in abstract functions or

View File

@ -141,6 +141,7 @@ add_task(async function test_api_listener_call_exception() {
// catch with a failure if we are running the extension code as a side effect
// of logging the error to the console service.
const nonError = {
// eslint-disable-next-line getter-return
get message() {
browser.test.fail(`Unexpected extension code executed`);
},

View File

@ -148,20 +148,30 @@ class SitePermsAddonWrapper {
});
}
get creator() {}
get creator() {
return undefined;
}
get homepageURL() {}
get homepageURL() {
return undefined;
}
get description() {}
get description() {
return undefined;
}
get fullDescription() {}
get fullDescription() {
return undefined;
}
get version() {
// We consider the previous implementation attempt (signed addons) to be the initial version,
// hence the 2.0 for this approach.
return "2.0";
}
get updateDate() {}
get updateDate() {
return undefined;
}
get isActive() {
return true;

View File

@ -165,10 +165,6 @@ module.exports = {
// No credentials submitted with fetch calls
"fetch-options/no-fetch-credentials": "off",
// XXX This rule line should be removed to enable it. See bug 1487642.
// Enforce return statements in getters
"getter-return": "off",
// Maximum depth callbacks can be nested.
"max-nested-callbacks": ["error", 10],