Skip to content
This repository
Browse code

Copied CLI documentation from node-jshint

Since we're merging all repos together I need to copy some docs so that we don't lose them forever.
  • Loading branch information...
commit be8e56f6f6e477fc34c4142cad5001811ad24e55 1 parent 2bcaedf
Anton Kovalyov valueof authored

Showing 1 changed file with 66 additions and 0 deletions. Show diff stats Hide diff stats

  1. +66 0 README.md
66 README.md
Source Rendered
@@ -41,6 +41,72 @@ use them, clone this repo and run our build command:
41 41
42 42 node make.js
43 43
  44 +Usage
  45 +-----
  46 +
  47 + jshint -h
  48 +
  49 +You can also require JSHint itself as a module.
  50 +
  51 + var jshint = require('jshint');
  52 +
  53 +Note: If you are using npm v1.x be sure to install jshint locally (without the -g flag) or link it globally.
  54 +
  55 +Custom Reporters
  56 +----------------
  57 +
  58 +Specify a custom reporter module (see example/reporter.js).
  59 +
  60 + --reporter path/to/reporter.js
  61 +
  62 +Use a jslint compatible xml reporter.
  63 +
  64 + --jslint-reporter
  65 +
  66 +Show additional non-error data generated by jshint (unused globals etc).
  67 +
  68 + --show-non-errors
  69 +
  70 +Configuration Options
  71 +---------------------
  72 +
  73 +**Note:** This behavior described below is very different from versions prior to `0.6`.
  74 +
  75 +The CLI uses the default options that come with JSHint.
  76 +
  77 +Only one extra option is unique to node-jshint: `globals`
  78 +allows you to define an object of globals that get ignored for every file.
  79 +To see an example you can look at how whitelisted globals are defined
  80 +in the [jshint code](https://github.com/jshint/jshint/blob/c047ea1b01097fcc220fcd1a55c41f67ae2e6e81/jshint.js#L556)
  81 +
  82 +To have your own configuration apply, there are several methods you can use:
  83 +
  84 +### Specify Manually
  85 +
  86 +Setting the `--config=/path/to/your/config` command line option to specify your own configuration file outside of the directory tree for your project.
  87 +
  88 +### Within your Project's Directory Tree
  89 +
  90 +When the CLI is called, and a configuration file isn't specified already, `node-jshint` will attempt to locate one for you starting in `pwd`. (or "present working directory") If this does not yield a `.jshintrc` file, it will move one level up (`..`) the directory tree all the way up to the filesystem root. If a file is found, it stops immediately and uses that set of configuration.
  91 +
  92 +This setup allows you to set up **one** configuration file for your entire project. (place it in the root folder) As long as you run `jshint` from anywhere within your project directory tree, the same configuration file will be used.
  93 +
  94 +### Home Directory
  95 +
  96 +If all the methods above do not yield a `.jshintrc` to use, the last place that will be checked is your user's `$HOME` directory.
  97 +
  98 +## File Extensions
  99 +
  100 +Default extension for files is ".js". If you want to use JSHint with other file extensions (.json), you need to pass this extra extension as an option :
  101 +
  102 + --extra-ext .json
  103 +
  104 +## Ignoring Files and Directories
  105 +
  106 +If there is a .jshintignore file in your project's directory tree, (also provided you run `jshint` from within your project's directory) then any directories or files specified will be skipped over. (behaves just like a `.gitignore` file)
  107 +
  108 +**Note:** Pattern matching uses minimatch, with the nocase [option](https://github.com/isaacs/minimatch). When there is no match, it performs a left side match (when no forward slashes present and path is a directory).
  109 +
44 110 Contributing
45 111 ------------
46 112

0 comments on commit be8e56f

Please sign in to comment.
Something went wrong with that request. Please try again.