Page MenuHomePhabricator

Linter for <?hh code
Open, NormalPublic

Description

I need access to a linter that understands Hack. I'm happy to do all the legwork and store my code locally, but that doesn't seem like the right answer long-term.

Pretty much I just want someone to tell me which options are not available so I can move forward on doing something that won't be a waste of time.

Event Timeline

johnclyde claimed this task.
johnclyde raised the priority of this task from to Needs Triage.
johnclyde updated the task description. (Show Details)
johnclyde added a project: Arcanist.

If there's some binary called, say, hacklint or similar which, when run as hacklint --some-linty-args somefile.hack, emits some approximation of lint messages, and normal humans can reasonably expect to install it on their systems, and the output format isn't going to change radically more than every like 3-6 months, we're happy to put bindings in the upstream.

The actual binary should not go in the upstream, similar to how we don't distribute jshint, csslint, etc., as part of arcanist/. These linters just run some binary on your system, or exit with an error describing how to install the appropriate binary if they can't locate it.

We have no plans at this time to write Phabricator in Hack or accommodate the Hack language extensions in our linters. If you want to run the Phabricator PHP linters on some PHP code and the Hack linters on other code, the easiest approach might be to choose a different file extension for the hack code to make it easier to pass the right code to the different linters (there are also other, more complicated approaches you could pursue). If you want some of the warnings or other messages the Phabricator linters can emit to be emitted for Hack code, you should file those as requests against the hacklint upstream, whatever that is: we can't parse Hack code, and don't plan to be able to any time soon.

So the major thing which is not an option from our point of view is:

  • (NOT AN OPTION) Add the Hack language extensions to PHPAST/XHPAST and make the libphutil/arcanist linters understand Hack.

This would be an enormous amount of work to shoddily duplicate code which probably already exists elsewhere in far better form anyway, so even if it were an option it would be a really bad option, but we wouldn't want that in the upstream.

Presumably, Facebook has such a hacklint binary already (maybe it's hh_server --check), so the way forward is probably something like:

  1. Get someone from Facebook to tell you what binary is supposed to be run.
  2. Get someone from Facebook to tell you how to install it.
  3. Get someone from Facebook to give you their existing lint bindings which wrap the binary.
  4. Modernize those in arcanist/ as ArcanistHackLinter, having them emit the instructions from step (2) in getInstallInstructions().
  5. Write some tests; send me a diff.
  6. Hopefully it doesn't break all that often.
epriestley triaged this task as Normal priority.Mar 31 2014, 2:44 PM
pieter claimed this task.May 29 2014, 5:25 PM

@johnclyde: Going to work on this for a bit, unless you've secretly got diffs out for this already. Please let me know.

@pieter, I was working on hackifying some personal libphutil libraries and got stopped by this. any update / way that I can help?

@marpaia: @johnclyde and I discussed out-of-band and will be doing some work on this later this week.

I'm not sure if that work will help you directly -- if your code is part of a libputil library, then you'll need
arc liberate to work on Hack code, which will not not be part of our initial round of updates.

joshuaspence renamed this task from Lint Engine for <?hh code to Linter for <?hh code.Jul 15 2014, 4:26 AM
joshuaspence updated the task description. (Show Details)
joshuaspence added a subscriber: joshuaspence.
epriestley moved this task from Backlog to Bindings on the Lint board.Dec 22 2015, 12:47 PM