Skip to content

Commit ef56623

Browse files
committed
split syntax task and run no-es6-dist on true publish files
1 parent b71e70e commit ef56623

File tree

4 files changed

+58
-35
lines changed

4 files changed

+58
-35
lines changed

Diff for: .circleci/config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ jobs:
175175
- run:
176176
name: Test certain bundles against function constructors
177177
command: npm run no-new-func
178+
- run:
179+
name: Test plotly bundles against es6
180+
command: npm run no-es6-dist
178181

179182
workflows:
180183
version: 2

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"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)",
3535
"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)",
3636
"no-dup-keys": "eslint --no-ignore --no-eslintrc --no-inline-config --rule '{no-dupe-keys: error}' $(find dist -type f -iname '*.js' | grep plotly)",
37+
"no-es6-dist": "node tasks/no_es6_dist.js",
3738
"docker": "node tasks/docker.js",
3839
"pretest": "node tasks/pretest.js",
3940
"test-jasmine": "karma start test/jasmine/karma.conf.js",

Diff for: tasks/no_es6_dist.js

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
var eslint = require('eslint');
2+
var constants = require('./util/constants');
3+
var EXIT_CODE = 0;
4+
5+
assertES5();
6+
7+
// Ensure no ES6 has snuck through into the build:
8+
function assertES5() {
9+
var CLIEngine = eslint.CLIEngine;
10+
11+
var cli = new CLIEngine({
12+
allowInlineConfig: false,
13+
useEslintrc: false,
14+
ignore: false,
15+
parserOptions: {
16+
ecmaVersion: 5
17+
}
18+
});
19+
20+
var files = constants.partialBundlePaths.map(function(f) { return f.dist; });
21+
files.unshift(constants.pathToPlotlyDist);
22+
23+
var report = cli.executeOnFiles(files);
24+
var formatter = cli.getFormatter();
25+
26+
var errors = [];
27+
if(report.errorCount > 0) {
28+
console.log(formatter(report.results));
29+
30+
// It doesn't work well to pass formatted logs into this,
31+
// so instead pass the empty string in a way that causes
32+
// the test to fail
33+
errors.push('');
34+
}
35+
36+
log('es5-only syntax', errors);
37+
}
38+
39+
40+
function log(name, logs) {
41+
if(logs.length) {
42+
console.error('test-syntax error [' + name + ']');
43+
console.error(logs.join('\n'));
44+
EXIT_CODE = 1;
45+
} else {
46+
console.log('ok ' + name);
47+
}
48+
}
49+
50+
process.on('exit', function() {
51+
if(EXIT_CODE) {
52+
throw new Error('test syntax failed.');
53+
}
54+
});

Diff for: tasks/test_syntax.js

-35
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ var falafel = require('falafel');
55
var glob = require('glob');
66
var madge = require('madge');
77
var readLastLines = require('read-last-lines');
8-
var eslint = require('eslint');
98
var trueCasePath = require('true-case-path').trueCasePathSync;
109

1110
var common = require('./util/common');
@@ -27,7 +26,6 @@ assertSrcContents();
2726
assertFileNames();
2827
assertTrailingNewLine();
2928
assertCircularDeps();
30-
assertES5();
3129

3230

3331
// check for for focus and exclude jasmine blocks
@@ -299,39 +297,6 @@ function assertCircularDeps() {
299297
});
300298
}
301299

302-
// Ensure no ES6 has snuck through into the build:
303-
function assertES5() {
304-
var CLIEngine = eslint.CLIEngine;
305-
306-
var cli = new CLIEngine({
307-
allowInlineConfig: false,
308-
useEslintrc: false,
309-
ignore: false,
310-
parserOptions: {
311-
ecmaVersion: 5
312-
}
313-
});
314-
315-
var files = constants.partialBundlePaths.map(function(f) { return f.dist; });
316-
files.unshift(constants.pathToPlotlyBuild, constants.pathToPlotlyDist);
317-
318-
var report = cli.executeOnFiles(files);
319-
var formatter = cli.getFormatter();
320-
321-
var errors = [];
322-
if(report.errorCount > 0) {
323-
console.log(formatter(report.results));
324-
325-
// It doesn't work well to pass formatted logs into this,
326-
// so instead pass the empty string in a way that causes
327-
// the test to fail
328-
errors.push('');
329-
}
330-
331-
log('es5-only syntax', errors);
332-
}
333-
334-
335300
function combineGlobs(arr) {
336301
return '{' + arr.join(',') + '}';
337302
}

0 commit comments

Comments
 (0)