This repository was archived by the owner on Sep 28, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ var test = require ( "tape" )
2+ var webpack = require ( "webpack" )
3+ var assign = require ( "object-assign" )
4+ var conf = require ( "./utils/conf" )
5+
6+ test ( "eslint-loader can return error if file is bad" , function ( t ) {
7+ webpack ( assign ( { } ,
8+ conf ,
9+ {
10+ entry : "./test/fixtures/error.js" ,
11+ }
12+ ) ,
13+ function ( err , stats ) {
14+ if ( err ) { throw err }
15+
16+ t . ok ( stats . hasErrors ( ) , "a file that contains eslint errors should return error" )
17+ t . end ( )
18+ } )
19+ } )
Original file line number Diff line number Diff line change 1+ var test = require ( "tape" )
2+ var webpack = require ( "webpack" )
3+ var assign = require ( "object-assign" )
4+ var conf = require ( "./utils/conf" )
5+
6+ test ( "eslint-loader ignores files present in .eslintignore" , function ( t ) {
7+ webpack ( assign ( { } ,
8+ conf ,
9+ {
10+ entry : "./test/fixtures/ignore.js" ,
11+ eslint : assign ( { } , conf . eslint , {
12+ // we want to enable ignore, so eslint will parse .eslintignore and
13+ // should skip the file specified above
14+ ignore : true ,
15+ } ) ,
16+ }
17+ ) ,
18+ function ( err , stats ) {
19+ if ( err ) { throw err }
20+
21+ t . ok ( stats . hasWarnings ( ) , "an ignored file gives a warning" )
22+ t . end ( )
23+ } )
24+ } )
Original file line number Diff line number Diff line change 1+ var test = require ( "tape" )
2+ var webpack = require ( "webpack" )
3+ var assign = require ( "object-assign" )
4+ var conf = require ( "./utils/conf" )
5+
6+ test ( "eslint-loader can force to emit error" , function ( t ) {
7+ webpack ( assign ( { } ,
8+ conf ,
9+ {
10+ entry : "./test/fixtures/warn.js" ,
11+ eslint : assign ( { } , conf . eslint , {
12+ emitError : true ,
13+ } ) ,
14+ }
15+ ) ,
16+ function ( err , stats ) {
17+ if ( err ) { throw err }
18+
19+ t . ok ( stats . hasErrors ( ) , "a file should return error if asked" )
20+ t . notOk ( stats . hasWarnings ( ) , "a file should return no warning if error asked" )
21+ t . end ( )
22+ } )
23+ } )
24+
25+ test ( "eslint-loader can force to emit warning" , function ( t ) {
26+ webpack ( assign ( { } ,
27+ conf ,
28+ {
29+ entry : "./test/fixtures/error.js" ,
30+ eslint : assign ( { } , conf . eslint , {
31+ emitWarning : true ,
32+ } ) ,
33+ }
34+ ) ,
35+ function ( err , stats ) {
36+ if ( err ) { throw err }
37+
38+ t . ok ( stats . hasWarnings ( ) , "a file should return warning if asked" )
39+ t . notOk ( stats . hasErrors ( ) , "a file should return no error if error asked" )
40+ t . end ( )
41+ } )
42+ } )
Original file line number Diff line number Diff line change 1+ var test = require ( "tape" )
2+ var webpack = require ( "webpack" )
3+ var assign = require ( "object-assign" )
4+ var conf = require ( "./utils/conf" )
5+
6+ test ( "eslint-loader can use eslint formatter" , function ( t ) {
7+ webpack ( assign ( { } ,
8+ conf ,
9+ {
10+ entry : "./test/fixtures/error.js" ,
11+ }
12+ ) ,
13+ function ( err , stats ) {
14+ if ( err ) { throw err }
15+
16+ console . log ( "### Here is a example of the default formatter" )
17+ console . log ( "# " + stats . compilation . errors [ 0 ] . message . split ( "\n" ) . join ( "\n# " ) )
18+ t . ok ( stats . compilation . errors [ 0 ] . message , "webpack have some output" )
19+ t . end ( )
20+ } )
21+ } )
22+
23+ test ( "eslint-loader can use custom formatter" , function ( t ) {
24+ webpack ( assign ( { } ,
25+ conf ,
26+ {
27+ entry : "./test/fixtures/error.js" ,
28+ eslint : assign ( { } , conf . eslint , {
29+ formatter : require ( "eslint-friendly-formatter" ) ,
30+ } ) ,
31+ }
32+ ) ,
33+ function ( err , stats ) {
34+ if ( err ) { throw err }
35+
36+ console . log ( "### Here is a example of another formatter" )
37+ console . log ( "# " + stats . compilation . errors [ 0 ] . message . split ( "\n" ) . join ( "\n# " ) )
38+ t . ok ( stats . compilation . errors [ 0 ] . message , "webpack have some output with custom formatters" )
39+ t . end ( )
40+ } )
41+ } )
Load diff This file was deleted.
Original file line number Diff line number Diff line change 1+ var test = require ( "tape" )
2+ var webpack = require ( "webpack" )
3+ var assign = require ( "object-assign" )
4+ var conf = require ( "./utils/conf" )
5+
6+ test ( "eslint-loader don't throw error if file is ok" , function ( t ) {
7+ webpack ( assign ( { } ,
8+ conf ,
9+ {
10+ entry : "./test/fixtures/good.js" ,
11+ }
12+ ) ,
13+ function ( err , stats ) {
14+ if ( err ) { throw err }
15+
16+ t . notOk ( stats . hasErrors ( ) , "a good file doesn't give any error" )
17+ t . notOk ( stats . hasWarnings ( ) , "a good file doesn't give any warning" )
18+ t . end ( )
19+ } )
20+ } )
Original file line number Diff line number Diff line change 1+ var test = require ( "tape" )
2+ var webpack = require ( "webpack" )
3+ var assign = require ( "object-assign" )
4+ var conf = require ( "./utils/conf" )
5+
6+ test ( "eslint-loader supports query strings parameters" , function ( t ) {
7+ webpack ( assign ( { } ,
8+ conf ,
9+ {
10+ entry : "./test/fixtures/good-semi.js" ,
11+ module : {
12+ loaders : [
13+ {
14+ test : / \. j s $ / ,
15+ loader : "./index?{rules:[{semi:0}]}" ,
16+ exclude : / n o d e _ m o d u l e s / ,
17+ } ,
18+ ] ,
19+ } ,
20+ }
21+ ) ,
22+ function ( err , stats ) {
23+ if ( err ) { throw err }
24+
25+ t . notOk ( stats . hasErrors ( ) , "a good file doesn't give any error" )
26+ t . notOk ( stats . hasWarnings ( ) , "a good file doesn't give any warning" )
27+ t . end ( )
28+ } )
29+ } )
You can’t perform that action at this time.
0 commit comments