Skip to content

Add ES5 check to syntax test #1540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 31, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions tasks/test_syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -20,6 +21,7 @@ assertSrcContents();
assertFileNames();
assertTrailingNewLine();
assertCircularDeps();
assertES5();


// check for for focus and exclude jasmine blocks
Expand Down Expand Up @@ -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(',') + '}';
}
Expand Down