Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to verify JavaScript code is valid in C#

I need to take some non-trivial javascript and ensure that all code paths have code that is valid. For example:

var num = 1;
if (num == 2) {
    badFunctionName();
}

and I need to do this from C#. On top of validating it, I need to produce nice error messages explaining line number and column number of bad code.

Any ideas on the best way to do this?

UPDATE - Corrected the confusion by saying javascript syntax. My intent is to ensure that all execution paths have valid javascript code (probably as defined by jslint).

like image 570
Leslie Hanks Avatar asked Nov 23 '25 16:11

Leslie Hanks


1 Answers

Use eslint to validate your Javascript. Rules are configurable and pluggable.

like image 101
Jared Dykstra Avatar answered Nov 26 '25 06:11

Jared Dykstra



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!