@@ -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,45 @@ 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+ // Filter out min and plotly-geo-assets.js since one is unnecessary
206+ // and the other is super slow:
207+ var files = fs . readdirSync ( path . join ( __dirname , '../dist' ) ) ;
208+ var validFiles = [ ] ;
209+ for ( var i = 0 ; i < files . length ; i ++ ) {
210+ var f = files [ i ] ;
211+ var isMin = ! / [ ^ ( m i n ) ] \. j s $ / . test ( f ) ;
212+ var isGeo = / g e o - a s s e t s / . test ( f ) ;
213+ if ( ! isMin && ! isGeo ) {
214+ validFiles . push ( path . join ( __dirname , '../dist' , f ) ) ;
215+ }
216+ }
217+
218+ var report = cli . executeOnFiles ( validFiles ) ;
219+ var formatter = cli . getFormatter ( ) ;
220+
221+ if ( report . errorCount > 0 ) {
222+ console . log ( formatter ( report . results ) ) ;
223+
224+ // It doesn't work well to pass formatted logs into this,
225+ // so instead pass the empty string in a way that causes
226+ // the test to fail
227+ log ( 'non-ES5 syntax found' , [ '' ] ) ;
228+ }
229+ }
230+
231+
191232function combineGlobs ( arr ) {
192233 return '{' + arr . join ( ',' ) + '}' ;
193234}
0 commit comments