PHPackages                             hershel-theodore-layton/portable-hack-ast-linters - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hershel-theodore-layton/portable-hack-ast-linters

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hershel-theodore-layton/portable-hack-ast-linters
=================================================

Hack source code linters authored with portable-hack-ast.

v0.3.3(1mo ago)02.4k↓80.6%[1 issues](https://github.com/hershel-theodore-layton/portable-hack-ast-linters/issues)MITHackCI passing

Since Jan 28Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/hershel-theodore-layton/portable-hack-ast-linters)[ Packagist](https://packagist.org/packages/hershel-theodore-layton/portable-hack-ast-linters)[ RSS](/packages/hershel-theodore-layton-portable-hack-ast-linters/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (10)Versions (17)Used By (0)

portable-hack-ast-linters
=========================

[](#portable-hack-ast-linters)

*Hack source code linters authored with portable-hack-ast*

How to lint my code
-------------------

[](#how-to-lint-my-code)

If you've used [HHAST](https://github.com/hhvm/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](./tests/lint.hack)and copy it verbatim. This file is explicitly licensed as [MIT-0](https://choosealicense.com/licenses/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?
---------------------------

[](#which-linters-are-included)

For the full list, see [bundled linters](./BUNDLED_LINTERS.md), almost all linters from HHAST are included, and some never before seen linters, only available in portable-hack-ast-linters.

### Missing linters from HHAST

[](#missing-linters-from-hhast)

Some linters from HHAST are not included in this library.

- [HHClientLinter.hack](https://github.com/hhvm/hhast/blob/v4.168.3/src/Linters/HHClientLinter.hack)
    - This linter does not use the HHAST framework. It is a wrapper around the `hh_client --lint` cli. The lints that `hh_client` suggest are very high quality and can/do utilize type information. The HHAST implementation has [serious performance problems](https://github.com/hhvm/hhast/issues/432). A separate tool could be developed, since it doesn't need anything from HHAST (or Pha for that matter).
- [DataProviderTypesLinter.hack](https://github.com/hhvm/hhast/blob/v4.168.3/src/Linters/DataProviderTypesLinter.hack)
    - This linter was a well intentioned attempt at making ``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 the `nothing` type. The "real" solution is to the change the `` mechanism to complement the Hack language.
- [MustUseOverrideAttributeLinter.hack](https://github.com/hhvm/hhast/blob/v4.168.3/src/Linters/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.
- [StrictModeOnlyLinter.hack](https://github.com/hhvm/hhast/blob/v4.168.3/src/Linters/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. `
