Expected 'this' to be used by class method 'extractLoginTokenFromCookies'
57 }
58 }
59
60 private extractLoginTokenFromCookies(headers: Headers): string { 61 const cookies = headers.get("set-cookie") ?? "";
62 const loginToken = cookies
63 .split(";")
Expected 'this' to be used by class method 'extractSessionIdFromCookies'
44 return headers;
45 }
46
47 private extractSessionIdFromCookies(headers: Headers): string { 48 const cookies = headers.get("set-cookie") ?? "";
49 const sessionId = cookies
50 .split(";")
Description
If a class method does not use this
, it can sometimes be made into a static function. If you do convert the method into a static function, instances of the class that call that particular method have to be converted to a static call as well (MyClass.callStaticMethod())
Bad Practice
class Person {
sayHi() {
const greeting = document.createElement("div");
greeting.innerText = "Hello!";
document.appendChild();
}
}
const person = new Person();
person.sayHi();
Recommended
class Person {
static sayHi() {
const greeting = document.createElement("div");
greeting.innerText = "Hello!";
document.appendChild();
}
}
Person.sayHi();