DevTools/Hacking: Difference between revisions

link to coding standards; don't mention jslint any more
(added eslint link)
(link to coding standards; don't mention jslint any more)
Line 152: Line 152:
Note that the mochitests '''must''' have focus while running.
Note that the mochitests '''must''' have focus while running.


= Checking your code using JSHint =
= Coding Standards =


You don't have to use JSHint, but you may find it helpful.
DevTools has some [[DevTools/CodingStandards|coding standards]] that your changes should follow. That page also shows how to set up ESLint to check your code for compliance.
 
There are many tools that allow you to run JSHint, for example [https://github.com/victorporof/Sublime-JSHint JSHint Gutter for Sublime Text].
 
Here is an example jshint.rc that conforms pretty closely with our style and use:
 
{
  "browser": true,
  "devel": true,
  "loopfunc": true,
  "esnext": true,
  "moz": true,
  "quotmark": true,
  "undef": true,
  "unused": true,
  "maxerr": 10000,
  "globals": {
    "loader": true,
    "require": true,
    "module": true,
    "exports": true,
    "Components": false,
    "Cu": true,
    "Ci": true,
    "Cc": true,
    "Cr": true,
    "CC": true,
    "dump": false,
    "Services": false,
    "do_check_eq": false,
    "do_check_false": false,
    "do_check_true": false,
    "do_get_file": false,
    "do_get_profile": false,
    "do_print": false,
    "do_register_cleanup": false,
    "do_throw": false,
    "add_test": false,
    "add_task": false,
    "run_next_test": false,
    "EventUtils": false,
    "ok": false,
    "is": false,
    "isnot": false,
    "equal": false,
    "deepEqual": false,
    "Task": false,
    "finish": false,
    "setTimeout": false,
    "clearTimeout": false,
    "XPCOMUtils": false,
    "top": true
  }
}


= Potential Pitfalls =
= Potential Pitfalls =


Today there are a few techniques and conventions we use that can be confusing, especially when you first start working with the code base.  We hope to improve these with time to make things easier for everyone, but for now this [https://etherpad.mozilla.org/devtools-intro-pitfalls etherpad] might be a helpful set of notes if you are having trouble.  If you find new pitfalls that aren't listed there, feel free to add your own entries, so we know to address them.  Also, please come talk to us in #devtools on IRC, as that might be the fastest path to solving the issue.
Today there are a few techniques and conventions we use that can be confusing, especially when you first start working with the code base.  We hope to improve these with time to make things easier for everyone, but for now this [https://etherpad.mozilla.org/devtools-intro-pitfalls etherpad] might be a helpful set of notes if you are having trouble.  If you find new pitfalls that aren't listed there, feel free to add your own entries, so we know to address them.  Also, please come talk to us in #devtools on IRC, as that might be the fastest path to solving the issue.
10

edits