npm install karma-eslint --save-dev
In your karma.conf.js
file:
preprocessors: {
'**/*.js': ['eslint']
}
Karma-eslint accepts these options:
stopOnError
- fails a test on any error default:
true
errorThreshold
- a threshold value for total errors default:
null
- use with
stopAboveErrorThreshold
to stop build if errors exceed threshold
stopAboveErrorThreshold
- stops build if
errorThreshold
exceeded default:false
stopOnWarning
- fails a test on any Warning default:
false
- if set
true
, Warnings are always displayed
showWarnings
- to display Warning messages default:
true
- has no effect if
stopOnWarning
is settrue
- in such case Warnings are displayed anyway
engine
- eslint CLIEngine configuration options. default:
{}
Example:
eslint: {
errorThreshold: 1000,
stopAboveErrorThreshold: true,
stopOnError: false,
stopOnWarning: true,
showWarnings: true,
engine: {
configFile: 'client/.eslintrc'
}
}
This plugin leverages ESLints normal configuration methods. The full list of ESLint rules are here.
For more information on Karma visit the Karma site.