@@ -5,6 +5,7 @@ var falafel = require('falafel');
5
5
var glob = require ( 'glob' ) ;
6
6
var madge = require ( 'madge' ) ;
7
7
var readLastLines = require ( 'read-last-lines' ) ;
8
+ var eslint = require ( 'eslint' ) ;
8
9
9
10
var constants = require ( './util/constants' ) ;
10
11
var srcGlob = path . join ( constants . pathToSrc , '**/*.js' ) ;
@@ -20,6 +21,7 @@ assertSrcContents();
20
21
assertFileNames ( ) ;
21
22
assertTrailingNewLine ( ) ;
22
23
assertCircularDeps ( ) ;
24
+ assertES5 ( ) ;
23
25
24
26
25
27
// check for for focus and exclude jasmine blocks
@@ -188,6 +190,38 @@ function assertCircularDeps() {
188
190
} ) ;
189
191
}
190
192
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
+
191
225
function combineGlobs ( arr ) {
192
226
return '{' + arr . join ( ',' ) + '}' ;
193
227
}
0 commit comments