Download the PHP package hershel-theodore-layton/portable-hack-ast-linters without Composer
On this page you can find all versions of the php package hershel-theodore-layton/portable-hack-ast-linters. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hershel-theodore-layton/portable-hack-ast-linters
More information about hershel-theodore-layton/portable-hack-ast-linters
Files in hershel-theodore-layton/portable-hack-ast-linters
Package portable-hack-ast-linters
Short Description Hack source code linters authored with portable-hack-ast.
License MIT
Informations about the package portable-hack-ast-linters
portable-hack-ast-linters
Hack source code linters authored with portable-hack-ast
How to lint my code
If you've used HHAST before, you might expect
that you'd be able to add a hhast-lint.json
or alike to your repository to
start linting right away. PhaLinters does not work this way. You must add a
Hack source code file which does the linting and call the linters directly.
The linters are in the HTL\PhaLinters
namespace, so autocomplete away.
This library lints itself. You can check lint.hack and copy it verbatim. This file is explicitly licensed as MIT-0, not MIT like the rest of this library. This means you can do all the things permitted by the MIT license, without having to keep the license comment in the file intact. This choice of license does not change the license for the rest of this project.
Which linters are included?
For the full list, see bundled linters, almost all linters from HHAST are included, and some never before seen linters, only available in portable-hack-ast-linters.
Missing linters from HHAST
Some linters from HHAST are not included in this library.
- HHClientLinter.hack
- This linter does not use the HHAST framework. It is a wrapper around the
hh_client --lint
cli. The lints thathh_client
suggest are very high quality and can/do utilize type information. The HHAST implementation has serious performance problems. A separate tool could be developed, since it doesn't need anything from HHAST (or Pha for that matter).
- This linter does not use the HHAST framework. It is a wrapper around the
- DataProviderTypesLinter.hack
- This linter was a well intentioned attempt at making
<<DataProvider(...)>>
annotations typesafe. By its nature, it is a crude heuristic based approximation of a typechecker. It suggests you do things that are actively harmful like abusing thenothing
type. The "real" solution is to the change the<<DataProvider>>
mechanism to complement the Hack language.
- This linter was a well intentioned attempt at making
- MustUseOverrideAttributeLinter.hack
- The output of this linter depends not just on the arguments, but on global information.
A change in a parent class will require a file to be linted again.
Caching lint results in a cross request manner would require extensive dependency tracking.
hh_client --lint
does the job of this linter better and doesn't depend on the\ReflectionClass
api.
- The output of this linter depends not just on the arguments, but on global information.
A change in a parent class will require a file to be linted again.
Caching lint results in a cross request manner would require extensive dependency tracking.
- StrictModeOnlyLinter.hack
- This linter was needed in the early days of Hack.
Files used to have the
.php
or.hh
extension and the mode was determined by a comment.<?hh
would "kick your.php
file into Hack partial mode". You'd explicitly enable "strict mode" by using<?hh // strict
. Since the release of hhvm version 4.0 you can use.hack
files.
- This linter was needed in the early days of Hack.
Files used to have the
Fixme directives
Lint errors can't (and shouldn't) always be fixed. Sometimes an await-in-a-loop isn't a sign of a false dependency for example in sgml-stream's ConcurrentReusableRenderer:
The $snippet->feedBytesToConsumerAsync(...)
method awaits an Awaitable that
was already started in ->primeAsync(...)
. Internally, it also awaits on
$consumer->consumeAsync(...)
which must be called sequentially.
This await-in-a-loop is required for the code to work correctly.
To inform hhast, a HHAST_IGNORE_ERROR[DontAwaitInALoop]
comment was added.
This comment-to-suppress-a-lint-error mechanism has always bothered me a little. I subscribe wholehartedly to the following quote from the CppCoreGuidelines:
As a replacement for fixme comments, PhaLinters uses the pragma(...)
directive
and the <<Pragmas(...)>>
annotation. The following pieces of code express the
same intent.
All versions of portable-hack-ast-linters with dependencies
hershel-theodore-layton/portable-hack-ast Version dev-master || <1
hershel-theodore-layton/portable-hack-ast-extras Version dev-master || <1
hershel-theodore-layton/pragma Version <1