Skip to content

Commit

Permalink
Enabled require("eslint") and exposed out CLI.
Browse files Browse the repository at this point in the history
I've added the "main" key to the package.json, pointing it to lib/api.js. The api.js file exports /lib/eslint.js and /lib/cli.js. This enables those who have run `npm install eslint` to then require eslint in their project like so:

var eslint = require("eslint");

Prior to this change calling `require("eslint")` would throw an error.

In addition, developers can now use the CLI from their projects, without having to `require` it from the `node_modules` directory (which is generally not good). Developers can now use the CLI programatically, like so:

var eslint = require("eslint");
eslint.cli.execute(["-h"]);
  • Loading branch information
iancmyers committed Jul 19, 2013
1 parent 5266964 commit f5464e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @fileoverview Expose out ESLint and CLI to require.
* @author Ian Christian Myers
*/

module.exports = {
linter: require("./eslint"),
cli: require("./cli")
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"bin": {
"eslint": "./bin/eslint.js"
},
"main": "./lib/api.js",
"scripts": {
"changelog": "bash ./scripts/changelog-update.sh",
"test": "npm run-script lint && node ./node_modules/istanbul/lib/cli.js cover --print both ./node_modules/vows/bin/vows -- --spec ./tests/*/*.js ./tests/*/*/*.js",
Expand Down

0 comments on commit f5464e8

Please sign in to comment.