-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement getWorkAdult #87
base: main
Are you sure you want to change the base?
Conversation
genuinly i don't know why all those commits come with the PR |
@@ -191,6 +191,11 @@ export const getWorkLocked = ($workPage: WorkPage) => { | |||
return !!$workPage("#signin > .heading").text(); | |||
}; | |||
|
|||
export const getWorkAdult = ($workPage: WorkPage): boolean => { | |||
const adultCategories: WorkRatings[] = [WorkRatings.EXPLICIT, WorkRatings.MATURE, WorkRatings.NOT_RATED]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is a constant, we should define it outside this function like this:
const ADULT_CATEGORIES: WorkRatings[] = [WorkRatings.EXPLICIT, WorkRatings.MATURE, WorkRatings.NOT_RATED];
export const getWorkAdult = ($workPage: WorkPage): boolean => {
// rest of the code
see https://google.github.io/styleguide/tsguide.html#identifiers-constants (but it's a common convention)
@@ -191,6 +191,11 @@ export const getWorkLocked = ($workPage: WorkPage) => { | |||
return !!$workPage("#signin > .heading").text(); | |||
}; | |||
|
|||
export const getWorkAdult = ($workPage: WorkPage): boolean => { | |||
const adultCategories: WorkRatings[] = [WorkRatings.EXPLICIT, WorkRatings.MATURE, WorkRatings.NOT_RATED]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I just found out about this: https://mkosir.github.io/typescript-style-guide/#type-safe-constants-with-satisfies
Apparently the best way of declaring this constant would be:
const ADULT_CATEGORIES = [
WorkRatings.EXPLICIT,
WorkRatings.MATURE,
WorkRatings.NOT_RATED
] as const satisfies ReadonlyArray<WorkRatings>;
this would give the most correct typing (feel free to ask if you want to understand more).
I'd be ok with keeping it const ADULT_CATEGORIES: WorkRatings[]
, but since you're changing it let's try the new one?
Solves a todo. getWorkAdult implemented by checking if the work is rated NR, M, or E.
Had to modify a test because the test case was wrong.