Skip to content

Instantly share code, notes, and snippets.

@rxaviers
Created December 4, 2012 18:28
Show Gist options
  • Save rxaviers/4207213 to your computer and use it in GitHub Desktop.
Save rxaviers/4207213 to your computer and use it in GitHub Desktop.
jQuery Coding Standard questions
  1. Nested functions with object parameter
// Coding standards says this is correct
foo( x, {
  a: "alpha",
  b: "beta"
});

// What about this?
// a?
foo( bar( x, {
  a: "alpha",
  b: "beta"
}));
// The exception tells us to glue } and ). But, all occurences of )
// followed by another ) have spaces in between.

// b?
foo( bar( x, {
  a: "alpha",
  b: "beta"
}) );
// Shall we use the exception for the first }), but space the second )?

// c?
foo( bar( x, {
  a: "alpha",
  b: "beta"
} ) );
// Or simply space them all?

// d?
foo(
  bar( x, {
    a: "alpha",
    b: "beta"
  })
);
// Or "Nested multi-line function/object/array go on multiple lines". This way
// we reduce the inner function rules to its simpler non-nested rules?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment