Manual:jsparse.php
MediaWiki file: jsparse.php | |
---|---|
Location: | maintenance/ |
Source code: | master • 1.39.1 • 1.38.5 • 1.35.9 |
Classes: | JSParseHelper |
DetailsEdit
jsparse.php file is a maintenance script for testing JavaScript validity using JSMin+'s parser. This is a useful feature to run parsing/syntax check on JavaScript files.
Options/ArgumentsEdit
This script takes the filenames of the files to be validated as arguments, separated by spaces.
UsageEdit
php maintenance/jsparse.php filename
Checking valid fileEdit
example.js
$( function () {
var $longList = $("#longList").addClass("grid_row");
var $leftDiv = $("<div>");
var $rightDiv = $("<div>");
$longList.append($leftDiv, $rightDiv);
});
Terminal
$ php maintenance/jsparse.php example.js example.js OK
Checking invalid fileEdit
example.js
$( function () {
var $longList = $("#longList").addClass("grid_row");
var $leftDiv = $("<div>");
var $rightDiv = $("<div>");
// Intentionally removed `);` from the end for the jsparse.php demo
$longList.append($leftDiv, $rightDiv
});
Terminal
$ php maintenance/jsparse.php example.js example.js ERROR: Parse error: Missing ) in parenthetical in file 'example.js' on line 7 Failed.
Common errorEdit
- $filename ERROR: could not read file
This error occurs when the file does not exist or the user running the script does not have permission to read the file.
If the file does exist, check the file permissions. If you are root user, then you can run the script with sudo.
See alsoEdit
- Manual:eval.php (PHP interpreter)
- Manual:How to debug
- ResourceLoader/Architecture#Debug mode