问题
I have found that sometimes people do not realise they have linting errors in their tests when they run them since they are show before the test progress/information.
Is there any configuration which will cause ALL tests to fail if any of the tests have any linting errors?
I am using mocha with karma.
Thanks.
回答1:
Make the ESLint execution a part of the grunt or gulp or "npm" task (whichever you use). For instance, when we run grunt test, first the ESLint is executed and then karma. If there are any errors or warnings produced by ESLint the task would fail early.
回答2:
Inside you webpack config, setup fail option for eslint like this
module.exports = {
entry: "...",
module: {
// ...
},
eslint: {
failOnError: true
}
}
This would fail the build.
Doc ref: https://github.com/MoOx/eslint-loader#failonerror-default-false
来源:https://stackoverflow.com/questions/39229441/how-can-i-force-all-karma-test-to-fail-if-an-eslint-error-is-found