mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 11:30:55 +01:00
Use the ArcanistConfigurationDrivenLintEngine
as a linting engine.
Summary: Ref T2039. This diff is the equivalent to D9057, but for rP. Depends on D9066. Test Plan: Ran `arc lint` and ensure it doesn't complain about the `.arclint` file. Reviewers: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T2039 Differential Revision: https://secure.phabricator.com/D9064
This commit is contained in:
parent
94772689cd
commit
566f8ab9aa
4 changed files with 65 additions and 67 deletions
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"project.name" : "phabricator",
|
"project.name" : "phabricator",
|
||||||
"phabricator.uri" : "https://secure.phabricator.com/",
|
"phabricator.uri" : "https://secure.phabricator.com/",
|
||||||
"lint.engine" : "PhabricatorLintEngine",
|
|
||||||
"unit.engine" : "PhutilUnitTestEngine",
|
"unit.engine" : "PhutilUnitTestEngine",
|
||||||
"load" : ["src/"],
|
"load" : ["src/"],
|
||||||
"lint.xhpast.naminghook" : "PhabricatorSymbolNameLinter",
|
"lint.xhpast.naminghook" : "PhabricatorSymbolNameLinter",
|
||||||
|
|
61
.arclint
Normal file
61
.arclint
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
{
|
||||||
|
"exclude": [
|
||||||
|
"(^externals/)",
|
||||||
|
"(\\.lint-test$)"
|
||||||
|
],
|
||||||
|
"linters": {
|
||||||
|
"filename": {
|
||||||
|
"type": "filename"
|
||||||
|
},
|
||||||
|
"javelin": {
|
||||||
|
"type": "javelin",
|
||||||
|
"include": "(\\.js$)",
|
||||||
|
"exclude": [
|
||||||
|
"(^externals/JsShrink/)",
|
||||||
|
"(^support/aphlict/)",
|
||||||
|
"(^webroot/rsrc/externals/raphael/)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"jshint": {
|
||||||
|
"type": "jshint",
|
||||||
|
"include": "(\\.js$)",
|
||||||
|
"exclude": [
|
||||||
|
"(^externals/JsShrink/)",
|
||||||
|
"(^webroot/rsrc/externals/raphael/)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"generated": {
|
||||||
|
"type": "generated"
|
||||||
|
},
|
||||||
|
"merge-conflict": {
|
||||||
|
"type": "merge-conflict"
|
||||||
|
},
|
||||||
|
"nolint": {
|
||||||
|
"type": "nolint"
|
||||||
|
},
|
||||||
|
"phutil-xhpast": {
|
||||||
|
"type": "phutil-xhpast",
|
||||||
|
"include": "(\\.php$)",
|
||||||
|
"phutil-xhpast.deprecated.functions": {
|
||||||
|
"phutil_escape_html": "The phutil_escape_html() function is deprecated. Raw strings passed to phutil_tag() or hsprintf() are escaped automatically."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"text": {
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
"spelling": {
|
||||||
|
"type": "spelling"
|
||||||
|
},
|
||||||
|
"xhpast": {
|
||||||
|
"type": "xhpast",
|
||||||
|
"include": "(\\.php$)",
|
||||||
|
"severity": {
|
||||||
|
"16": "advice",
|
||||||
|
"29": "warning",
|
||||||
|
"31": "error",
|
||||||
|
"34": "error",
|
||||||
|
"35": "error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,66 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @concrete-extensible
|
|
||||||
*/
|
|
||||||
class PhabricatorLintEngine extends PhutilLintEngine {
|
|
||||||
|
|
||||||
public function buildLinters() {
|
|
||||||
$linters = parent::buildLinters();
|
|
||||||
|
|
||||||
foreach ($linters as $linter) {
|
|
||||||
if ($linter instanceof ArcanistPhutilXHPASTLinter) {
|
|
||||||
$linter->setDeprecatedFunctions(array(
|
|
||||||
'phutil_escape_html' =>
|
|
||||||
'The phutil_escape_html() function is deprecated. Raw strings '.
|
|
||||||
'passed to phutil_tag() or hsprintf() are escaped automatically.',
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$paths = $this->getPaths();
|
|
||||||
|
|
||||||
foreach ($paths as $key => $path) {
|
|
||||||
if (!$this->pathExists($path)) {
|
|
||||||
unset($paths[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$javelin_linter = new PhabricatorJavelinLinter();
|
|
||||||
$linters[] = $javelin_linter;
|
|
||||||
|
|
||||||
$jshint_linter = new ArcanistJSHintLinter();
|
|
||||||
$linters[] = $jshint_linter;
|
|
||||||
|
|
||||||
foreach ($paths as $path) {
|
|
||||||
if (!preg_match('/\.js$/', $path)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strpos($path, 'externals/JsShrink') !== false) {
|
|
||||||
// Ignore warnings in JsShrink tests.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strpos($path, 'externals/raphael') !== false) {
|
|
||||||
// Ignore Raphael.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$jshint_linter->addPath($path);
|
|
||||||
$jshint_linter->addData($path, $this->loadData($path));
|
|
||||||
|
|
||||||
if (strpos($path, 'support/aphlict/') !== false) {
|
|
||||||
// This stuff is Node.js, not Javelin, so don't apply the Javelin
|
|
||||||
// linter.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$javelin_linter->addPath($path);
|
|
||||||
$javelin_linter->addData($path, $this->loadData($path));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $linters;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -48,6 +48,10 @@ final class PhabricatorJavelinLinter extends ArcanistLinter {
|
||||||
return 'JAVELIN';
|
return 'JAVELIN';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getLinterConfigurationName() {
|
||||||
|
return 'javelin';
|
||||||
|
}
|
||||||
|
|
||||||
public function getLintSeverityMap() {
|
public function getLintSeverityMap() {
|
||||||
return array(
|
return array(
|
||||||
self::LINT_MISSING_BINARY => ArcanistLintSeverity::SEVERITY_WARNING,
|
self::LINT_MISSING_BINARY => ArcanistLintSeverity::SEVERITY_WARNING,
|
||||||
|
|
Loading…
Reference in a new issue