Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for flow syntax extensions. #592

Closed
Gozala opened this issue Aug 18, 2016 · 12 comments
Closed

Support for flow syntax extensions. #592

Gozala opened this issue Aug 18, 2016 · 12 comments
Labels

Comments

@Gozala
Copy link

Gozala commented Aug 18, 2016

Is there way to support flow syntax extensions for projects that want to use that ?

@jprichardson
Copy link
Member

jprichardson commented Aug 18, 2016

You can, just use the babel-eslint parser for Standard and add the necessary plugins for Babel. This is what I use: https://github.com/codemix/babel-plugin-typecheck.

@Gozala
Copy link
Author

Gozala commented Aug 18, 2016

So I run into following issue gajus/eslint-plugin-flowtype#72 when using standard with babel-eslint and eslint-plugin-flowtype

@Gozala
Copy link
Author

Gozala commented Aug 18, 2016

Also babel/babel-eslint#293 seems relevant here.

@feross
Copy link
Member

feross commented Aug 18, 2016

@Gozala Are you specifying the flowtype plugin in your package.json config for standard like this?

{
  "standard": {
    "plugins": ["flowtype"]
  }
}

Setting a custom parser and plugins are the only ways you can try to solve this issue with standard. We intentionally don't support enabling/disabling rules.

If you require enabling extra rules from the flowtype plugin and/or disabling rules in standard to get your code to pass, then I would suggest using eslint directly in your project. You can extend from eslint-config-standard and just change the few rules you need to change.

@Gozala
Copy link
Author

Gozala commented Aug 18, 2016

@feross Yeap that is pretty much what I use:

{
  "standard": {
    "parser": "babel-eslint",
    "plugins": [
      "flowtype"
    ]
}

The problem as described in babel/babel-eslint#293 is that babel-eslint does not seem to have a way of informing eslint that type import is different from value import & there for eslint will report duplicate imports.

If you require enabling extra rules from the flowtype plugin and/or disabling rules in standard to get your code to pass, then I would suggest using eslint directly in your project. You can extend from eslint-config-standard and just change the few rules you need to change.

That is what I end up doing for now, but I would much rather not do that. Maybe standard could avoid this issue by using import/no-duplicates instead of stock no-duplicates ?

@feross
Copy link
Member

feross commented Aug 18, 2016

The import plugin actually looks really well done. Adding another eslint plugin is not ideal for running time, but if there are other rules in there that would make standard catch more errors, I'm open to considering it. (As an added bonus, flow type annotations would work again.)

@Gozala
Copy link
Author

Gozala commented Aug 19, 2016

but if there are other rules in there that would make standard catch more errors, I'm open to considering it.

@feross I believe it primary selling point is:

prevent issues with misspelling of file paths and import names

Also should I open new issue regarding duplicate imports issue caused by import type ?

@Gozala
Copy link
Author

Gozala commented Aug 19, 2016

Setting a custom parser and plugins are the only ways you can try to solve this issue with standard. We intentionally don't support enabling/disabling rules.

Would not it be reasonably to allow configuring those plugins ? It would not solve the duplicate imports issue I'm afraid, but I did also notice that I'm unable to configure flowtype plugin which can catches bunch of errors otherwise.

@Gozala
Copy link
Author

Gozala commented Aug 19, 2016

Created a separate issue in regards to no-duplicate-imports casted by import type:
#599

@feross
Copy link
Member

feross commented Aug 19, 2016

Would not it be reasonably to allow configuring those plugins ? It would not solve the duplicate imports issue I'm afraid, but I did also notice that I'm unable to configure flowtype plugin which can catches bunch of errors otherwise.

This is a slippery slope. When you see standard is being used on a repo, we want that to mean something. If you can configure rules, then it means less because contributors will need to see exactly which rules you have added before jumping in. This was discussed extensively in #399 and it was decided not to support this.

If you really want a flow-type variant of standard, I suggest writing a fork like standard-flow. You can see https://github.com/feross/standard-react or https://github.com/Flet/semistandard for an example of how to write a fork of standard that extends the existing rules and modifies a few of them.

This was referenced Aug 19, 2016
@Gozala
Copy link
Author

Gozala commented Aug 29, 2016

If you really want a flow-type variant of standard, I suggest writing a fork like standard-flow. You can see https://github.com/feross/standard-react or https://github.com/Flet/semistandard for an example of how to write a fork of standard that extends the existing rules and modifies a few of them.

Thanks. I have followed this advice and created https://github.com/Gozala/standard-flow and https://github.com/Gozala/eslint-config-standard-flow to add flow support and lint type annotations with the same rules as rest of the code.

@ArmorDarks
Copy link

I think that forcing forks is terrible idea, because they almost always lags behind main library and ends up unmaintained.

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Archived in project
Development

No branches or pull requests

4 participants