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

Add ES5 check to syntax test #1540

merged 5 commits into from
Mar 31, 2017

Conversation

rreusser
Copy link
Contributor

@rreusser rreusser commented Mar 30, 2017

See #1539. Uses another eslint pass that applies no rules except for an ecmaVersion: 5 parser setting. Before the const fix, this change causes plotly-latest to return:

$ npm run test-syntax

/Users/rreusser/plotly/plotly.js/dist/plotly-gl2d.js
  435:1  error  Parsing error: The keyword 'const' is reserved

/Users/rreusser/plotly/plotly.js/dist/plotly-gl3d.js
  1105:1  error  Parsing error: The keyword 'const' is reserved

/Users/rreusser/plotly/plotly.js/dist/plotly-with-meta.js
  1916:1  error  Parsing error: The keyword 'const' is reserved

/Users/rreusser/plotly/plotly.js/dist/plotly.js
  1916:1  error  Parsing error: The keyword 'const' is reserved

✖ 4 problems (4 errors, 0 warnings)

test-syntax error [es5-only syntax]

ok no jasmine suites focus/exclude blocks
ok circular dependencies: 17
ok correct headers and contents in lib/ and src/
ok lower case only file names
ok trailing new line character
/Users/rreusser/plotly/plotly.js/tasks/test_syntax.js:250
        throw new Error('test syntax failed.');
        ^

Error: test syntax failed.
    at process.<anonymous> (/Users/rreusser/plotly/plotly.js/tasks/test_syntax.js:250:15)
    at emitOne (events.js:96:13)
    at process.emit (events.js:188:7)

After fixing:

$ npm run test-syntax

ok es5-only syntax
ok no jasmine suites focus/exclude blocks
ok circular dependencies: 17
ok correct headers and contents in lib/ and src/
ok lower case only file names
ok trailing new line character

@rreusser
Copy link
Contributor Author

Note: CI failure can be considered a success. 🎉

var validFiles = [];
for(var i = 0; i < files.length; i++) {
var f = files[i];
var isMin = !/[^(min)]\.js$/.test(f);
Copy link
Contributor Author

@rreusser rreusser Mar 30, 2017

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.

Copy link
Contributor

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:

var validFiles = constants.partialBundlePaths(function(p) { return p.dist; });
validFiles  = validFiles.concat(constants.pathToPlotlyDist)l

var report = cli.executeOnFiles(validFiles);
// ...

looks easier to read to me. Thoughts?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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 with with-meta to save a few seconds.

@etpinard etpinard mentioned this pull request Mar 31, 2017
}
}

var report = cli.executeOnFiles(validFiles);
Copy link
Contributor

Choose a reason for hiding this comment

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

Too bad eslint can't do this in an async way. This does slow down test-syntax a lot. Oh well, it's worth it 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

@rreusser
Copy link
Contributor Author

Fixed file lookup. FYI you can just switch ecmaVersion between 5 an 6 to test success/failure.

@etpinard
Copy link
Contributor

etpinard commented Mar 31, 2017

💃 after merging master

@rreusser rreusser merged commit 7f63e29 into master Mar 31, 2017
@rreusser rreusser deleted the test-es5-syntax branch March 31, 2017 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants