Manual:Jsparse.php
Arquivo MediaWiki: jsparse.php | |
---|---|
Local: | maintenance/ |
Código fonte: | master • 1.43.0 • 1.42.4 • 1.39.11 |
Classes: | JSParseHelper |
Detalhes
O arquivo jsparse.php é um script de manutenção para testes dos analisadores de validação do JavaScript, usando o analisador JSMin+. This is a useful feature to run parsing/syntax check on JavaScript files.
Options/Arguments
This script takes the filenames of the files to be validated as arguments, separated by spaces.
Usage
php maintenance/run.php jsparse filename
In MediaWiki version 1.39.10 and earlier, you must invoke maintenance scripts using
php maintenance/scriptName.php
instead of php maintenance/run.php scriptName
.Checking valid file
example.js
$( function () {
var $longList = $("#longList").addClass("grid_row");
var $leftDiv = $("<div>");
var $rightDiv = $("<div>");
$longList.append($leftDiv, $rightDiv);
});
Terminal
$ php maintenance/run.php jsparse example.js example.js OK
Checking invalid file
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/run.php jsparse example.js example.js ERROR: Parse error: Missing ) in parenthetical in file 'example.js' on line 7 Failed.
Common error
- $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 also
- Manual:eval.php (PHP interpreter)
- Manual:How to debug
- ResourceLoader/Architecture#Debug mode