JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5804
  • Score
    100M100P100Q118711F
  • License MIT

run ESLint as mocha tests

Package Exports

  • mocha-eslint

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mocha-eslint) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

mocha-eslint

Run ESLint in Mocha tests.

Inspired by mocha-jshint from Allan Ebdrup.

Installation

You can install into your node.js project as a development dependency with:

$ npm install --save-dev mocha-eslint

Usage

After mocha-eslint is installed, you can use it by creating a test file for Mocha and requiring mocha-eslint like so:

var lint = require('mocha-eslint');

This will return a function with the signature:

lint(paths, options)

where paths is an array of paths from your project's top level directory and options has a single property "formatter" which can be assigned to the name of any of the ESLint formatters ("stylish" (the default), "compact", "checkstyle", "jslint-xml", "junit" and "tap") or the full path to a JavaScript file containing a custom formatter. If 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 = require('mocha-eslint');

// Array of paths to lint
// Note: a seperate Mocha test will be run for each path
var paths = [
  'bin',
  'lib',
  'tests',
];

// Specify style of output
var options = {};
options.formatter = 'compact';

// Get the party started
lint(paths, options);

Notes

This module does not make any decisions about which ESLint rules to run. Make sure your project has a .eslintrc file if you want something other than the default ESLint rules to execute.