-
Notifications
You must be signed in to change notification settings - Fork 2
Coding Standards
We use and enforce the Airbnb style guide so all of our code is formatted the same. To better enforce this styling, we have installed and use ESLint in combination with Airbnb's extension to it eslint-config-airbnb.
In order to ensure quality, we use ESLint while reviewing. To do this we use the command: npm run pretest. This test will inform the developer of any errors in syntax. It can also be used with the command --fix to automatically fix some issues like so: ./node_modules/.bin/eslint ./server/db/ldb.js --fix
Overall, this catches many issues and also forces collaborative styling between the whole team. This reduces the work required for future software maintenance.
The Airbnb style guide for JavaScript can be found here.
We have chosen to implement the following custom rules:
"rules": {
"no-multiple-empty-lines": [1,{"max":3}],
"no-unused-vars": ["error", { "argsIgnorePattern": "next", "argsIgnorePattern": "req" }],
"linebreak-style": 0,
},
-
no-multiple-empty-lines: Is set to 2 by default, allowing only two empty lines. However, for better readability we have increased this to three empty spaces. -
no-unused-vars: Some variables were added to be ignored for the ruleno-unused-vars. This rule displays errors if there is a variable that is unused in a function. However, these exceptions were added because even though they may be unused they are required by many processes in Node.JS. -
linebreak-style: Since our project team uses Windows and by default CRLF, we have to decided to ignore this rule.