Skip to content

Commit

Permalink
Merge pull request #5471 from plotly/publish-dist-no-es6
Browse files Browse the repository at this point in the history
Split syntax task and run no-es6-dist on true publish files
  • Loading branch information
archmoj authored Feb 4, 2021
2 parents b71e70e + ef56623 commit 89e27be
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ jobs:
- run:
name: Test certain bundles against function constructors
command: npm run no-new-func
- run:
name: Test plotly bundles against es6
command: npm run no-es6-dist

workflows:
version: 2
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"no-new-func": "eslint --no-ignore --no-eslintrc --no-inline-config --rule '{no-new-func: error}' $(find dist -type f -iname '*.js' | grep -v plotly-gl* | grep -v plotly-with-meta.* | grep -v plotly.js | grep -v plotly.min.js | grep -v MathJax.js)",
"no-bad-char": "eslint --no-ignore --no-eslintrc --no-inline-config --rule '{no-misleading-character-class: error}' $(find dist -type f -iname '*.js' | grep plotly)",
"no-dup-keys": "eslint --no-ignore --no-eslintrc --no-inline-config --rule '{no-dupe-keys: error}' $(find dist -type f -iname '*.js' | grep plotly)",
"no-es6-dist": "node tasks/no_es6_dist.js",
"docker": "node tasks/docker.js",
"pretest": "node tasks/pretest.js",
"test-jasmine": "karma start test/jasmine/karma.conf.js",
Expand Down
54 changes: 54 additions & 0 deletions tasks/no_es6_dist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
var eslint = require('eslint');
var constants = require('./util/constants');
var EXIT_CODE = 0;

assertES5();

// Ensure no ES6 has snuck through into the build:
function assertES5() {
var CLIEngine = eslint.CLIEngine;

var cli = new CLIEngine({
allowInlineConfig: false,
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 log(name, logs) {
if(logs.length) {
console.error('test-syntax error [' + name + ']');
console.error(logs.join('\n'));
EXIT_CODE = 1;
} else {
console.log('ok ' + name);
}
}

process.on('exit', function() {
if(EXIT_CODE) {
throw new Error('test syntax failed.');
}
});
35 changes: 0 additions & 35 deletions tasks/test_syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ var falafel = require('falafel');
var glob = require('glob');
var madge = require('madge');
var readLastLines = require('read-last-lines');
var eslint = require('eslint');
var trueCasePath = require('true-case-path').trueCasePathSync;

var common = require('./util/common');
Expand All @@ -27,7 +26,6 @@ assertSrcContents();
assertFileNames();
assertTrailingNewLine();
assertCircularDeps();
assertES5();


// check for for focus and exclude jasmine blocks
Expand Down Expand Up @@ -299,39 +297,6 @@ function assertCircularDeps() {
});
}

// Ensure no ES6 has snuck through into the build:
function assertES5() {
var CLIEngine = eslint.CLIEngine;

var cli = new CLIEngine({
allowInlineConfig: false,
useEslintrc: false,
ignore: false,
parserOptions: {
ecmaVersion: 5
}
});

var files = constants.partialBundlePaths.map(function(f) { return f.dist; });
files.unshift(constants.pathToPlotlyBuild, 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

0 comments on commit 89e27be

Please sign in to comment.