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

Create code of conduct #92

Open
OlegSuperBro opened this issue Oct 28, 2024 · 8 comments
Open

Create code of conduct #92

OlegSuperBro opened this issue Oct 28, 2024 · 8 comments
Assignees
Labels
🖥️ dev Make developers life easier or harder ❔ priority: unknown ✨ enhancement New feature or request ⚠️ discussion Discuss how to fix or implement something

Comments

@OlegSuperBro
Copy link
Collaborator

We need some sort of instruction, how to write code to make repository code more consistent. What are the rules we need to define?

IMPORTANT if no responses are written in a week, i'll write it by myself :)

@OlegSuperBro OlegSuperBro added ✨ enhancement New feature or request ❔ priority: unknown 🖥️ dev Make developers life easier or harder ⚠️ discussion Discuss how to fix or implement something labels Oct 28, 2024
@froggy-jpg
Copy link
Collaborator

do we really need this at the moment? i fear this might scare away potential contributors
although i think we would need it at some point of course, just not right now

@OlegSuperBro
Copy link
Collaborator Author

OlegSuperBro commented Oct 28, 2024

that's actually a reason why i think we should create it now. Soon we will work on code refactoring (as @ClaireRoush planning), which means a lot of rewritten code. If we don't define rules for code before this refactoring, we will have to make another refactoring.
I don't mean to scare new contributors (or existing ones). I think in theory it can attract new contributors, because code will be more consistent and simple to understand.
Also i don't want to make code of conduct too strict, so i think it should just define how code should function. For example:

  • All components should not get any data except contexts and props
  • All pages should not have any fetch calls except from service
  • services should return only responses
  • ...

@froggy-jpg
Copy link
Collaborator

okay, sounds good to me then :)
i have no objections, you can start writing it 🐸

@OlegSuperBro
Copy link
Collaborator Author

OlegSuperBro commented Oct 29, 2024

well, i still have no idea what are right and what is wrong to do in code, so i hope to get your suggestions
My current suggestions are:

For both:

  • All configurable values (save paths, amount of object for requests etc) should be written in .env or .env.local file
  • .env should have all keys that used in code. If value is secret, key should be defined without value.
  • Usage of "any" type should be escaped as much as possible
  • function and variable naming should be in camelCase, constants in UPPER_CASE

For backend:

  • All endpoints should check if objects exists (users, posts, comments etc.). Return 404 response if not found
  • If user is not authorized (logged in) but endpoint requires authorization 401 should be returned with error message "Not authorized"
  • If user can't make a requests due permissions (delete other user post for example) 403 should be returned with error message "Not enough permissions"
  • All GET responses should return status 200 if request is successful
  • All POST responses should return status 200 or 201 with new object if successful
  • Database should save universal info. For example: saving image base name instead full/relative path on server
  • All endpoints that requires authorization should make permission checks, no matter if it's accessed on frontend or not

For frontend:

  • All components/pages should use defined types, instead unknown objects
  • All services should return defined type or nothing
  • All react files should not have any raw fetch calls
  • Only pages should gather information fro page
  • Components should be built only by data from props and should not make any API calls
  • If component have an button that makes api call via function, function should be provided by parent with prop or context
  • Pages should contain only components, not other pages
  • All base urls should be readed from .env file (user profile pictures, static, media files, etc.)

For now it's everything i think will make development easier. I'm not sure how comfortable is this and what should be for styles (i made 0 changes in css files lol), but still, i think at least those rules will make further development and scaling easier

@froggy-jpg
Copy link
Collaborator

i have no clue what any of this means to be honest xD
so it isnt really my place to dictate the rules

@ClaireRoush
Copy link
Owner

Yeah, i fully agree with all above, this example of cude of conduct i amazin. How appropriate would it be to add here rules for folder structures from #90 too?

@OlegSuperBro
Copy link
Collaborator Author

Yeah, i fully agree with all above, this example of cude of conduct i amazin. How appropriate would it be to add here rules for folder structures from #90 too?

maybe then just say in coc that you shouldn't put type in pages folder? I'll write a folder structure and where to put things

@OlegSuperBro
Copy link
Collaborator Author

i think we also need to add eslint for most rules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🖥️ dev Make developers life easier or harder ❔ priority: unknown ✨ enhancement New feature or request ⚠️ discussion Discuss how to fix or implement something
Projects
None yet
Development

No branches or pull requests

3 participants