Skip to content

Commit e33128f

Browse files
author
Jeroen Meeus
committed
Added a small functional test for eslint output
1 parent 73cf6e6 commit e33128f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

fixtures/js/eslint.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const a = 'foobar';

test/functional.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,5 +946,33 @@ module.exports = {
946946
done();
947947
}, true);
948948
});
949+
950+
it('When enabled, eslint checks for linting errors', (done) => {
951+
const config = createWebpackConfig('www/build', 'dev');
952+
config.setPublicPath('/build');
953+
config.addEntry('main', './js/eslint');
954+
config.enableEslintLoader({
955+
// Force eslint-loader to output errors instead of sometimes
956+
// using warnings (see: https://github.com/MoOx/eslint-loader#errors-and-warning)
957+
emitError: true,
958+
rules: {
959+
// That is not really needed since it'll use the
960+
// .eslintrc.js file at the root of the project, but
961+
// it'll avoid breaking this test if we change these
962+
// rules later on.
963+
'indent': ['error', 2],
964+
'no-unused-vars': ['error', { 'args': 'all' }]
965+
}
966+
});
967+
968+
testSetup.runWebpack(config, (webpackAssert, stats) => {
969+
const eslintErrors = stats.toJson().errors[0];
970+
971+
expect(eslintErrors).to.contain('Expected indentation of 0 spaces but found 2');
972+
expect(eslintErrors).to.contain('\'a\' is assigned a value but never used');
973+
974+
done();
975+
}, true);
976+
});
949977
});
950978
});

0 commit comments

Comments
 (0)