From 2fd0d578507a3e976b1373e16a6b2b6945c2ec20 Mon Sep 17 00:00:00 2001 From: Ricky Reusser Date: Thu, 30 Mar 2017 18:20:25 -0400 Subject: [PATCH 1/4] Add ES5 check to syntax test --- tasks/test_syntax.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tasks/test_syntax.js b/tasks/test_syntax.js index f4591496238..da8ae3bcb9e 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,45 @@ 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 + } + }); + + // Filter out min and plotly-geo-assets.js since one is unnecessary + // and the other is super slow: + var files = fs.readdirSync(path.join(__dirname, '../dist')); + var validFiles = []; + for(var i = 0; i < files.length; i++) { + var f = files[i]; + var isMin = !/[^(min)]\.js$/.test(f); + var isGeo = /geo-assets/.test(f); + if(!isMin && !isGeo) { + validFiles.push(path.join(__dirname, '../dist', f)); + } + } + + var report = cli.executeOnFiles(validFiles); + var formatter = cli.getFormatter(); + + 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 + log('non-ES5 syntax found', ['']); + } +} + + function combineGlobs(arr) { return '{' + arr.join(',') + '}'; } From 069437fbeae7c91d7cdcacecdb4feac215c7e4b1 Mon Sep 17 00:00:00 2001 From: Ricky Reusser Date: Thu, 30 Mar 2017 18:29:46 -0400 Subject: [PATCH 2/4] Fix ES5 check error reporting --- tasks/test_syntax.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tasks/test_syntax.js b/tasks/test_syntax.js index da8ae3bcb9e..32ee36806bb 100644 --- a/tasks/test_syntax.js +++ b/tasks/test_syntax.js @@ -218,14 +218,16 @@ function assertES5() { var report = cli.executeOnFiles(validFiles); 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 - log('non-ES5 syntax found', ['']); + errors.push(''); } + + // 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 + log('es5-only syntax', errors); } From 4c8ca525e146ec58d7147b20237ff3473c122375 Mon Sep 17 00:00:00 2001 From: Ricky Reusser Date: Fri, 31 Mar 2017 10:05:33 -0400 Subject: [PATCH 3/4] Use constants in ES5 test --- tasks/test_syntax.js | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/tasks/test_syntax.js b/tasks/test_syntax.js index 32ee36806bb..521f16ac387 100644 --- a/tasks/test_syntax.js +++ b/tasks/test_syntax.js @@ -202,20 +202,10 @@ function assertES5() { } }); - // Filter out min and plotly-geo-assets.js since one is unnecessary - // and the other is super slow: - var files = fs.readdirSync(path.join(__dirname, '../dist')); - var validFiles = []; - for(var i = 0; i < files.length; i++) { - var f = files[i]; - var isMin = !/[^(min)]\.js$/.test(f); - var isGeo = /geo-assets/.test(f); - if(!isMin && !isGeo) { - validFiles.push(path.join(__dirname, '../dist', f)); - } - } + var files = constants.partialBundlePaths.map(function(f) { return f.dist; }); + files.unshift(constants.pathToPlotlyDist); - var report = cli.executeOnFiles(validFiles); + var report = cli.executeOnFiles(files); var formatter = cli.getFormatter(); var errors = []; From ad35b18c41e991789a8d7eb0ab39f451e7fb57e9 Mon Sep 17 00:00:00 2001 From: Ricky Reusser Date: Fri, 31 Mar 2017 10:14:20 -0400 Subject: [PATCH 4/4] Fix syntax test comment --- tasks/test_syntax.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tasks/test_syntax.js b/tasks/test_syntax.js index 521f16ac387..150cac24f4c 100644 --- a/tasks/test_syntax.js +++ b/tasks/test_syntax.js @@ -211,12 +211,13 @@ function assertES5() { 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(''); } - // 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 log('es5-only syntax', errors); }