-
Notifications
You must be signed in to change notification settings - Fork 3
Coding Standards
Aidin Niavarani edited this page Jan 24, 2020
·
5 revisions
Please follow these coding standards when coding. Note that we also use ESLint to automatically lint the code to match certain best practices, including some of the following. You can view the .eslintrc.js file to find out those set of rules.
- Group files into folders where possible if there are at least 2 files that can be grouped together
- Please be cognizant of how variables, constants, and parameters are currently formed in the code in terms of their casing, how they are worded, etc. and try to follow the same pattern in your code
- Add doc comments for all classes and public functions
- Add an empty line between description and parameters
- Each parameter should be formed similar to this format:
@param Integer $postId Post Id
- Add an empty line between parameters and @return
- Add TODO functions where appropriate
- Add a comment if you are commenting out any code to explain why it's commented out
- If line is more than 85 characters, break it down by putting each attribute or list item on its own line
- Put the opening braces for functions on their own line
- Always add a comma after the last item to reduce merge conflicts
- Add the comment before
add_action
- Put the related function for the
add_action
right below it (without an empty line)