Skip to content

Commit 763b695

Browse files
committed
Bug 1778106 - Move Pocket code to use mjs files, rather than defining sourceType for ESLint. r=thecount
Differential Revision: https://phabricator.services.mozilla.com/D200604
1 parent 5ae4b29 commit 763b695

File tree

9 files changed

+63
-80
lines changed

9 files changed

+63
-80
lines changed

browser/components/pocket/.eslintrc.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ module.exports = {
1111
version: "17.0.2",
1212
},
1313
},
14-
overrides: [
15-
{
16-
files: ["content/**/*.js", "content/**/*.jsx"],
17-
parserOptions: {
18-
sourceType: "module",
19-
},
20-
},
21-
],
2214
rules: {
2315
"react/jsx-uses-react": 2,
2416
"react/jsx-uses-vars": 2,

browser/components/pocket/content/panels/js/home/overlay.js renamed to browser/components/pocket/content/panels/js/home/overlay.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
/* global Handlebars:false */
2-
31
/*
42
HomeOverlay is the view itself and contains all of the methods to manipute the overlay and messaging.
53
It does not contain any logic for saving or communication with the extension or server.
64
*/
75

86
import React from "react";
97
import ReactDOM from "react-dom";
10-
import Home from "../components/Home/Home";
8+
import Home from "../components/Home/Home.jsx";
119

1210
var HomeOverlay = function (options) {
1311
this.inited = false;

browser/components/pocket/content/panels/js/main.bundle.js

Lines changed: 46 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
/******/ "use strict";
33
/******/ var __webpack_modules__ = ({
44

5-
/***/ 299:
6-
/***/ ((__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) => {
5+
/***/ 140:
6+
/***/ ((__unused_webpack___webpack_module__, __unused_webpack___webpack_exports__, __webpack_require__) => {
77

88

99
// EXTERNAL MODULE: ./node_modules/react/index.js
@@ -25,8 +25,9 @@ function Header(props) {
2525
}
2626

2727
/* harmony default export */ const Header_Header = (Header);
28-
;// CONCATENATED MODULE: ./content/panels/js/messages.js
28+
;// CONCATENATED MODULE: ./content/panels/js/messages.mjs
2929
/* global RPMRemoveMessageListener:false, RPMAddMessageListener:false, RPMSendAsyncMessage:false */
30+
3031
var pktPanelMessaging = {
3132
removeMessageListener(messageId, callback) {
3233
RPMRemoveMessageListener(messageId, callback);
@@ -43,41 +44,39 @@ var pktPanelMessaging = {
4344
// and we don't want to close a RPMSendQuery promise loop unexpectedly.
4445
// So instead we setup a response event.
4546
const responseMessageId = `${messageId}_response`;
46-
4747
var responseListener = responsePayload => {
4848
callback(responsePayload);
4949
this.removeMessageListener(responseMessageId, responseListener);
5050
};
5151

5252
this.addMessageListener(responseMessageId, responseListener);
53-
} // Send message
54-
53+
}
5554

55+
// Send message
5656
RPMSendAsyncMessage(messageId, payload);
5757
},
5858

5959
// Click helper to reduce bugs caused by oversight
6060
// from different implementations of similar code.
61-
clickHelper(element, {
62-
source = "",
63-
position
64-
}) {
61+
clickHelper(element, { source = "", position }) {
6562
element?.addEventListener(`click`, event => {
6663
event.preventDefault();
64+
6765
this.sendMessage("PKT_openTabWithUrl", {
6866
url: event.currentTarget.getAttribute(`href`),
6967
source,
70-
position
68+
position,
7169
});
7270
});
7371
},
7472

7573
log() {
7674
RPMSendAsyncMessage("PKT_log", arguments);
77-
}
78-
75+
},
7976
};
77+
8078
/* harmony default export */ const messages = (pktPanelMessaging);
79+
8180
;// CONCATENATED MODULE: ./content/panels/js/components/TelemetryLink/TelemetryLink.jsx
8281
/* This Source Code Form is subject to the terms of the Mozilla Public
8382
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
@@ -390,9 +389,7 @@ function Home(props) {
390389
}
391390

392391
/* harmony default export */ const Home_Home = (Home);
393-
;// CONCATENATED MODULE: ./content/panels/js/home/overlay.js
394-
/* global Handlebars:false */
395-
392+
;// CONCATENATED MODULE: ./content/panels/js/home/overlay.jsx
396393
/*
397394
HomeOverlay is the view itself and contains all of the methods to manipute the overlay and messaging.
398395
It does not contain any logic for saving or communication with the extension or server.
@@ -503,7 +500,7 @@ function Signup(props) {
503500
}
504501

505502
/* harmony default export */ const Signup_Signup = (Signup);
506-
;// CONCATENATED MODULE: ./content/panels/js/signup/overlay.js
503+
;// CONCATENATED MODULE: ./content/panels/js/signup/overlay.jsx
507504
/*
508505
SignupOverlay is the view itself and contains all of the methods to manipute the overlay and messaging.
509506
It does not contain any logic for saving or communication with the extension or server.
@@ -886,7 +883,7 @@ function Saved(props) {
886883
}
887884

888885
/* harmony default export */ const Saved_Saved = (Saved);
889-
;// CONCATENATED MODULE: ./content/panels/js/saved/overlay.js
886+
;// CONCATENATED MODULE: ./content/panels/js/saved/overlay.jsx
890887
/*
891888
SavedOverlay is the view itself and contains all of the methods to manipute the overlay and messaging.
892889
It does not contain any logic for saving or communication with the extension or server.
@@ -931,7 +928,7 @@ SavedOverlay.prototype = {
931928

932929
};
933930
/* harmony default export */ const saved_overlay = (SavedOverlay);
934-
;// CONCATENATED MODULE: ./content/panels/js/style-guide/overlay.js
931+
;// CONCATENATED MODULE: ./content/panels/js/style-guide/overlay.jsx
935932

936933

937934

@@ -1042,18 +1039,18 @@ StyleGuideOverlay.prototype = {
10421039

10431040
};
10441041
/* harmony default export */ const style_guide_overlay = (StyleGuideOverlay);
1045-
;// CONCATENATED MODULE: ./content/panels/js/main.js
1042+
;// CONCATENATED MODULE: ./content/panels/js/main.mjs
10461043
/* This Source Code Form is subject to the terms of the Mozilla Public
10471044
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
10481045
* You can obtain one at http://mozilla.org/MPL/2.0/. */
1049-
10501046
/* global RPMGetStringPref:false */
10511047

10521048

10531049

10541050

10551051

10561052

1053+
10571054
var PKT_PANEL = function () {};
10581055

10591056
PKT_PANEL.prototype = {
@@ -1078,39 +1075,37 @@ PKT_PANEL.prototype = {
10781075
},
10791076

10801077
setupObservers() {
1081-
this.setupMutationObserver(); // Mutation observer isn't always enough for fast loading, static pages.
1078+
this.setupMutationObserver();
1079+
// Mutation observer isn't always enough for fast loading, static pages.
10821080
// Sometimes the mutation observer fires before the page is totally visible.
10831081
// In this case, the resize tries to fire with 0 height,
10841082
// and because it's a static page, it only does one mutation.
10851083
// So in this case, we have a backup intersection observer that fires when
10861084
// the page is first visible, and thus, the page is going to guarantee a height.
1087-
10881085
this.setupIntersectionObserver();
10891086
},
10901087

10911088
init() {
10921089
if (this.inited) {
10931090
return;
10941091
}
1095-
10961092
this.setupObservers();
10971093
this.inited = true;
10981094
},
10991095

11001096
resizeParent() {
11011097
let clientHeight = document.body.clientHeight;
1102-
11031098
if (this.overlay.tagsDropdownOpen) {
11041099
clientHeight = Math.max(clientHeight, 252);
1105-
} // We can ignore 0 height here.
1100+
}
1101+
1102+
// We can ignore 0 height here.
11061103
// We rely on intersection observer to do the
11071104
// resize for 0 height loads.
1108-
1109-
11101105
if (clientHeight) {
11111106
messages.sendMessage("PKT_resizePanel", {
11121107
width: document.body.clientWidth,
1113-
height: clientHeight
1108+
height: clientHeight,
11141109
});
11151110
}
11161111
},
@@ -1127,46 +1122,44 @@ PKT_PANEL.prototype = {
11271122

11281123
setupMutationObserver() {
11291124
// Select the node that will be observed for mutations
1130-
const targetNode = document.body; // Options for the observer (which mutations to observe)
1125+
const targetNode = document.body;
11311126

1132-
const config = {
1133-
attributes: false,
1134-
childList: true,
1135-
subtree: true
1136-
}; // Callback function to execute when mutations are observed
1127+
// Options for the observer (which mutations to observe)
1128+
const config = { attributes: false, childList: true, subtree: true };
11371129

1130+
// Callback function to execute when mutations are observed
11381131
const callback = (mutationList, observer) => {
11391132
mutationList.forEach(mutation => {
11401133
switch (mutation.type) {
1141-
case "childList":
1142-
{
1143-
/* One or more children have been added to and/or removed
1144-
from the tree.
1145-
(See mutation.addedNodes and mutation.removedNodes.) */
1146-
this.resizeParent();
1147-
break;
1148-
}
1134+
case "childList": {
1135+
/* One or more children have been added to and/or removed
1136+
from the tree.
1137+
(See mutation.addedNodes and mutation.removedNodes.) */
1138+
this.resizeParent();
1139+
break;
1140+
}
11491141
}
11501142
});
1151-
}; // Create an observer instance linked to the callback function
1143+
};
11521144

1145+
// Create an observer instance linked to the callback function
1146+
const observer = new MutationObserver(callback);
11531147

1154-
const observer = new MutationObserver(callback); // Start observing the target node for configured mutations
1155-
1148+
// Start observing the target node for configured mutations
11561149
observer.observe(targetNode, config);
11571150
},
11581151

11591152
create() {
1160-
const pockethost = RPMGetStringPref("extensions.pocket.site") || "getpocket.com";
1161-
this.overlay.create({
1162-
pockethost
1163-
});
1164-
}
1165-
1153+
const pockethost =
1154+
RPMGetStringPref("extensions.pocket.site") || "getpocket.com";
1155+
this.overlay.create({ pockethost });
1156+
},
11661157
};
1158+
11671159
window.PKT_PANEL = PKT_PANEL;
11681160
window.pktPanelMessaging = messages;
11691161

1162+
11701163
/***/ })
11711164

11721165
/******/ });
@@ -1294,7 +1287,7 @@ window.pktPanelMessaging = messages;
12941287
/******/ // startup
12951288
/******/ // Load entry module and return exports
12961289
/******/ // This entry module depends on other loaded chunks and execution need to be delayed
1297-
/******/ var __webpack_exports__ = __webpack_require__.O(undefined, [736], () => (__webpack_require__(299)))
1290+
/******/ var __webpack_exports__ = __webpack_require__.O(undefined, [736], () => (__webpack_require__(140)))
12981291
/******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
12991292
/******/
13001293
/******/ })()

