diff --git a/src/lint/linter/ArcanistJSHintLinter.php b/src/lint/linter/ArcanistJSHintLinter.php --- a/src/lint/linter/ArcanistJSHintLinter.php +++ b/src/lint/linter/ArcanistJSHintLinter.php @@ -5,6 +5,9 @@ */ final class ArcanistJSHintLinter extends ArcanistExternalLinter { + private $jshintignore; + private $jshintrc; + public function getInfoName() { return 'JSHint'; } @@ -74,9 +77,61 @@ } protected function getMandatoryFlags() { - return array( - '--reporter='.dirname(realpath(__FILE__)).'/reporter.js', + $options = array(); + + $options[] = '--reporter='.dirname(realpath(__FILE__)).'/reporter.js'; + + if ($this->jshintrc) { + $options[] = '--config='.$this->jshintrc; + } + + if ($this->jshintignore) { + $options[] = '--exclude-path='.$this->jshintignore; + } + + return $options; + } + + public function getLinterConfigurationOptions() { + $options = array( + 'jshint.jshintignore' => array( + 'type' => 'optional string', + 'help' => pht('Pass in a custom jshintignore file path.'), + ), + 'jshint.jshintrc' => array( + 'type' => 'optional string', + 'help' => pht('Custom configuration file.'), + ), ); + + return $options + parent::getLinterConfigurationOptions(); + } + + public function setLinterConfigurationValue($key, $value) { + $working_copy = $this->getEngine()->getWorkingCopy(); + $root = $working_copy->getProjectRoot(); + + switch ($key) { + case 'jshint.jshintignore': + $path = Filesystem::resolvePath($value, $root); + + if (Filesystem::pathExists($path)) { + $this->jshintignore = $path; + return; + } + throw new Exception(pht('File not found: %s', $value)); + + case 'jshint.jshintrc': + $path = Filesystem::resolvePath($value, $root); + + if (Filesystem::pathExists($path)) { + $this->jshintrc = $path; + return; + } + throw new Exception(pht('File not found: %s', $value)); + } + + return parent::setLinterConfigurationValue($key, $value); } protected function getDefaultFlags() {