Skip to content

Commit 7f63e29

Browse files
authored
Merge pull request #1540 from plotly/test-es5-syntax
Add ES5 check to syntax test
2 parents 627aeab + 8b0c892 commit 7f63e29

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tasks/test_syntax.js

+34
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var falafel = require('falafel');
55
var glob = require('glob');
66
var madge = require('madge');
77
var readLastLines = require('read-last-lines');
8+
var eslint = require('eslint');
89

910
var constants = require('./util/constants');
1011
var srcGlob = path.join(constants.pathToSrc, '**/*.js');
@@ -20,6 +21,7 @@ assertSrcContents();
2021
assertFileNames();
2122
assertTrailingNewLine();
2223
assertCircularDeps();
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+
191225
function combineGlobs(arr) {
192226
return '{' + arr.join(',') + '}';
193227
}

0 commit comments

Comments
 (0)