Page MenuHomePhabricator

D9112.id21649.diff
No OneTemporary

D9112.id21649.diff

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,63 @@
}
protected function getMandatoryFlags() {
- return array(
- '--reporter='.dirname(realpath(__FILE__)).'/reporter.js',
+ $options = array();
+
+ $options[] = csprintf(
+ '--reporter=%s',
+ dirname(realpath(__FILE__)).'/reporter.js');
+
+ if ($this->jshintrc) {
+ $options[] = csprintf('--config=%s', $this->jshintrc);
+ }
+
+ if ($this->jshintignore) {
+ $options[] = csprintf('--exclude-path=%s', $this->jshintignore);
+ }
+
+ return $options;
+ }
+
+ public function getLinterConfigurationOptions() {
+ $options = array(
+ 'jshintignore' => array(
+ 'type' => 'optional string',
+ 'help' => pht('Pass in a custom jshintignore file path.'),
+ ),
+ '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 'jshintignore':
+ $path = Filesystem::resolvePath($value, $root);
+
+ if (Filesystem::pathExists($path)) {
+ $this->jshintignore = $path;
+ return;
+ }
+ throw new Exception(pht('File not found: %s', $value));
+
+ case '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() {
@@ -86,7 +143,7 @@
$config = $this->getDeprecatedConfiguration('lint.jshint.config');
if ($config) {
- $options[] = '--config='.$config;
+ $options[] = csprintf('--config=%s', $config);
}
return $options;

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 16, 11:08 PM (5 d, 20 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7707805
Default Alt Text
D9112.id21649.diff (2 KB)

Event Timeline