Skip to content
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

Split syntax task and run no-es6-dist on true publish files #5471

Merged
merged 1 commit into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
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
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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note I removed build from this line:

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 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);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🌴 Can we pull this out into something like ./util/log? I see it changes EXIT_CODE but we can just return 1 and call it like EXIT_CODE += log('es5-only syntax', errors);


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