You can install into your Node.js project as a development dependency with:
npm install --save-dev mocha-eslint
mocha-eslint will install ESLint for itself, so you don't need to worry about
adding it to your consuming module.
The same is not true for Mocha. You should already have Mocha installed in your consuming module.
After mocha-eslint is installed, you can use it by creating a test file for
Mocha and requiring
mocha-eslint like so:
var lint = ;
This will return a function with the signature:
paths is an array of paths from your project's top level directory (as
of v0.1.2, you can also include
glob patterns) and
has a single property
formatter that can be assigned to the name of any of the
stylish (the default),
options is not included, the default "stylish" formatter will be used.
So, a full test file to run in Mocha might look like:
var lint = ;// Array of paths to lint// Note: a seperate Mocha test will be run for each path and each file which// matches a glob patternvar paths ='bin''lib''tests/**/*Test.js''!tests/NotATest.js' // negation also works;var options =// Specify style of outputformatter: 'compact' // Defaults to `stylish`// Only display warnings if a test is failingalwaysWarn: false // Defaults to `true`, always show warnings// Increase the timeout of the test if linting takes to longtimeout: 5000 // Defaults to the global mocha `timeout` option// Increase the time until a test is marked as slowslow: 1000 // Defaults to the global mocha `slow` option// Consider linting warnings as errors and return failurestrict: true // Defaults to `false`, only notify the warnings;// Run the tests;
This module does not make any decisions about which ESLint rules to run. Make
sure your project has a
.eslintrc file if you want ESLint to do anything.