Coder Social home page Coder Social logo

flow-phabricator-parser's Introduction

flow-phabricator-parser

A flow output parser to be use with phabricator arc lint

This is a simple wrapper - parser for node that will transform the output from flow to something that phabricator can inspect in the linting stage.

How to use it.

Install the package with

npm install flow-phabricator-parser --save-dev
#or
yarn add flow-phabricator-parser --dev

or copy the source file to your project.

To configure the script with arc lint create a .arclint file and add

{
  "linters": {
    ....
  "flow-regex-based": {
    "type": "script-and-regex",
    "include": "(\\.js?$)",
    "exclude": [ ],
    "script-and-regex.script": "sh -c '(node ./PATH_FROM_REPO_ROOT_TO_PROJECT/node_modules/flow-phabricator-parser/flowparser.js ./PATH_FROM_REPO_ROOT_TO_FLOWCONFIG \"$0\")'",
    "script-and-regex.regex": "/^(?P<file>.*): line (?P<line>[0-9]*), col (?P<char>[0-9]*), (?P<severity>error|warning) - (?P<message>.*) \\((?P<code>[a-z-]+)\\)$/m"
    }
  }
}

Replace PATH_FROM_REPO_ROOT_TO_FLOWCONFIG in the above with the path to directory containing your project's project.json file. If it's at the root, remove /PATH_FROM_REPO_ROOT_TO_FLOWCONFIG from the path above - including the / prefix, so just . is left. An optional parameter check can be pass at the end to the script so the line will look like

"script-and-regex.script": "sh -c '(node ./PATH_FROM_REPO_ROOT_TO_PROJECT/node_modules/flow-phabricator-parser/flowparser.js ./PATH_FROM_REPO_ROOT_TO_FLOWCONFIG \"$0\" check)'",

That will force to run flow in mode "check" (independent process) instead of status (server). Flow #6025 and Flow #1428 are issues that can be work around with this. Flow modes

Next we need to ensure the appropriate version of flow-bin is installed.

  • Open up .flowconfig file at the root of your React Native project, and scroll to the bottom.

You should see a version, e.g.:

[version]
^0.42.0

Install that version of flow-bin with:

npm install [email protected] --save-dev
# or
yarn add [email protected] --dev

Notes

We point to "(\\.js?$)", to get all the js files changed since last version. Also the parser will discard errors that doesn't belong to changed files. If you think some error reported is cryptic you may want to run flow in your project folder.

On

"script-and-regex.script": "sh -c '(node ./ProjectDir/node_modules/flow-phabricator-parser/flowparser.js ./ProjectDir \"$0\")'"

we need to pass ./ProjectDir as the folder where flow will be run (AKA the folder of your .flowconfig file) relative to the root of the git repository.

Current Limitations

  • Flow is invoked for each file and the output processed for each different file.
  • Right now, in very big projects with many dependencies in node_modules; errors in the parsing are not impossible although really unlikely. To solve this we may need to move from execFile to a more robust mechanism.

flow-phabricator-parser's People

Contributors

benvium avatar pablocarrillo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.