browser/components/pocket/content/panels/js/main.js renamed to browser/components/pocket/content/panels/js/main.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
* You can obtain one at http://mozilla.org/MPL/2.0/. */
44
/* global RPMGetStringPref:false */
55

6-
import HomeOverlay from "./home/overlay.js";
7-
import SignupOverlay from "./signup/overlay.js";
8-
import SavedOverlay from "./saved/overlay.js";
9-
import StyleGuideOverlay from "./style-guide/overlay.js";
10-
import pktPanelMessaging from "./messages.js";
6+
import HomeOverlay from "./home/overlay.jsx";
7+
import SignupOverlay from "./signup/overlay.jsx";
8+
import SavedOverlay from "./saved/overlay.jsx";
9+
import StyleGuideOverlay from "./style-guide/overlay.jsx";
10+
import pktPanelMessaging from "./messages.mjs";
1111

1212
var PKT_PANEL = function () {};
1313

browser/components/pocket/content/panels/js/saved/overlay.js renamed to browser/components/pocket/content/panels/js/saved/overlay.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ It does not contain any logic for saving or communication with the extension or
55

66
import React from "react";
77
import ReactDOM from "react-dom";
8-
import Saved from "../components/Saved/Saved";
8+
import Saved from "../components/Saved/Saved.jsx";
99

