1

I need to make a script that will analyse javascript files for specific errors in the code.

One of the first envisioned ways of doing so is by building an abstract syntax tree of the files. Is this doable with nodejs or any other tool? (preferably in a scripting language, or better yet in javascript itself, or python).

Or is there even a better method that I could use to analyse javascript code?

EDIT: As pointed out in some answers, JSLint and JSHint are not the tools I'm looking for. I use them as well, of course, but they are not specific enough for my requirements.

aspyct
  • 3,625
  • 7
  • 36
  • 61

3 Answers3

0

A better method to go for some pre-written tool instead of trying to reinvent the wheel.

halkujabra
  • 2,844
  • 3
  • 25
  • 35
  • What tool do you suggest? – aspyct Sep 19 '13 at 10:57
  • I reinvented the wheel which was not existing in Javascript/Typescript/node in a proper way. The library is accessible with npm i @jlguenego/syntax-analysis. The library allows parsing with most of all known methods: LL(k), LR0, LR1, LALR, SLR, etc. I will continue to maintain it by adding other methods (GLR, Earley, LR(k), etc.) – jlguenego Feb 16 '21 at 16:01
  • However, @jlguenego/syntax-analysis does not provide the context-free-grammar for any language (except json for testing a simple grammar). If you want specifically work with Javascript syntax, I think Babel is the most adapted. Or Monaco (the VSCode utility for editing code). – jlguenego Feb 16 '21 at 16:12
0

Somebody already awnsered this question on another stackoverflow page

JavaScript Source Code Analyzer

Community
  • 1
  • 1
Mordalthunder
  • 256
  • 1
  • 3
  • I'm actually not looking for JSLint or JSHint (which I use already), as my needs are far more specific than what these can provide. – aspyct Sep 19 '13 at 11:11
0

Looks like esprima - http://esprima.org/ and the Parser API is what I'm looking for :)

aspyct
  • 3,625
  • 7
  • 36
  • 61