]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Add some `.arclint` configuration options for `ArcanistJSHintLinter`.
authorJoshua Spence <josh@joshuaspence.com>
Sat, 17 May 2014 04:42:52 +0000 (21:42 -0700)
committerepriestley <git@epriestley.com>
Sat, 17 May 2014 04:42:52 +0000 (21:42 -0700)
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

index d05bcecc7bb594bd6a645a35edf5101c2c140372..566cf1e89fe77c592daa786cd52883591e488bc5 100644 (file)
@@ -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() {