JSLint has historically been the main tool for this, but several more now exist:
- JSHint - a fork of JSLint that is said to be a little less opinionated
- Closure Linter - a linter that checks against the Google Javascript Style Guide
- ESLint - a more flexible tool, but newer, and not yet as stable.