Keeping with our tradition of Continuous Improvement, we are proud to announce a major revamp of NodeJS SDKs!
- We are using ES6 classes, along with other ES6 primitives.
- You can run
npm run lintto lint your code immediately.
- We generate CI/CD files for Travis, CircleCi, Appveyor and Jenkins to run NodeJS tests.
Please generate your SDK again if you want the improved ES6 based code.
Here is a summary of code related changes you'll see:
- Classes are now written using ES6 class syntax.
- All code and comments now follow a max line length of
vardeclarations have been replaced by block scoped
- All files now work in
- Unnecessary imports in files have been removed.
- Double quotes have been replaced by single quotes throughout the sdk.
- JSDoc annotations in code have improved.
- String concatenation has been replaced by template literals.
- Object properties are strictly being accessed using dot notation whenever possible.
- Tabs have been replaced by spaces.
- Indent of 4 spaces is used.
- Line endings are now Unix style (LF) line-endings.
- Arrow functions are now being used.
===is used instead of
==for equality checks.
- All requires have been moved to the top of the file.
- Object literal shorthand syntax is now being used.
- Removed all trailing spaces.
- Infix operators are now spaced according to AirBnb guide.
- Removed all code that manipulated object prototype (due to ES6 class inheritance).
We no longer generate getters and setters for properties in model and exception/error classes. Properties should directly be accessed using the property name.
// Access properties simply by dot notation
let user = new User();
user.name = 'Foo';
// Getters and setters like these are no longer supported
// This code will no longer run
let user = new User();
Running Linter Tests
To check for Style Guide compliance, you can run the ESLint tool.
First ensure all the project dependencies are installed:
Then run the ESLint tool using:
npm run lint
Our current ESLint configuration looks like this:
"indent": ["error", 4],
Supported NodeJS Runtimes
The generated SDK should be compatible with NodeJS version 4 and above.
We specifically avoided some ES6 features in order to keep compatibility with version 4: see node.green.