Skip to content
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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

darthnithin
Copy link
Contributor

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.

@darthnithin
Copy link
Contributor Author

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];

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];

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants