Properly formatted code enhances the readability, maintainability and scalability of your codebase.
Benefits of well-formatted code include reduced mental load, consistent style among team members, and tooling compatibility.
Formatting methods include indentation, line length, naming conventions, spacing, braces/parenthesis, quotes, semicolons, file/folder structure, and comments.
Indentation visually organizes code hierarchy. The recommended white space is 2 spaces, not tabs.
Keeping line length between 80 to 100 characters on a single line is the industry standard. PEP 8 and Prettier recommend 80 characters to prevent horizontal scrolling.
Naming conventions for variables/functions include using camelCase. PascalCase should be used for React components and upper snake case for constants.
Recommended spacing is to separate operators with spaces, group variable and function assignment, and create blank lines between different code sections.
Dangling braces should be avoided according to the Airbnb style guide. Either single or double quotes should be used throughout the project.
Stick to either using semicolons or not using them. Good file and folder structure tips include grouping related files and using meaningful names.
Comments should be used sparingly. Only used to explain non-obvious decisions or to show why a piece of code exists rather than how it works.