Facebook-chat-api: use coding style?

Created on 3 Mar 2018  路  11Comments  路  Source: Schmavery/facebook-chat-api

Do we use any coding style? If we use some style like standard or airbnb, the code will look more comfortable. I suggest use standard on this project. And add a .eslintrc file to help developer to lint code.

Most helpful comment

馃槀Don't worry. It's just show how annoying as airbnb style. I never want to PR this commit.

All 11 comments

Is there some pattern that you think is making it hard to contribute?

  • Adding .eslintrc is useful for auto-lint code. Developer do not need to create eslint configuration file themeselves.
  • It makes it easy to unify code style and make it beautiful.
  • Some contributers dosen't follow exactly camel case. Let some variables or object key like "foo_bar", some like "fooBar". This will confuse the user.
  • Most large projects also use eslintrc to unify code style.
  • avoid weird indentation
  • use single quote or double quote?

I think many developer like more beautiful code right?馃檪
btw. I suggest use standard code style. Although it's very different from current style.

I'm not entirely against the idea of aiming for some sort of unified style, though I'm not that into no semicolons (as standard appears to be).
Maybe something like prettier? Downside of having to touch every file and adding another step to development (would also be required of linting), upside of no manual (and error-prone) work to change and maintain style. I guess you would maybe still want a linter to enforce camelCase for instance. Would be nice to have an automated check for that.
@bsansouci thoughts?

We can just create a lint configure file (.eslintrc). And let developers include that into editor by themselves.
Or you can also use "husky"+"lint-stage", to force developer auto lint codes before commit.

Few days later, if i have space times I can make a PR to view the lint result.

ref

Thanks for the link @ALiangLiang, looks like my preference for with-semicolon style is justified by science 馃槣

Looks like @ravkr created https://github.com/Schmavery/facebook-chat-api/pull/611 to try out some changes. How do people feel about the airbnb style guide? From looking at it briefly it seems to match most closely what we're doing here already (in terms of semicolons, indentation and use of single-quotes for strings).
@bsansouci

I agree. airbnb is more like current coding style. But... Airbnb style is very strict and annoying. QQ
You can try below commit and run npm run lint. Or use linter plugin of your editor. You will know how strict of it
https://github.com/ALiangLiang/facebook-chat-api/commit/8ad192e1fd2d970bfd103938a22bc5abbd4429a1

btw. I found a funny service called "stickler-ci". It can help you to check lint before merge every PR.
Below is my test result:
https://github.com/ALiangLiang/pchome-api/pull/3

----- edited

After I change some api code to airbnb..... I think I will die soon.... Toooooooo strict...

let me die... (38 files changed, 834 insertions(+), 917 deletions(-), not completely and not testing yet)
https://github.com/ALiangLiang/facebook-chat-api/commit/4ba63031f17e2e363bbfe35e6a3cc5430e48b36e

Used airbnb style.

Haha oh no, I didn't mean for you to spend a bunch of work manually converting files!
What I'm honestly thinking at this point is that @bsansouci and I will spend time this weekend trying to merge any outstanding PRs (so we don't break them with formatting), and then simply run prettier over the codebase. Let's see how that goes unless anyone has big objections? 馃槃

Motivation: I hate when I or other people have to spend time formatting code instead of writing it. Also don't want to make it harder to contribute by drowning people in linter errors.

馃槀Don't worry. It's just show how annoying as airbnb style. I never want to PR this commit.

Thanks for the feedback, we've formatted the whole codebase with prettier for now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

WaffleCohn picture WaffleCohn  路  6Comments

Dinamots picture Dinamots  路  8Comments

Hraph picture Hraph  路  6Comments

ezaca picture ezaca  路  3Comments

standnguyen197 picture standnguyen197  路  4Comments