@@ -1722,6 +1722,47 @@ module.exports = {
1722
1722
} , true ) ;
1723
1723
} ) ;
1724
1724
1725
+ it ( 'When enabled, eslint checks for linting errors by using configuration from file' , ( done ) => {
1726
+ const cwd = process . cwd ( ) ;
1727
+ after ( ( ) => {
1728
+ process . chdir ( cwd ) ;
1729
+ } ) ;
1730
+
1731
+ const appDir = testSetup . createTestAppDir ( ) ;
1732
+ const config = testSetup . createWebpackConfig ( appDir , 'www/build' , 'dev' ) ;
1733
+ config . setPublicPath ( '/build' ) ;
1734
+ config . addEntry ( 'main' , './js/eslint-es2018' ) ;
1735
+ config . enableEslintLoader ( {
1736
+ // Force eslint-loader to output errors instead of sometimes
1737
+ // using warnings (see: https://github.com/MoOx/eslint-loader#errors-and-warning)
1738
+ emitError : true ,
1739
+ } ) ;
1740
+ fs . writeFileSync (
1741
+ path . join ( appDir , '.eslintrc.js' ) ,
1742
+ `
1743
+ module.exports = {
1744
+ parser: 'babel-eslint',
1745
+ rules: {
1746
+ 'indent': ['error', 2],
1747
+ 'no-unused-vars': ['error', { 'args': 'all' }]
1748
+ }
1749
+ } `
1750
+ ) ;
1751
+
1752
+ process . chdir ( appDir ) ;
1753
+
1754
+ testSetup . runWebpack ( config , ( webpackAssert , stats ) => {
1755
+ const eslintErrors = stats . toJson ( ) . errors [ 0 ] ;
1756
+
1757
+ expect ( eslintErrors ) . not . to . contain ( 'Parsing error: Unexpected token ..' ) ;
1758
+ expect ( eslintErrors ) . to . contain ( 'Expected indentation of 0 spaces but found 2' ) ;
1759
+ expect ( eslintErrors ) . to . contain ( '\'x\' is assigned a value but never used' ) ;
1760
+ expect ( eslintErrors ) . to . contain ( '\'b\' is assigned a value but never used' ) ;
1761
+
1762
+ done ( ) ;
1763
+ } , true ) ;
1764
+ } ) ;
1765
+
1725
1766
it ( 'Code splitting with dynamic import' , ( done ) => {
1726
1767
const config = createWebpackConfig ( 'www/build' , 'dev' ) ;
1727
1768
config . setPublicPath ( '/build' ) ;
0 commit comments