diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..51563b8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = "utf-8" + +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/docs/ADDING_ISSUES.markdown b/docs/ADDING_ISSUES.markdown new file mode 100644 index 0000000..f32d728 --- /dev/null +++ b/docs/ADDING_ISSUES.markdown @@ -0,0 +1,15 @@ +# Guidelines for Adding Issues to SparkPost +Thank you for finding an issue, the SparkPost SDKs are open sourced and focused on helping our developers to be successful. Please review the following checklist before submitting a new issue. + +1. To prevent duplication, please search for issues and make sure it doesn’t already exist +2. Please provide the following information to help our contributors in resolving the issue: + 1. Operating System and Version + 2. Programming language version + 3. Exception, error or issue summary + 4. Recreation steps or Use case summary + 5. Example data (if available) + 6. Expected result or desired functionality + 7. Any extra information you’d like to provide +3. Please give your issue a meaningful name +4. Please, no trolling or flaming comments on issues (counter-productive) +5. Please follow/watch your issue. We expect you to take issue reporting as seriously as we do. diff --git a/docs/CODE_STYLE_GUIDE.markdown b/docs/CODE_STYLE_GUIDE.markdown new file mode 100644 index 0000000..2a23eb6 --- /dev/null +++ b/docs/CODE_STYLE_GUIDE.markdown @@ -0,0 +1,726 @@ +# Code Style Guide for SparkPost Node SDK + +Please make sure that your editor is properly reading from the .editorconfig file located at the base of the repository. + +Please take a few minutes and review our style guide: + +The following provide a reasonable style and formatting guide for all Javascript produced at Message Systems. The most important take-away from this guide is: be consistent. +A lot of effort has been made to keep this guide focused on style and formatting. However, conventions and techniques are inevitably part of things as well. These have been minimized as much as possible, as other documents are better suited to handle them. + +## Naming Conventions +Avoid single letter names outside of loops. Offer descriptive names. +``` + // Bad + function q() {...} + + // Good + function query() {...} + for (var i = 0; i < 10; i++) { + ... + } +``` +Use camelCase when naming objects, functions, and instances. +``` + // Bad + var MYObject = {}; + var my_string_variable = ''; + var my-object-variable = {}; + + + // Good + var myObject = {}; + var myStringVariable = ''; + var myObjectVariable = {}; +``` +Use PascalCase for class names. +``` + // Bad + var superHero = function (options) { + this.name = options.name; + }; + var reed = new superHero({ name:'Reed Richards' }); + + + // Good + var SuperHero = function (options) { + this.name = options.name; + }; + var reed = new SuperHero({ name:'Reed Richards' }); +``` +Do not treat "private" object properties as special with something like an underscore. If you need private properties, obtain them by closing over them in the constructor. +``` + // Bad + this._ccNumber = '4111111111111111'; + + // Good + function AccountInfo(cardNumber) { + var cardNumber = cardNumber; + + // initialization, &c. + + return this; + } + + var acct = new AccountInfo('4111111111111111'); +``` +If you are making a reference to this, use self (assuming a bind() function isn't used). +``` + // Bad + function () { + var that = this; + return function () { console.log(that); }; + } + + // Good + function () { + var self = this; + return function () { console.log(self); }; + } +``` +You're not a minifier. Save yourself the headache of trying to be one. +``` + // Bad + var q = function q(s) { + return document.querySelectorAll(s); + }; + var i,a=[],els=q('#test'); + for(i=0;iLoading...