@@ -5,6 +5,7 @@ var falafel = require('falafel');
55var glob = require ( 'glob' ) ;
66var madge = require ( 'madge' ) ;
77var readLastLines = require ( 'read-last-lines' ) ;
8+ var eslint = require ( 'eslint' ) ;
89
910var constants = require ( './util/constants' ) ;
1011var srcGlob = path . join ( constants . pathToSrc , '**/*.js' ) ;
@@ -20,6 +21,7 @@ assertSrcContents();
2021assertFileNames ( ) ;
2122assertTrailingNewLine ( ) ;
2223assertCircularDeps ( ) ;
24+ assertES5 ( ) ;
2325
2426
2527// check for for focus and exclude jasmine blocks
@@ -188,6 +190,38 @@ function assertCircularDeps() {
188190 } ) ;
189191}
190192
193+ // Ensure no ES6 has snuck through into the build:
194+ function assertES5 ( ) {
195+ var CLIEngine = eslint . CLIEngine ;
196+
197+ var cli = new CLIEngine ( {
198+ useEslintrc : false ,
199+ ignore : false ,
200+ parserOptions : {
201+ ecmaVersion : 5
202+ }
203+ } ) ;
204+
205+ var files = constants . partialBundlePaths . map ( function ( f ) { return f . dist ; } ) ;
206+ files . unshift ( constants . pathToPlotlyDist ) ;
207+
208+ var report = cli . executeOnFiles ( files ) ;
209+ var formatter = cli . getFormatter ( ) ;
210+
211+ var errors = [ ] ;
212+ if ( report . errorCount > 0 ) {
213+ console . log ( formatter ( report . results ) ) ;
214+
215+ // It doesn't work well to pass formatted logs into this,
216+ // so instead pass the empty string in a way that causes
217+ // the test to fail
218+ errors . push ( '' ) ;
219+ }
220+
221+ log ( 'es5-only syntax' , errors ) ;
222+ }
223+
224+
191225function combineGlobs ( arr ) {
192226 return '{' + arr . join ( ',' ) + '}' ;
193227}
0 commit comments