1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2025-01-26 06:28:19 +01:00
phorge-arcanist/src/lint/linter/ArcanistJSONLinter.php
Joshua Spence cf998db5e0 Add a native JSON linter.
Summary:
Ref T5297. Utilize `PhutilJSONParser` to create a native JSON linter (native in that it is pure PHP with no external dependencies).

Since [[https://github.com/Seldaek/jsonlint | JsonLint]] is literally a PHP port of [[https://github.com/zaach/jsonlint | jsonlint]], I figured that we should also deprecate `ArcanistJSONLintLinter`. `ArcanistJSONLinter` //should// behave identically to `ArcanistJSONLintLinter`.

Depends on D9634.

Test Plan: Ran the `ArcanistJSONLintLinter` unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T5297

Differential Revision: https://secure.phabricator.com/D9628
2014-06-22 06:41:22 +10:00

39 lines
757 B
PHP

<?php
/**
* A linter for JSON files.
*/
final class ArcanistJSONLinter extends ArcanistLinter {
public function getInfoName() {
return 'JSON Lint';
}
public function getInfoDescription() {
return pht('Detect syntax errors in JSON files.');
}
public function getLinterName() {
return 'JSON';
}
public function getLinterConfigurationName() {
return 'json';
}
public function lintPath($path) {
$data = $this->getData($path);
try {
$parser = new PhutilJSONParser();
$parser->parse($data);
} catch (PhutilJSONParserException $ex) {
$this->raiseLintAtLine(
$ex->getSourceLine(),
$ex->getSourceChar(),
$this->getLinterName(),
$ex->getMessage());
}
}
}