# Code formatting

  • When working in a team, it's very important that all team members follow the same coding conventions
    • Just like a magazine or newspaper has his style rules (layout, colors, visuals, ...) also programmers - especially when working in a team - should have their own style guides
    • If you work in a (programming) team, it has to look like the whole codebase is programmed by one person!
  • Good style guides avoid conflicts in version control tools like Git(Hub) and make code reviews a lot easier
    • A lot of these conflicts are generated by minor (configuration) changes in the IDE settings among the team members or in the code itself that causes painful conflicts and unwanted history in version control
      • Examples: single/double quote for strings, using trailing comma or not, tabs and spaces, statements end with or without a semicolon, ...
  • We discuss three of the most used tools to avoid a lot of these conflicts
    1. .editorconfig is a configuration file for editors/IDEs and sets some general rules like tabs and spacing in a file
    2. the Prettier plugin handles code formatting, e.g. always use single quotes or double quotes, add (or remove) trailing commas, ...
    3. the ESLint plugin is a JavaScript linting tool which consistently structures our scripting code and which also checks for errors (even before the code is executed)

REMARKS

  • What follows is a short crash course about these tools
  • Several of these tools are integrated in the projects of this course
  • You don't have to be able to set up these tools yourself, but you do have to understand what's happening in the background
Last Updated: 3/18/2021, 6:58:11 PM