Git Product home page Git Product logo

javascript-style-guide's Issues

Babel has great implementations of const and let

I love this style guide -- especially the ES6 section -- and I'm going to adopt it as my own.
I just had a comment about your use of const and let ... I assume that section is outdated, because Babel (formerly 6to5) now has great support for them.

Examples:

Const:

const c = 5;
c = 10;

Error: "c" is read-only

Let:

let i = 0;
for (let i = 0; i < 10; i++) {
  console.log(i);
}
for (let i = 0; i < 10; i++) {
  console.log(function(){ return i; });
}

Compiled output:

"use strict";

var i = 0;
for (var _i = 0; _i < 10; _i++) {
  console.log(_i);
}
for (var _i2 = 0; _i2 < 10; _i2++) {
  (function (_i2) {
    console.log(function () {
      return _i2;
    });
  })(_i2);
}

Add spacing rules

It would be nice to get consistent when adding spacing around code blocks. For example, spaces here are probably unnecessary:

function1(var1, var2) {

  function2('some_string', function(var3, var4) {
    
  });

  return;
}

but spaces deeply indented are useful:

]).config([
  '$stateProvider',
  function accessTokensCreateRoute($stateProvider) {
    $stateProvider.state(ACCESS_TOKENS_CREATE_ROUTE_STATE, {
      url: '/create',
      onEnter: [
        '$state',
        'Dialog',
        function($state, Dialog) {

         Dialog.show({
            template: template,
            controller: 'AccessTokensCreateController',
            controllerAs: 'ctrl',
            dialogHeader: 'Create Access Token',
            onDismissDialog: function onDismissDialog() {
              $state.go(ACCESS_TOKENS_INDEX_ROUTE_STATE);
            },
          });

        },
      ],
    });
  },
]);

In some places we’re adding a space above but not below a chunk of code. I think it should be both or neither. Any other spacing issues, feel free to add 'em.

Thoughts @jackfranklin @harrison @samjewell @jamesshedden?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.