@@ -22,10 +22,36 @@ const webpackOptions = webpackFactory('development')
22
22
debug ( 'webpack options: %o' , webpackOptions )
23
23
24
24
// remove bunch of options, we just need to bundle spec files
25
- // delete webpackOptions.entry
26
- // delete webpackOptions.output
27
- // delete webpackOptions.node
28
25
delete webpackOptions . optimization
26
+ delete webpackOptions . plugins
27
+
28
+ // ESLint loader does not know about our "cy" global so it will error
29
+ // find it in the module processing rules and add global "cy" option
30
+ debug ( 'module property %o' , webpackOptions . module )
31
+
32
+ if ( webpackOptions . module && Array . isArray ( webpackOptions . module . rules ) ) {
33
+ const modulePre = webpackOptions . module . rules . find ( rule => rule . enforce === 'pre' )
34
+ if ( modulePre && Array . isArray ( modulePre . use ) ) {
35
+ debug ( 'found Pre block %o' , modulePre )
36
+
37
+ const useEslintLoader = modulePre . use . find ( use => use . loader && use . loader . includes ( 'eslint-loader' ) )
38
+ if ( useEslintLoader ) {
39
+ debug ( 'found useEslintLoader %o' , useEslintLoader )
40
+
41
+ if ( useEslintLoader . options ) {
42
+ if ( Array . isArray ( useEslintLoader . options . globals ) ) {
43
+ debug ( 'adding cy to existing globals %o' , useEslintLoader . options . globals )
44
+ useEslintLoader . options . globals . push ( 'cy' )
45
+ useEslintLoader . options . globals . push ( 'Cypress' )
46
+ } else {
47
+ debug ( 'setting new list of globals with cy and Cypress' )
48
+ useEslintLoader . options . globals = [ 'cy' , 'Cypress' ]
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
54
+
29
55
30
56
const options = {
31
57
webpackOptions,
0 commit comments