This repository has been archived by the owner on Dec 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate the roles of SingleRuleLinter into Linter and LintRule
- Loading branch information
Showing
5 changed files
with
121 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2017-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
|
||
namespace Facebook\HHAST; | ||
|
||
/** | ||
* A problem detected by a lint rule | ||
* | ||
* LintError is more generic than SingleRuleLintError because LintError is | ||
* associated with any LintRule, not necessarily a SingleRuleLinter. | ||
*/ | ||
<<__Sealed( | ||
SingleRuleLintError::class, | ||
// HHClientProblem::class | ||
)>> | ||
interface LintError { | ||
public function getFile(): File; | ||
|
||
public function getPosition(): ?(int, int); | ||
|
||
public function getRange(): ?((int, int), ?(int, int)); | ||
|
||
public function getDescription(): string; | ||
|
||
public function getBlameCode(): ?string; | ||
|
||
public function getPrettyBlame(): ?string; | ||
|
||
public function getLintRule(): LintRule; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2017-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
|
||
namespace Facebook\HHAST; | ||
|
||
/** | ||
* An abstract lint rule that provides a single error reason, which could be | ||
* either a HHAST linter or a lint rule written in OCaml. | ||
*/ | ||
<<__Sealed( | ||
SingleRuleLinter::class, | ||
// HHClientLintRule::class, | ||
)>> | ||
interface LintRule { | ||
/** | ||
* The name of the lint rule, which can be used to determine markers to | ||
* suppress lint errors. | ||
*/ | ||
public function getName(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2017-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
|
||
namespace Facebook\HHAST; | ||
|
||
/** | ||
* The process to find problems against a single source file. | ||
* | ||
* Problems found by a Linter could associated with different LintRules, | ||
* especially when the Linter is a proxy calling other linting tools. | ||
*/ | ||
<< | ||
__Sealed( | ||
SingleRuleLinter::class, | ||
// HHClientLinter::class | ||
) | ||
>> | ||
interface Linter { | ||
abstract const type TConfig; | ||
|
||
public function getLintErrorsAsync(): Awaitable<vec<LintError>>; | ||
|
||
public static function shouldLintFile(File $_): bool; | ||
|
||
public static function newInstance(File $file, ?this::TConfig $config): this; | ||
|
||
public function isLinterSuppressedForFile(): bool; | ||
|
||
public function getFile(): File; | ||
|
||
public static function typeAssertConfig(mixed $config): this::TConfig; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters