-
-
Notifications
You must be signed in to change notification settings - Fork 237
Add javascript code snippet validation #662
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
Changes from 28 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
01c79e7
Add validation for javascript expressions.
ThomasHickman 5182ab6
Merge branch 'master' into js-linting
ThomasHickman f9bcbd0
Fix unfixed merge confict
ThomasHickman 8543182
Rename jshint files add add to MANIFEST.in
ThomasHickman a320e10
Fix issues found in testing
ThomasHickman df6fe7d
Fix items in failing tests and add disable-js-validation and js-hint-…
ThomasHickman 1eac465
Merge branch 'master' into js-linting
ThomasHickman c4a6f16
draft2tool -> command_line_tool in validate_js
ThomasHickman d4b5168
Move get_data from tests to cwltool
ThomasHickman ddf4291
Fix issues found in testing
ThomasHickman b847c81
Merge branch 'master' into js-linting
ThomasHickman 4f76771
Revert "Move get_data from tests to cwltool" excluding utils.py
ThomasHickman 397711d
Add get_test_data
ThomasHickman 4f126db
Add folder checking and exception to get_data
ThomasHickman b774648
Corrected incorrect logic in get_data
ThomasHickman 149933f
Add jshint wrapper file existrance checking
ThomasHickman 1da4c43
Create cwlNodeEngineWithContext for jshint
ThomasHickman f56192c
Merge branch 'master' into js-linting
ThomasHickman 4062fb9
remove unneeded import
mr-c 915f961
include new javascript in dist
mr-c 5452b8a
Merge branch 'master' into js-linting
mr-c 89d1cdb
a little more unicode…
mr-c 55641d0
a bit more unicode
mr-c 9bd96ba
make unicode fix py2.7 compat
mr-c 202a536
Update validate_js.py
mr-c 16dc781
fix reporting of jshint expressionlib warnings
ThomasHickman dd9336f
propogate globals from each line in expression_lib
ThomasHickman b372ac4
better open
mr-c aff6564
Add copy import
ThomasHickman 583dc99
globals -> js_globals
ThomasHickman 0b514c8
Remove should_include_jshint_message
ThomasHickman af15fc0
tweak windows testing
mr-c 0783014
mock too
mr-c daac50c
turn off appveyor pytest caching
mr-c 2d54920
add nodejs to appveyor
mr-c 530b7d0
use a fixed nodejs version for appveyor
mr-c 01fe931
Try fix exec_js with context in windows
ThomasHickman a8b1266
Merge branch 'js-linting' of https://github.com/wtsi-hgi/cwltool into…
ThomasHickman b243a10
Use resource_stream for validate_js
ThomasHickman 7926be4
Revert get_data -> get_test_data
ThomasHickman 7552315
move validate_js_expressions to Process.__init__
ThomasHickman 5e08b88
Remove unused imports
ThomasHickman 50d9d8f
Correct Process type
ThomasHickman b28dfd5
Further correct type errors
ThomasHickman c295a04
Merge branch 'master' into js-linting
ThomasHickman 17fa7fc
Merge branch 'master' into js-linting
tetron 1786a7f
Merge branch 'master' into js-linting
tetron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| "use strict"; | ||
| process.stdin.setEncoding("utf8"); | ||
| var incoming = ""; | ||
| var firstInput = true; | ||
| var context; | ||
|
|
||
| process.stdin.on("data", function(chunk) { | ||
| incoming += chunk; | ||
| var i = incoming.indexOf("\n"); | ||
| if (i > -1) { | ||
| try{ | ||
| var fn = JSON.parse(incoming.substr(0, i)); | ||
| incoming = incoming.substr(i+1); | ||
| if(firstInput){ | ||
| context = require("vm").runInNewContext(fn, {}); | ||
| firstInput = false; | ||
| } | ||
| else{ | ||
| process.stdout.write(JSON.stringify(require("vm").runInNewContext(fn, context)) + "\n"); | ||
| } | ||
| } | ||
| catch(e){ | ||
| console.error(e) | ||
| } | ||
| /*strings to indicate the process has finished*/ | ||
| console.log("r1cepzbhUTxtykz5XTC4"); | ||
| console.error("r1cepzbhUTxtykz5XTC4"); | ||
| } | ||
| }); | ||
| process.stdin.on("end", process.exit); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| "use strict"; | ||
| // set a global object, in order for jshint to work | ||
| var global = this; | ||
|
|
||
| function validateJS(input) { | ||
| var jshintGlobalsObj = {}; | ||
| input.globals.forEach(function (global) { | ||
| jshintGlobalsObj[global] = true; | ||
| }) | ||
| var includewarnings; | ||
|
|
||
| if (input.options.includewarnings !== undefined) { | ||
| includewarnings = input.options.includewarnings; | ||
| delete input.options.includewarnings; | ||
| } | ||
|
|
||
| JSHINT( | ||
| input.code, | ||
| input.options, | ||
| jshintGlobalsObj | ||
| ) | ||
|
|
||
| var jshintData = JSHINT.data(); | ||
| if (jshintData.errors !== undefined) { | ||
| if (includewarnings !== undefined) { | ||
| jshintData.errors = jshintData.errors.filter(function (error) { | ||
| return includewarnings.indexOf(error.code) !== -1 || error.code[0] == "E"; | ||
| }) | ||
| } | ||
|
|
||
| jshintData.errors.forEach(function (error) { | ||
| if (error.code == "W104" || error.code == "W119") { | ||
| if (error.code == "W104"){ | ||
| var jslint_suffix = " (use 'esversion: 6') or Mozilla JS extensions (use moz)." | ||
| } | ||
| else{ | ||
| var jslint_suffix = " (use 'esversion: 6')" | ||
| } | ||
|
|
||
| error.reason = error.reason.slice(0, -jslint_suffix.length - 1) + | ||
| ". CWL only supports ES5.1"; | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| return jshintData; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Seems to be causing neverending loops on windows: https://ci.appveyor.com/project/mr-c/cwltool/build/.773-master/job/o57lcfpp9xjcrc7i#L1775