-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Changes from 2 commits
2fd0d57
069437f
4c8ca52
ad35b18
8b0c892
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,47 @@ 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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Too bad There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's always the possibility of just testing the regular bundle only since there's tons of duplication between the bundles, but I'd need to investigate to figure out which parts are a subset of which parts. |
||
var formatter = cli.getFormatter(); | ||
|
||
var errors = []; | ||
if(report.errorCount > 0) { | ||
console.log(formatter(report.results)); | ||
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); | ||
} | ||
|
||
|
||
function combineGlobs(arr) { | ||
return '{' + arr.join(',') + '}'; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've negated a negation… that's silly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use this list, something like:
looks easier to read to me. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds great. Didn't know it was a thing. Will update once confirmed it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Included
plotly.js
but left out withwith-meta
to save a few seconds.