Changeset View
Changeset View
Standalone View
Standalone View
src/lint/linter/ArcanistLesscLinter.php
| Show All 14 Lines | final class ArcanistLesscLinter extends ArcanistExternalLinter { | ||||
| const LINT_OPERATION_ERROR = 5; | const LINT_OPERATION_ERROR = 5; | ||||
| const LINT_PARSE_ERROR = 6; | const LINT_PARSE_ERROR = 6; | ||||
| const LINT_SYNTAX_ERROR = 7; | const LINT_SYNTAX_ERROR = 7; | ||||
| private $strictMath = false; | private $strictMath = false; | ||||
| private $strictUnits = false; | private $strictUnits = false; | ||||
| public function getInfoName() { | public function getInfoName() { | ||||
| return pht('Less'); | return 'Less'; | ||||
| } | } | ||||
| public function getInfoURI() { | public function getInfoURI() { | ||||
| return 'https://lesscss.org/'; | return 'https://lesscss.org/'; | ||||
| } | } | ||||
| public function getInfoDescription() { | public function getInfoDescription() { | ||||
| return pht( | return pht( | ||||
| 'Use the `--lint` mode provided by `lessc` to detect errors in Less '. | 'Use the `%s` mode provided by `%s` to detect errors in '. | ||||
| 'source files.'); | 'Less source files.', | ||||
| '--lint', | |||||
| 'lessc'); | |||||
| } | } | ||||
| public function getLinterName() { | public function getLinterName() { | ||||
| return 'LESSC'; | return 'LESSC'; | ||||
| } | } | ||||
| public function getLinterConfigurationName() { | public function getLinterConfigurationName() { | ||||
| return 'lessc'; | return 'lessc'; | ||||
| ▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | public function getVersion() { | ||||
| if (preg_match($regex, $stdout, $matches)) { | if (preg_match($regex, $stdout, $matches)) { | ||||
| $version = $matches['version']; | $version = $matches['version']; | ||||
| } else { | } else { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| public function getInstallInstructions() { | public function getInstallInstructions() { | ||||
| return pht('Install lessc using `npm install -g less`.'); | return pht('Install lessc using `%s`.', 'npm install -g less'); | ||||
| } | } | ||||
| protected function getMandatoryFlags() { | protected function getMandatoryFlags() { | ||||
| return array( | return array( | ||||
| '--lint', | '--lint', | ||||
| '--no-color', | '--no-color', | ||||
| '--strict-math='.($this->strictMath ? 'on' : 'off'), | '--strict-math='.($this->strictMath ? 'on' : 'off'), | ||||
| '--strict-units='.($this->strictUnits ? 'on' : 'off'), | '--strict-units='.($this->strictUnits ? 'on' : 'off'), | ||||
| Show All 39 Lines | foreach ($lines as $line) { | ||||
| $code = self::LINT_PARSE_ERROR; | $code = self::LINT_PARSE_ERROR; | ||||
| break; | break; | ||||
| case 'SyntaxError': | case 'SyntaxError': | ||||
| $code = self::LINT_SYNTAX_ERROR; | $code = self::LINT_SYNTAX_ERROR; | ||||
| break; | break; | ||||
| default: | default: | ||||
| throw new RuntimeException(pht( | throw new RuntimeException( | ||||
| pht( | |||||
| 'Unrecognized lint message code "%s".', | 'Unrecognized lint message code "%s".', | ||||
| $code)); | $code)); | ||||
| } | } | ||||
| $code = $this->getLintCodeFromLinterConfigurationKey($matches['name']); | $code = $this->getLintCodeFromLinterConfigurationKey($matches['name']); | ||||
| $message = new ArcanistLintMessage(); | $message = new ArcanistLintMessage(); | ||||
| $message->setPath($path); | $message->setPath($path); | ||||
| $message->setLine($matches['line']); | $message->setLine($matches['line']); | ||||
| $message->setChar($matches['column']); | $message->setChar($matches['column']); | ||||
| Show All 17 Lines | |||||