1010
var SavedOverlay = function (options) {
1111
this.inited = false;

browser/components/pocket/content/panels/js/signup/overlay.js renamed to browser/components/pocket/content/panels/js/signup/overlay.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ It does not contain any logic for saving or communication with the extension or
55

66
import React from "react";
77
import ReactDOM from "react-dom";
8-
import pktPanelMessaging from "../messages.js";
9-
import Signup from "../components/Signup/Signup";
8+
import pktPanelMessaging from "../messages.mjs";
9+
import Signup from "../components/Signup/Signup.jsx";
1010

1111
var SignupOverlay = function (options) {
1212
this.inited = false;

browser/components/pocket/content/panels/js/style-guide/overlay.js renamed to browser/components/pocket/content/panels/js/style-guide/overlay.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from "react";
22
import ReactDOM from "react-dom";
3-
import Header from "../components/Header/Header";
4-
import ArticleList from "../components/ArticleList/ArticleList";
5-
import Button from "../components/Button/Button";
6-
import PopularTopics from "../components/PopularTopics/PopularTopics";
7-
import TagPicker from "../components/TagPicker/TagPicker";
3+
import Header from "../components/Header/Header.jsx";
4+
import ArticleList from "../components/ArticleList/ArticleList.jsx";
5+
import Button from "../components/Button/Button.jsx";
6+
import PopularTopics from "../components/PopularTopics/PopularTopics.jsx";
7+
import TagPicker from "../components/TagPicker/TagPicker.jsx";
88

99
var StyleGuideOverlay = function (options) {};
1010

browser/components/pocket/webpack.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
module.exports = {
66
mode: "production",
77
entry: {
8-
main: "./content/panels/js/main.js",
8+
main: "./content/panels/js/main.mjs",
99
},
1010
output: {
1111
filename: "[name].bundle.js",
@@ -14,7 +14,7 @@ module.exports = {
1414
module: {
1515
rules: [
1616
{
17-
test: /\.jsx?$/,
17+
test: /\.jsx$/,
1818
exclude: /node_modules/,
1919
loader: "babel-loader",
2020
options: {
@@ -24,7 +24,7 @@ module.exports = {
2424
],
2525
},
2626
resolve: {
27-
extensions: [".js", ".jsx"],
27+
extensions: [".mjs", ".jsx"],
2828
},
2929
optimization: {
3030
minimize: false,

0 commit comments

Comments
 (0)