Page MenuHomePhabricator

D12198.id32757.diff
No OneTemporary

D12198.id32757.diff

diff --git a/src/lint/linter/ArcanistESLintLinter.php b/src/lint/linter/ArcanistESLintLinter.php
--- a/src/lint/linter/ArcanistESLintLinter.php
+++ b/src/lint/linter/ArcanistESLintLinter.php
@@ -2,6 +2,9 @@
final class ArcanistESLintLinter extends ArcanistExternalLinter {
+ private $eslintenv;
+ private $eslintconfig;
+
public function getInfoName() {
return 'ESLint';
}
@@ -14,8 +17,18 @@
return pht('ESLint is a linter for JavaScript source files.');
}
+ public function getVersion() {
+ $output = exec('eslint --version');
+
+ if (strpos($output, 'command not found') !== false) {
+ return false;
+ }
+
+ return $output;
+ }
+
public function getLinterName() {
- return 'ESLint';
+ return 'ESLINT';
}
public function getLinterConfigurationName() {
@@ -27,11 +40,51 @@
}
public function getInstallInstructions() {
- return pht('Install ESLint using `npm install -g eslint`.');
+ return pht('Install ESLint using `%s`.', 'npm install -g eslint');
+ }
+
+ public function getMandatoryFlags() {
+ $options = array();
+
+ $options[] = '--format=stylish';
+
+ if ($this->eslintenv) {
+ $options[] = '--env='.$this->eslintenv;
+ }
+
+ if ($this->eslintconfig) {
+ $options[] = '--config='.$this->eslintconfig;
+ }
+
+ return $options;
}
- protected function canCustomizeLintSeverities() {
- return true;
+ public function getLinterConfigurationOptions() {
+ $options = array(
+ 'eslint.eslintenv' => array(
+ 'type' => 'optional string',
+ 'help' => pht('enables specific environments.'),
+ ),
+ 'eslint.eslintconfig' => array(
+ 'type' => 'optional string',
+ 'help' => pht('config file to use the default is .eslint.'),
+ ),
+ );
+ return $options + parent::getLinterConfigurationOptions();
+ }
+
+ public function setLinterConfigurationValue($key, $value) {
+
+ switch ($key) {
+ case 'eslint.eslintenv':
+ $this->eslintenv = $value;
+ return;
+ case 'eslint.eslintconfig':
+ $this->eslintconfig = $value;
+ return;
+ }
+
+ return parent::setLinterConfigurationValue($key, $value);
}
protected function parseLinterOutput($path, $err, $stdout, $stderr) {

File Metadata

Mime Type
text/plain
Expires
Fri, Apr 25, 12:33 AM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7741010
Default Alt Text
D12198.id32757.diff (2 KB)

Event Timeline