Skip to content

Commit 03bc596

Browse files
Jeroen MeeusLyrkan
Jeroen Meeus
authored andcommitted
Added a small functional test for eslint output
1 parent a19414e commit 03bc596

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

fixtures/js/eslint.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const a = 'foobar';

test/functional.js

+28
Original file line numberDiff line numberDiff line change
@@ -1033,5 +1033,33 @@ module.exports = {
10331033
done();
10341034
});
10351035
});
1036+
1037+
it('When enabled, eslint checks for linting errors', (done) => {
1038+
const config = createWebpackConfig('www/build', 'dev');
1039+
config.setPublicPath('/build');
1040+
config.addEntry('main', './js/eslint');
1041+
config.enableEslintLoader({
1042+
// Force eslint-loader to output errors instead of sometimes
1043+
// using warnings (see: https://github.com/MoOx/eslint-loader#errors-and-warning)
1044+
emitError: true,
1045+
rules: {
1046+
// That is not really needed since it'll use the
1047+
// .eslintrc.js file at the root of the project, but
1048+
// it'll avoid breaking this test if we change these
1049+
// rules later on.
1050+
'indent': ['error', 2],
1051+
'no-unused-vars': ['error', { 'args': 'all' }]
1052+
}
1053+
});
1054+
1055+
testSetup.runWebpack(config, (webpackAssert, stats) => {
1056+
const eslintErrors = stats.toJson().errors[0];
1057+
1058+
expect(eslintErrors).to.contain('Expected indentation of 0 spaces but found 2');
1059+
expect(eslintErrors).to.contain('\'a\' is assigned a value but never used');
1060+
1061+
done();
1062+
}, true);
1063+
});
10361064
});
10371065
});

0 commit comments

Comments
 (0)