views:

77

answers:

2

I'm implementing a code review process, among the things to be reviewed is javascript. I've been asked to make a sort of checklist of things to look for when reviewing code. So far my checklist is as follows:

  • no functions or variables in the global namespace.
  • write efficient code, especially in loops
  • don't append to the dom in a loop.
  • keep style in css, use classes.
  • use the best jQuery selector possible.
  • Don't select an object in jquery more than once, use chaining or put it in a variable.
  • minimize http requests.
  • don't use jQuery $.each.
  • validate user input before making http requests.
  • handle specific errors.
  • provide the user with enough info to remedy the situation when errors occur (if possible)

Does anyone have anything else they'd recommend for a general javascript review checklist (jQuery included).

+1  A: 

I would add something like "distinguish between non-fatal and fatal errors". This improves the user experience a lot. Another thing that i am thinking about is the usage of closures to minimize namespace pollution. My third point: Feature detection over browser sniffing.

elusive
+1  A: 

No errors from JSLint using whatever settings you decide you want. This can check for things you've mentioned, such as adding nothing to the global namespace.

Michael Williamson