Registry / testing / mocha-eslint

mocha-eslint

JSON →
library7.0.0jsnpmunverified

Run ESLint as Mocha tests without a task runner like Grunt or Gulp. Version 7.0.0 supports ESLint ^7.0.0 and requires Node ^10.12.0 or >=12.0.0. It creates separate Mocha tests for each linted path or glob pattern, with options for formatter, timeout, slow, strict mode, and context name. Unlike alternatives that require plugin registration, this package directly exposes a function to run linting in any Mocha test file.

npm install mocha-eslint
INSTALL
IMPORT
SIG · MOCHA-ESLINT
M
mocha-eslint
testingjavascriptv7.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const lint = require('mocha-eslint');
import lint from 'mocha-eslint';
Package uses CommonJS; ESM import may fail in older Node or without transpiler.
Value
const lint = require('mocha-eslint');
The exported value is a function; no named exports.
Type
const lint = require('mocha-eslint');
import { lint } from 'mocha-eslint';
There is no named export; must import default.

Configure mocha-eslint with paths, formatter style, timeout, and strict mode, then run linting as Mocha tests.

const lint = require('mocha-eslint'); const paths = ['src', 'test/**/*.js', '!test/exclude.js']; const options = { formatter: 'stylish', alwaysWarn: true, timeout: 5000, slow: 1000, strict: false, contextName: 'eslint' }; lint(paths, options);
Debug
Known issues
breakingVersion 7.0.0 updates ESLint to ^7.0.0. ESLint 7 includes breaking changes such as removal of some rules and configuration changes.
fix
Review ESLint 7 migration guide for rule and config changes.
affects: >=7.0.0
breakingVersion 6.0.0 drops support for Node 6 and updates to ESLint 6 and Mocha 6.
fix
Use Node >=8.0.0. Update ESLint config for version 6 changes.
affects: >=6.0.0 <7.0.0
breakingVersion 5.0.0 drops Node <6 support and updates ESLint to ^5.10.0.
fix
Ensure Node >=6.0.0. Review ESLint 5 migration.
affects: >=5.0.0 <6.0.0
gotchaMocha must be installed separately; mocha-eslint does not include it.
fix
Install mocha as a devDependency: npm install --save-dev mocha.
affects: >=0.0.0
gotchaNegation patterns (e.g., !tests/NotATest.js) must be at the end of the paths array or they will not work.
fix
Place negation patterns after all positive patterns in the array.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'eslint'
ESLint is not installed or not installed as a peer dependency.
fix
Run npm install eslint --save-dev
TypeError: lint is not a function
Using named import instead of default import.
fix
Use const lint = require('mocha-eslint');
Mocha error: timeout of 2000ms exceeded
Linting takes longer than the default Mocha timeout.
fix
Set the timeout option in mocha-eslint or globally in Mocha.
Upgrade
Version history
7.0.0latest on npm
Audit
Dependencies
eslintrequiredPeer dependency for linting functionality
mocharequiredTest runner, expected to be installed in consuming project
Agent activity
4 hits · last 30 days
node
4
Resources
mocha-eslint — npm install mocha-eslint · libregistry