Comments (14)
Just published v0.9.0 with the updated docs.
also @mrtnzlml this release includes import.meta
support
from eslint-plugin-ft-flow.
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.
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.
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.
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.
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.
@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...
from eslint-plugin-ft-flow.
@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.
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.
@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.
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.
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
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.
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.
@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)
- `ft-flow/enforce-suppression-code`: TypeError: Cannot read properties of undefined (reading 'startsWith') HOT 4
- Suggested improvements to `no-flow-fix-me-in-strict-files` rule HOT 7
- Improve test runner HOT 1
- Consider renaming `no-flow-fix-me-in-strict-files` to something like `no-flow-suppressions-in-strict-files` HOT 1
- improve readme generator
- Function type parameters spacing issues HOT 2
- Recommended configuration not working with enums HOT 7
- Enums support consistent trailing comma
- Enums support unused value
- Q HOT 1
- Allow mixed type-import-style HOT 1
- Add meta.schema to rules
- Fix mapped types throwing eslint errors
- should depend on hermes-eslint with >=
- `globalScope.__defineGeneric` is not a function HOT 12
- No sourceCode in context HOT 2
- Fix all lint errors and enable as part of build
- flow type the repo
- Fix dodgy old file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eslint-plugin-ft-flow.