Skip to content

Commit fa86f51

Browse files
committed
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
1 parent 7cb64f0 commit fa86f51

File tree

13 files changed

+42
-32
lines changed

13 files changed

+42
-32
lines changed

browser/components/aboutwelcome/.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ module.exports = {
124124
"consistent-this": ["error", "use-bind"],
125125
eqeqeq: "error",
126126
"func-name-matching": "error",
127-
"getter-return": "error",
128127
"guard-for-in": "error",
129128
"max-nested-callbacks": ["error", 4],
130129
"max-params": ["error", 6],

browser/components/asrouter/.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ module.exports = {
9494
"consistent-this": ["error", "use-bind"],
9595
eqeqeq: "error",
9696
"func-name-matching": "error",
97-
"getter-return": "error",
9897
"guard-for-in": "error",
9998
"max-nested-callbacks": ["error", 4],
10099
"max-params": ["error", 6],

browser/components/newtab/.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ module.exports = {
123123
"consistent-this": ["error", "use-bind"],
124124
eqeqeq: "error",
125125
"func-name-matching": "error",
126-
"getter-return": "error",
127126
"guard-for-in": "error",
128127
"max-nested-callbacks": ["error", 4],
129128
"max-params": ["error", 6],

browser/components/reportbrokensite/test/browser/head.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,11 +558,17 @@ class MenuHelper {
558558
return true;
559559
}
560560

561-
get reportBrokenSite() {}
561+
get reportBrokenSite() {
562+
throw new Error("Should be defined in derived class");
563+
}
562564

563-
get reportSiteIssue() {}
565+
get reportSiteIssue() {
566+
throw new Error("Should be defined in derived class");
567+
}
564568

565-
get popup() {}
569+
get popup() {
570+
throw new Error("Should be defined in derived class");
571+
}
566572

567573
get opened() {
568574
return this.popup?.hasAttribute("panelopen");

devtools/server/devtools-server-connection.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,6 @@ DevToolsServerConnection.prototype = {
7373
return this._prefix;
7474
},
7575

76-
/**
77-
* For a DevToolsServerConnection used in content processes,
78-
* returns the prefix of the connection it originates from, from the parent process.
79-
*/
80-
get parentPrefix() {
81-
this.prefix.replace(/child\d+\//, "");
82-
},
83-
8476
_transport: null,
8577
get transport() {
8678
return this._transport;

dom/promise/tests/unit/test_promise_job_across_sandbox.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ add_task(async function testThenableJobAccessError() {
175175
sandbox.thenable = {
176176
get then() {
177177
accessed = true;
178+
return undefined;
178179
},
179180
};
180181

js/xpconnect/tests/chrome/test_xrayToJS.xhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
800800
checkThrows(function() { trickyObject.hasOwnProperty = 33; }, /shadow/,
801801
"Should reject shadowing of pre-existing inherited properties over Xrays");
802802

803-
checkThrows(function() { Object.defineProperty(trickyObject, 'rejectedProp', { get() {}}); },
803+
checkThrows(function() { Object.defineProperty(trickyObject, 'rejectedProp', { get() { return undefined; }}); },
804804
/accessor property/, "Should reject accessor property definition");
805805
}
806806

toolkit/components/extensions/ExtensionParent.sys.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,7 @@ class ExtensionPageContextParent extends ProxyContextParent {
716716
if (this.viewType !== "background") {
717717
return this.appWindow;
718718
}
719+
return undefined;
719720
}
720721

721722
get tabId() {
@@ -724,6 +725,7 @@ class ExtensionPageContextParent extends ProxyContextParent {
724725
if (data.tabId >= 0) {
725726
return data.tabId;
726727
}
728+
return undefined;
727729
}
728730

729731
unload() {

toolkit/components/extensions/parent/ext-downloads.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ class DownloadItem {
212212
let timeLeftInSeconds = sizeLeft / this.download.speed;
213213
return new Date(Date.now() + timeLeftInSeconds * 1000);
214214
}
215+
return undefined;
215216
}
216217

217218
get state() {

toolkit/components/extensions/parent/ext-tabs-base.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,16 @@ class TabBase {
199199
}
200200

201201
/**
202-
* @property {string | null} url
202+
* @property {string | undefined} url
203203
* Returns the current URL of this tab if the extension has permission
204-
* to read it, or null otherwise.
204+
* to read it, or undefined otherwise.
205205
* @readonly
206206
*/
207207
get url() {
208208
if (this.hasTabPermission) {
209209
return this._url;
210210
}
211+
return undefined;
211212
}
212213

213214
/**
@@ -230,15 +231,16 @@ class TabBase {
230231
}
231232

232233
/**
233-
* @property {nsIURI | null} title
234+
* @property {nsIURI | undefined} title
234235
* Returns the current title of this tab if the extension has permission
235-
* to read it, or null otherwise.
236+
* to read it, or undefined otherwise.
236237
* @readonly
237238
*/
238239
get title() {
239240
if (this.hasTabPermission) {
240241
return this._title;
241242
}
243+
return undefined;
242244
}
243245

244246
/**
@@ -253,15 +255,16 @@ class TabBase {
253255
}
254256

255257
/**
256-
* @property {nsIURI | null} faviconUrl
258+
* @property {nsIURI | undefined} faviconUrl
257259
* Returns the current faviron URL of this tab if the extension has permission
258-
* to read it, or null otherwise.
260+
* to read it, or undefined otherwise.
259261
* @readonly
260262
*/
261263
get favIconUrl() {
262264
if (this.hasTabPermission) {
263265
return this._favIconUrl;
264266
}
267+
return undefined;
265268
}
266269

267270
/**
@@ -1165,9 +1168,9 @@ class WindowBase {
11651168
}
11661169

11671170
/**
1168-
* @property {nsIURI | null} title
1171+
* @property {nsIURI | undefined} title
11691172
* Returns the current title of this window if the extension has permission
1170-
* to read it, or null otherwise.
1173+
* to read it, or undefined otherwise.
11711174
* @readonly
11721175
*/
11731176
get title() {
@@ -1176,6 +1179,7 @@ class WindowBase {
11761179
if (this.activeTab && this.activeTab.hasTabPermission) {
11771180
return this._title;
11781181
}
1182+
return undefined;
11791183
}
11801184

11811185
// The JSDoc validator does not support @returns tags in abstract functions or

toolkit/components/extensions/test/xpcshell/test_ext_api_events_listener_calls_exceptions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ add_task(async function test_api_listener_call_exception() {
141141
// catch with a failure if we are running the extension code as a side effect
142142
// of logging the error to the console service.
143143
const nonError = {
144+
// eslint-disable-next-line getter-return
144145
get message() {
145146
browser.test.fail(`Unexpected extension code executed`);
146147
},

toolkit/mozapps/extensions/internal/SitePermsAddonProvider.sys.mjs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,20 +148,30 @@ class SitePermsAddonWrapper {
148148
});
149149
}
150150

151-
get creator() {}
151+
get creator() {
152+
return undefined;
153+
}
152154

153-
get homepageURL() {}
155+
get homepageURL() {
156+
return undefined;
157+
}
154158

155-
get description() {}
159+
get description() {
160+
return undefined;
161+
}
156162

157-
get fullDescription() {}
163+
get fullDescription() {
164+
return undefined;
165+
}
158166

159167
get version() {
160168
// We consider the previous implementation attempt (signed addons) to be the initial version,
161169
// hence the 2.0 for this approach.
162170
return "2.0";
163171
}
164-
get updateDate() {}
172+
get updateDate() {
173+
return undefined;
174+
}
165175

166176
get isActive() {
167177
return true;

tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,6 @@ module.exports = {
165165
// No credentials submitted with fetch calls
166166
"fetch-options/no-fetch-credentials": "off",
167167

168-
// XXX This rule line should be removed to enable it. See bug 1487642.
169-
// Enforce return statements in getters
170-
"getter-return": "off",
171-
172168
// Maximum depth callbacks can be nested.
173169
"max-nested-callbacks": ["error", 10],
174170

0 commit comments

Comments
 (0)