Skip to content

BBVAEngineering/javascript

Repository files navigation

BBVA Javascript

Greenkeeper badge

Javascript style guide inspired in Airbnb rules

Table of Contents

  1. Editorconfig
  2. Babel
  3. ESlint
  4. JSBeautify
  5. Possible errors

Editorconfig

EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs.

  • Spaces must be used to indent instead of tabs.

  • Use 2 spaces to indent the code.

  • Use "lf" char at end of line.

  • UTF-8 charset.

  • Remove white spaces at the end of the line.

  • Last line must be blank.

⬆ back to top

Babel

Babel allows you to use ES6 features in your projects and then compiles ES5 for you to use in production.

All code must be written using babel ES6 rules. Get more ES6 info here.

  • Arrows and Lexical This

  • Classes

  • Template Strings

  • Default + Rest + Spread

  • Let + Const

  • Iterators + For..Of

  • Generators

  • Modules

  • And much more...

⬆ back to top

ESlint

ESLint is an open source project, It's goal is to provide a pluggable linting utility for JavaScript.

This rules are optimized for ECMAScript 2015 and eslint versions ^3.0.0.

You can check the rules for BBVA eslint in this link.

Usage

  • npm install --save-dev eslint-config-bbva eslint.
  • add "extends": "bbva" to your .eslintrc.js file in your project.

⬆ back to top

JSBeautify

This little beautifier will reformat and reindent bookmarklets, ugly JavaScript, unpack scripts packed by Dean Edward’s popular packer, as well as deobfuscate scripts processed by javascriptobfuscator.

⬆ back to top

Possible errors

  1. Do not use console statements. When using Ember it's recommended to log with the Object Ember.Logger

Why? messages are considered to be for debugging purposes and therefore not suitable to ship to the client.

Ember.Logger.log("Hey!");
  1. Trailing commas are not valid. eslint: comma-dangle

    Why? In some browsers trailing commas can throw an error.

    // bad
    var foo = {
      bar: ":)",
    };
    var wow = [1, 2];
    
    // good
    var foo = {
      bar: ":)",
    };
    var wow = [1, 2];

⬆ back to top

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details