-
Notifications
You must be signed in to change notification settings - Fork 338
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
Organize utils.ts
into folder, update imports
#1332
Organize utils.ts
into folder, update imports
#1332
Conversation
…lemmy-ui into breakout-role-utils
Wow, I totally ruined this branch. Somehow I pulled in a bunch of arbitrary changes, need to sort this out. |
Resolved it. Please squash on merge when/if possible. |
import { UserService } from "../../services"; | ||
import { amAdmin } from "./am-admin"; | ||
|
||
export function canCreateCommunity( |
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.
If we're using a single function, a default export may be better. Same for other similar files.
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.
I’m not sure I understand. 😅
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.
I meant default export lol. No idea where subreddit came from.
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.
LGTM, thanks! There's still a check that's failing lint.
Not sure why CI is failing, but I'd love to get this merged and get started on the second pass. 🙌 |
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.
The only change I would make (which I messed up saying earlier) would be to use default exports for single-function modules. E.g., for can-share.ts
,
export default function canShare() {
return isBrowser() && !!navigator.canShare;
}
instead of
export function canShare() {
return isBrowser() && !!navigator.canShare;
}
@SleeplessOne1917 I'm planning on making those changes ASAP. Totally slipped my mind! |
Just need to fix the imports later tonight and we'll be good to go! Will comment and tag reviewers when it's ready. Thanks for your patience. |
I've found that a common pattern is to set up an import {
amAdmin,
amCommunityCreator,
amMod,
canAdmin,
canMod,
isAdmin,
isBanned,
isMod,
} from "@utils/roles"; Especially if we also set up https://www.typescriptlang.org/tsconfig#paths Just a convention though, I also understand the desire to be as explicit as possible and not make imports at all mysterious. Also is this PR re-writing any utils, or just organizing them? If it's just organizing them, I think it would be good to make that super clear in the PR description/title, so that it can be more easily reviewed without worrying if it's breaking anything. |
I second this. |
Just organizing for now. I'll update the PR title!
Ooh, I like this. |
utils.ts
into folder, update importsutils.ts
into folder, update imports
@jsit @SleeplessOne1917 Would you mind taking a look at my changes? For some reason, I'm getting |
@jsit @SleeplessOne1917 @dessalines Upon adding TSConfigPathsWebpackPlugin, we're good to go! Let me know if you'd like any other changes. This is ready for final review. |
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.
Looks good, thanks!
You're welcome! Immediately after we merge this, I'll get started on the second pass which should completely eliminate our |
Thanks @alectrocute! Is adding this extra dependency necessary? I wonder if it would be cleaner just to manually do |
Any idea how to do this without the dependency? It would definitely be cleaner to do it manually, but I'm unsure how at the moment. |
Hi Lemdevs!
This is my first milestone of refactoring the
utils.ts
file into a folder with logical structure:Next PR will expand upon this, adding more folders as necessary. The finish line isn't yet in sight, but I'm confident I can finish the entire refactor/tidying project.
utils.ts
can be a thing of the past soon. 😄Thanks so much!