diff --git a/tasks/test_syntax.js b/tasks/test_syntax.js index f4591496238..150cac24f4c 100644 --- a/tasks/test_syntax.js +++ b/tasks/test_syntax.js @@ -5,6 +5,7 @@ var falafel = require('falafel'); var glob = require('glob'); var madge = require('madge'); var readLastLines = require('read-last-lines'); +var eslint = require('eslint'); var constants = require('./util/constants'); var srcGlob = path.join(constants.pathToSrc, '**/*.js'); @@ -20,6 +21,7 @@ assertSrcContents(); assertFileNames(); assertTrailingNewLine(); assertCircularDeps(); +assertES5(); // check for for focus and exclude jasmine blocks @@ -188,6 +190,38 @@ function assertCircularDeps() { }); } +// Ensure no ES6 has snuck through into the build: +function assertES5() { + var CLIEngine = eslint.CLIEngine; + + var cli = new CLIEngine({ + useEslintrc: false, + ignore: false, + parserOptions: { + ecmaVersion: 5 + } + }); + + var files = constants.partialBundlePaths.map(function(f) { return f.dist; }); + files.unshift(constants.pathToPlotlyDist); + + var report = cli.executeOnFiles(files); + var formatter = cli.getFormatter(); + + var errors = []; + if(report.errorCount > 0) { + console.log(formatter(report.results)); + + // It doesn't work well to pass formatted logs into this, + // so instead pass the empty string in a way that causes + // the test to fail + errors.push(''); + } + + log('es5-only syntax', errors); +} + + function combineGlobs(arr) { return '{' + arr.join(',') + '}'; }