aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2020-12-24 12:32:16 -0500
committerGitHub <[email protected]>2020-12-24 12:32:16 -0500
commitd81229a157d579ea7975c2da3371d3f62f51bd92 (patch)
tree32b7c7716186041f54e3c39be756b3f65b1da00e
parentcba0fc0a87eb48ad0541d68cd6142794505653ed (diff)
parent0e320426345c1c7ff4bcd5ae4c391bd5f0a008fd (diff)
downloadSponsorBlock-d81229a157d579ea7975c2da3371d3f62f51bd92.tar.gz
SponsorBlock-d81229a157d579ea7975c2da3371d3f62f51bd92.zip
Merge pull request #599 from FoseFx/fosefx-no-this-alias
Replace self-equals-this code with arrow functions
-rw-r--r--.eslintrc.js2
-rw-r--r--src/components/SkipNoticeComponent.tsx7
-rw-r--r--src/utils.ts19
3 files changed, 11 insertions, 17 deletions
diff --git a/.eslintrc.js b/.eslintrc.js
index 3ea331c5..64b64a12 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -20,10 +20,8 @@ module.exports = {
plugins: ["react", "@typescript-eslint"],
rules: {
// TODO: Remove warn rules when not needed anymore
- "@typescript-eslint/no-this-alias": "warn",
"no-self-assign": "off",
"@typescript-eslint/no-empty-interface": "off",
- "@typescript-eslint/ban-types": "warn",
},
settings: {
react: {
diff --git a/src/components/SkipNoticeComponent.tsx b/src/components/SkipNoticeComponent.tsx
index cd7b8205..aa75a587 100644
--- a/src/components/SkipNoticeComponent.tsx
+++ b/src/components/SkipNoticeComponent.tsx
@@ -444,10 +444,9 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
}
getUnskippedModeInfo(index: number, buttonText: string): SkipNoticeState {
- const self = this;
- const maxCountdownTime = function() {
- const sponsorTime = self.segments[index];
- const duration = Math.round((sponsorTime.segment[1] - self.contentContainer().v.currentTime) * (1 / self.contentContainer().v.playbackRate));
+ const maxCountdownTime = () => {
+ const sponsorTime = this.segments[index];
+ const duration = Math.round((sponsorTime.segment[1] - this.contentContainer().v.currentTime) * (1 / this.contentContainer().v.playbackRate));
return Math.max(duration, 4);
};
diff --git a/src/utils.ts b/src/utils.ts
index c15d3ff6..2331b2d4 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -54,18 +54,16 @@ class Utils {
setupExtraSitePermissions(callback: (granted: boolean) => void): void {
// Request permission
let permissions = ["declarativeContent"];
- if (this.isFirefox()) permissions = [];
-
- const self = this;
+ if (this.isFirefox()) permissions = [];
chrome.permissions.request({
origins: this.getInvidiousInstancesRegex(),
permissions: permissions
- }, async function (granted) {
+ }, async (granted) => {
if (granted) {
- self.setupExtraSiteContentScripts();
+ this.setupExtraSiteContentScripts();
} else {
- self.removeExtraSiteRegistration();
+ this.removeExtraSiteRegistration();
}
callback(granted);
@@ -80,7 +78,6 @@ class Utils {
* For now, it is just SB.config.invidiousInstances.
*/
setupExtraSiteContentScripts(): void {
- const self = this;
if (this.isFirefox()) {
const firefoxJS = [];
@@ -107,9 +104,9 @@ class Utils {
chrome.runtime.sendMessage(registration);
}
} else {
- chrome.declarativeContent.onPageChanged.removeRules(["invidious"], function() {
+ chrome.declarativeContent.onPageChanged.removeRules(["invidious"], () => {
const conditions = [];
- for (const regex of self.getInvidiousInstancesRegex()) {
+ for (const regex of this.getInvidiousInstancesRegex()) {
conditions.push(new chrome.declarativeContent.PageStateMatcher({
pageUrl: { urlMatches: regex }
}));
@@ -121,8 +118,8 @@ class Utils {
conditions,
actions: [new chrome.declarativeContent.RequestContentScript({
allFrames: true,
- js: self.js,
- css: self.css
+ js: this.js,
+ css: this.css
})]
};