Skip to content

Latest commit

 

History

History
68 lines (43 loc) · 2.43 KB

linters-usage.md

File metadata and controls

68 lines (43 loc) · 2.43 KB

HHAST: Linters

Quick Start

hhvm composer require hhvm/hhast
vendor/bin/hhast-lint src/

This will run a default set of linters against your source tree. If you do not have a configuration file, paths must be specified on the command line.

Configuration

An hhast-lint.json in your project root can be used to modify which linters are used, or to otherwise customize the behavior. A minimal configuration would be:

{
  "roots": [ "src/" ]
}

This would configure hhast-lint with no arguments check src/ with otherwise-default settings. For information on additional options, see LinterCLIConfig::TConfigFile.

Options can also be overriden for specific file patterns or subdirectories - for example, HHAST itself disables autofixes for codegen/.

Editor and IDE Support

Editor and IDE integration requires executing vendor/bin/hhast-lint when a .hhconfig and hhast-lint.json is present; if you do not trust the repositories you edit code in, this may be a security risk.

Atom IDE and Nuclide

screenshot of lint errors in Nuclide

The ide-hhast package (atom-ide-hhast) shows lint errors, and provides the option to fix many automatically.

This plugin will prompt before executing vendor/bin/hhast-lint for each project. The atom-ide-ui package is required, unless using Nuclide.

Vim8 and Neovim

screenshot of lint errors in Vim8

Install vim-hack and ALE; vim-hack provides filetype detection and syntax highlighting, and ALE provides support for more advanced features, including HHAST lint error reporting.

To enable HHAST support, add let g:ale_linters = { 'hack': ['hack', 'hhast'] } to your .vimrc. Note that this will execute vendor/bin/hhast-lint in any project, without further prompting.

Visual Studio Code

screenshot of lint errors in VSCode

Install vscode-hack; this provides a rich experience for Hack and HHAST, including lint error reporting and autofixing.

This plugin will prompt before executing vendor/bin/hhast-lint for each project.