'ArcanistJSHintLinterTestCase' => 'lint/linter/__tests__/ArcanistJSHintLinterTestCase.php',
'ArcanistJSONLintLinter' => 'lint/linter/ArcanistJSONLintLinter.php',
'ArcanistJSONLintLinterTestCase' => 'lint/linter/__tests__/ArcanistJSONLintLinterTestCase.php',
+ 'ArcanistJSONLinter' => 'lint/linter/ArcanistJSONLinter.php',
+ 'ArcanistJSONLinterTestCase' => 'lint/linter/__tests__/ArcanistJSONLinterTestCase.php',
'ArcanistJscsLinter' => 'lint/linter/ArcanistJscsLinter.php',
'ArcanistJscsLinterTestCase' => 'lint/linter/__tests__/ArcanistJscsLinterTestCase.php',
'ArcanistLandWorkflow' => 'workflow/ArcanistLandWorkflow.php',
'ArcanistJSHintLinterTestCase' => 'ArcanistArcanistLinterTestCase',
'ArcanistJSONLintLinter' => 'ArcanistExternalLinter',
'ArcanistJSONLintLinterTestCase' => 'ArcanistArcanistLinterTestCase',
+ 'ArcanistJSONLinter' => 'ArcanistLinter',
+ 'ArcanistJSONLinterTestCase' => 'ArcanistArcanistLinterTestCase',
'ArcanistJscsLinter' => 'ArcanistExternalLinter',
'ArcanistJscsLinterTestCase' => 'ArcanistArcanistLinterTestCase',
'ArcanistLandWorkflow' => 'ArcanistBaseWorkflow',
--- /dev/null
+<?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());
+ }
+ }
+
+}
--- /dev/null
+<?php
+
+final class ArcanistJSONLinterTestCase extends ArcanistArcanistLinterTestCase {
+
+ public function testJSONLinter() {
+ $this->executeTestsInDirectory(
+ dirname(__FILE__).'/jsonlint/',
+ new ArcanistJSONLinter());
+ }
+
+}