GithubHelp home page GithubHelp logo

Comments (14)

bradzacher avatar bradzacher commented on July 4, 2024 5

Just published v0.9.0 with the updated docs.
also @mrtnzlml this release includes import.meta support

from eslint-plugin-ft-flow.

bradzacher avatar bradzacher commented on July 4, 2024 4

Also as an aside, @Brianzchen, we could convert this repo to use flow if you wanted.
I've got flow types for ESLint based off of the types included in the hermes-estree package.

Internally at meta we have over 400 rules written with flow types! It's a much nicer experience authoring ESLint rules with types 😄!

from eslint-plugin-ft-flow.

bradzacher avatar bradzacher commented on July 4, 2024 2

Sorry, we probably could spruce up the docs.. Or rather add any docs at all heh. I'll look at doing that next week!

Hermes is Meta's JavaScript VM. It's primarily used to power react native.
As it's a VM, it also has a parser.

This parser is built with first-class support of flow syntax and its designed with performance in mind.

hermes-eslint (like @babel/eslint-parser) is a package designed to be the parser for ESLint. It uses Hermes' parser (compiled to WASM) to parse the code and outputs the AST in the latest ESTree format (I.e. It is fully compatible with ESLint v8+).

Unlike babel, hermes-eslint also includes a fully featured scope analyser which has full support for flow features - including types!!
This means (as I mentioned in the OP) we don't need extra hacky compatibility rules to teach eslint core rules about flow types or JSX!

At Meta we have been using hermes-eslint to power our linting in our largest repo for about a year. For context that is well over 550k files. This week I also migrated another repo to use it, which is another few hundred thousand files. So it's well and truly battle tested and hardened to say the least!

In terms of using it - nothing special is required. Just install the package and set parser: 'hermes-eslint' in the eslint config!

from eslint-plugin-ft-flow.

Brianzchen avatar Brianzchen commented on July 4, 2024 1

Thanks, I've been sick these past few days but I'll look into this next weekend once I'm better

from eslint-plugin-ft-flow.

bradzacher avatar bradzacher commented on July 4, 2024 1

weird - I did cleanup the docs, but for some reason they didn't publish with the release.
I'm working on another release today so i'll make sure the docs update is shipped with it

from eslint-plugin-ft-flow.

pascalduez avatar pascalduez commented on July 4, 2024 1

Hey there,

I trying out a migration from @babel/eslint-parser to hermes-eslint, and eslint-plugin-flowtype to eslint-plugin-ft-flow.

I had to disable the ft-flow/space-after-type-colon rule in addition to those mentioned above. It raises errors in place where it should not.

For instance on line breaks:

foo?:
  | Foo
  | Bar

from eslint-plugin-ft-flow.

Brianzchen avatar Brianzchen commented on July 4, 2024 1

@pascalduez working on the upgrade now. Looks like there are some rules that definitely need fixing and on top of that will need to run assertions tests on both babel and hermes...

https://github.com/flow-typed/eslint-plugin-ft-flow/actions/runs/5697988866/job/15445355957?pr=41#step:10:3761

from eslint-plugin-ft-flow.

mrtnzlml avatar mrtnzlml commented on July 4, 2024

@bradzacher Would you happen to have more information about the hermes-eslint parser? The only thing I could find is https://www.npmjs.com/package/hermes-eslint and it's not very welcoming. It doesn't seem to be open-sourced, and it doesn't explain very much what is it and what is the motivation to use it (over traditional parsers commonly used nowadays). Thanks! :)

Edit: is it related to https://github.com/facebook/hermes? I am lost on the React Native part. 🤔

from eslint-plugin-ft-flow.

mrtnzlml avatar mrtnzlml commented on July 4, 2024

Thanks, @bradzacher! Want to give it a try! 👍 Is facebook/hermes the correct repo for reporting bugs/asking questions? I've tried it in my monorepo, and I encountered some bumps (some parsing errors, unclear how to deal with Flow enums); you can see it here: adeira/universe#4583

from eslint-plugin-ft-flow.

bradzacher avatar bradzacher commented on July 4, 2024

@mrtnzlml
The import.meta support is missing (TBH I didn't know flow supported it!!!)
I'll talk to the hermes team about adding support for it.

For the no-unused-vars error on your enums - that's actually a completely correct error that you'll now get! Because hermes-eslint has a scope analyser that understands flow - it can keep track of things like types and enums as well as where they're used.
So in your file the three enums StatusDefault2, StatusString2 and StatusNumber2 are all not used anywhere - hence they're being flagged by no-unused-vars!

from eslint-plugin-ft-flow.

mrtnzlml avatar mrtnzlml commented on July 4, 2024

For the no-unused-vars error on your enums - that's actually a completely correct error that you'll now get! Because hermes-eslint has a scope analyser that understands flow - it can keep track of things like types and enums as well as where they're used.

Ah, right, I didn't realize this. Very cool! 😊 Thanks for your help!

from eslint-plugin-ft-flow.

Brianzchen avatar Brianzchen commented on July 4, 2024

Hi @bradzacher doing some testing here, works pretty well on my source code but when I parse my dist (which people normally don't) with hermes-eslint it crashes but with @babel/eslint-parser it does not

Screen Shot 2022-06-25 at 11 47 56 am

Also going through the limited docs

your project you must specify "hermes-eslint" as the "parser"

But the code snippet references "parser": "hermes-parser" this is correct? Not quite sure which it's meant to be

from eslint-plugin-ft-flow.

bradzacher avatar bradzacher commented on July 4, 2024

If you can isolate the code that's crashing then I can get this fixed up!

It looks like it was a property.
If you run eslint with --debug I think it'll show more info to help pinpoint?


The docs are wrong sorry. I forgot to go and get them update this week sorry. I'll make a note to do it on Monday.

from eslint-plugin-ft-flow.

Brianzchen avatar Brianzchen commented on July 4, 2024

@bradzacher just fyi I haven't forgotten this change! I'm just waiting for doc updates before I start digging into this further

from eslint-plugin-ft-flow.

Related Issues (20)

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.