Linters and automated code formatters can save you tons of time and they make it easy for collaborative projects to have consistent code formatting.
- Use Black and Pylint for Python.
- Use styler and lintr for R.
- Use Prettier for HTML, JavaScript, and CSS.
Use default settings in all cases (except setting Pylint to work with Black).
All are easily (or natively) integrated into VS Code. The R packages are also easily integrated into R Studio.
There are some things that the automated tools can't handle themselves. A few additional things to be consistent about are listed below. They all follow the most commonly used style guides for each language (though they are sometimes more specific, e.g., for R variable names).
These adhere to PEP8 and the tidyverse style guide.
ClassName
variable_name
function_name
CONSTANT_VALUE
These adhere to the Airbnb style guide.
- Use
const
orlet
as appropriate. Don't usevar
. - Use dot notation for accessing properties, not bracket notation, when possible.
- Use
===
and!==
instead of==
and!=
. - Start all comments with a space after the
//
.
ClassName
objectName
functionName