From 8cd9cb104798c12c42eaa9a64103e626a462819a Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Fri, 16 May 2014 21:42:52 -0700 Subject: [PATCH] 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 --- src/lint/linter/ArcanistJSHintLinter.php | 46 ++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) 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() {