refactor(lint): replace self-equals-this code with arrow functions

This commit is contained in:
Max Baumann 2020-12-24 11:59:24 +01:00
parent cba0fc0a87
commit 0e32042634
No known key found for this signature in database
GPG key ID: 82EEA14C1523D1BB
3 changed files with 11 additions and 17 deletions

View file

@ -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: {

View file

@ -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);
};

View file

@ -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
})]
};