Changeset View
Changeset View
Standalone View
Standalone View
build/arclint/pyrolint/src/ESLintLinter.php
Show All 27 Lines | public function getLinterName() { | ||||
return 'ESLINT'; | return 'ESLINT'; | ||||
} | } | ||||
public function getLinterConfigurationName() { | public function getLinterConfigurationName() { | ||||
return 'eslint'; | return 'eslint'; | ||||
} | } | ||||
public function getDefaultBinary() { | public function getDefaultBinary() { | ||||
// See also the "bin" array in /.arclint | |||||
return 'eslint'; | return 'eslint'; | ||||
} | } | ||||
public function getInstallInstructions() { | public function getInstallInstructions() { | ||||
return pht( | return pht( | ||||
'Install eslint using npm install -g eslint.', | 'Install eslint from npm by running "npm install" in the /build/arclint/eslint/ directory.' | ||||
'Install the brace-rule plugin using', | ); | ||||
'npm install -g eslint-plugin-brace-rules'); | |||||
} | } | ||||
protected function getMandatoryFlags() { | protected function getMandatoryFlags() { | ||||
// If the 'eslint' was installed globally (e.g. as Jenkins CI has) then | |||||
// tell ESLint to load for plugins from the global node path. | |||||
// Otherwise, use the local install (e.g. a developer has run 'npm install' | |||||
// in their /build/eslint/ directory). Use of global install is discouraged | |||||
// for developers, but for CI we do it because that's easier to snapshot | |||||
// and re-use between builds. | |||||
if ($this->getBinary() === 'eslint') { | |||||
list($err, $stdout, $stderr) = exec_manual('npm root -g'); | list($err, $stdout, $stderr) = exec_manual('npm root -g'); | ||||
$nodePath = strtok($stdout, "\n"); | |||||
} else { | |||||
$nodePath = 'build/arclint/eslint/'; | |||||
} | |||||
return array( | return array( | ||||
'--format=json', | '--format=json', | ||||
'--no-color', | '--no-color', | ||||
'--config', | |||||
$this->config, | |||||
// This allows globally installing plugins even with eslint 6+ | |||||
'--resolve-plugins-relative-to', | '--resolve-plugins-relative-to', | ||||
strtok($stdout, "\n") | $nodePath | ||||
); | |||||
} | |||||
public function getLinterConfigurationOptions() { | |||||
$options = array( | |||||
'config' => array( | |||||
'type' => 'optional string', | |||||
'help' => pht('Link to the config file.'), | |||||
), | |||||
); | ); | ||||
return $options + parent::getLinterConfigurationOptions(); | |||||
} | |||||
public function setLinterConfigurationValue($key, $value) { | |||||
switch ($key) { | |||||
case 'config': | |||||
$this->config = $value; | |||||
return; | |||||
} | |||||
return parent::setLinterConfigurationValue($key, $value); | |||||
} | } | ||||
protected function parseLinterOutput($path, $err, $stdout, $stderr) { | protected function parseLinterOutput($path, $err, $stdout, $stderr) { | ||||
// Gate on $stderr b/c $err (exit code) is expected. | // Gate on $stderr b/c $err (exit code) is expected. | ||||
if ($stderr) { | if ($stderr) { | ||||
return false; | return false; | ||||
} | } | ||||
Show All 39 Lines |
Wildfire Games · Phabricator