From: Joshua Spence Date: Sat, 17 May 2014 04:42:52 +0000 (-0700) Subject: Add some `.arclint` configuration options for `ArcanistJSHintLinter`. X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=8cd9cb104798c12c42eaa9a64103e626a462819a;p=arcanist.git Add some `.arclint` configuration options for `ArcanistJSHintLinter`. Summary: Allow `.jshintrc` and `.jshintignore` paths to be passed to `jshint`. Ref T2039. Test Plan: Added the `jshintrc` and `jshintignore` keys to an `.arclint` file that was configured to use `ArcanistJSHintLinter`. Ran `arc lint --trace` and inspected the flags that were passed to `jshint`. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: john.snow, epriestley, Korvin Maniphest Tasks: T2039, T5085 Differential Revision: https://secure.phabricator.com/D9112 --- diff --git a/src/lint/linter/ArcanistJSHintLinter.php b/src/lint/linter/ArcanistJSHintLinter.php index d05bcecc..566cf1e8 100644 --- 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,48 @@ final class ArcanistJSHintLinter extends ArcanistExternalLinter { } 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) { + switch ($key) { + case 'jshint.jshintignore': + $this->jshintignore = $value; + return; + + case 'jshint.jshintrc': + $this->jshintrc = $value; + return; + } + + return parent::setLinterConfigurationValue($key, $value); } protected function getDefaultFlags() {