Open oroojlooy opened 1 year ago
What you're looking for is a JavaScript AST parser library.
From a quick search, https://pypi.org/project/esprima/ is a native Python package on pip that can do the parsing.
If you want to use something from the JS side (that maybe more up to date/maintained), you can checkout the TypeScript AST parser, or use Babel's parser, with JSPyBridge usage demonstrated here:
I have bunch of JavaScript functions, all loaded in memory inside a python code, and I need to validate their syntax without writing them down in .js files. I was looking for a python package that could perform this task for me, and found this package. I tried to use
javascript
package for my goal, but was not sure if there is any way that I could only check syntax with that in python.P.S.: JSHint/prettier work OK if I write each function in a file and then call something like os.system("jshint --verbose sample.js"), but writing the js functions in file is expensive and takes a lot of time. So, looking for a method/package that can do the same without writing the codes in file.