Skip to content

Commit

Permalink
Add test for ESLint with external configuration (and babel-eslint usage)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kocal committed Jan 12, 2020
1 parent 3ba6cf2 commit 9f31d95
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fixtures/js/eslint-es2018.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const a = { x: 0, y: 1, z: 2 };
const { x, ...b } = a;
41 changes: 41 additions & 0 deletions test/functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,47 @@ module.exports = {
}, true);
});

it('When enabled, eslint checks for linting errors by using configuration from file', (done) => {
const cwd = process.cwd();
after(() => {
process.chdir(cwd);
});

const appDir = testSetup.createTestAppDir();
const config = testSetup.createWebpackConfig(appDir, 'www/build', 'dev');
config.setPublicPath('/build');
config.addEntry('main', './js/eslint-es2018');
config.enableEslintLoader({
// Force eslint-loader to output errors instead of sometimes
// using warnings (see: https://github.com/MoOx/eslint-loader#errors-and-warning)
emitError: true,
});
fs.writeFileSync(
path.join(appDir, '.eslintrc.js'),
`
module.exports = {
parser: 'babel-eslint',
rules: {
'indent': ['error', 2],
'no-unused-vars': ['error', { 'args': 'all' }]
}
} `
);

process.chdir(appDir);

testSetup.runWebpack(config, (webpackAssert, stats) => {
const eslintErrors = stats.toJson().errors[0];

expect(eslintErrors).not.to.contain('Parsing error: Unexpected token ..');
expect(eslintErrors).to.contain('Expected indentation of 0 spaces but found 2');
expect(eslintErrors).to.contain('\'x\' is assigned a value but never used');
expect(eslintErrors).to.contain('\'b\' is assigned a value but never used');

done();
}, true);
});

it('Code splitting with dynamic import', (done) => {
const config = createWebpackConfig('www/build', 'dev');
config.setPublicPath('/build');
Expand Down

0 comments on commit 9f31d95

Please sign in to comment.