-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Javascript Coding Style
Benjamin Délèze edited this page May 14, 2021
·
10 revisions
Use the w3school JS convention where not specified otherwise by our coding style.
To be consistent with our C/C++ coding style, we must use 2 spaces (instead of 4) to indent code.
To be consistent with our C/C++ coding style, don't use curly brackets when not needed (e.g., for single instruction blocks).
Use the following syntax to check for an undefined variable:
typeof data === 'undefined'
The names of private variables and functions must begin with a _.
Use ES6 features in the code. For example:
- OOP-style class instead of prototypes
- arrow functions
- constants
- blocked scoped variables
- let and const instead of var
All the errors reported by ESLint based on the https://github.com/cyberbotics/webots/blob/master/.eslintrc.json configuration file should be fixed. Warnings may be accepted.