Skip to content

Add eslint and editorconfig for linting and codestyle #568

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

Merged
merged 2 commits into from
May 22, 2017

Conversation

JeremyPlease
Copy link
Contributor

I attempted to base this configuration on the current code style.

.editorconfig:

  • indent with 2 spaces
  • trim trailing whitespace
  • lf as end of line
  • always end file with empty line

Eslint config:

  • node, es6, and browser
  • React eslint plugin
  • properly handles and lints JSX
  • allows console.___ and case declaration.

Let's discuss! Anyone have any feedback, additions, or recommendations?

@facebook-github-bot
Copy link

By analyzing the blame information on this pull request, we identified @drew-gross, @flovilmart and @dvanwinkle to be potential reviewers.

Copy link
Contributor

@flovilmart flovilmart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also in .travis.yml, add the npm run lint as before_script cf: https://github.com/ParsePlatform/parse-server/blob/master/.travis.yml#L18

insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insert_final_newline?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insert_final_newline: set to true to ensure file ends with a newline when saving and false to ensure it doesn't.

(editorconfig.org)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but it's missing a final line :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆 How ironic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that made me particularly laugh :)

"react/jsx-uses-vars": 1,
"react/jsx-uses-react": 1,
"react/react-in-jsx-scope": 1,
"no-console": 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need that?

Copy link
Contributor Author

@JeremyPlease JeremyPlease Nov 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 3 rules fix some linting issues with react/jsx:

And no-console allows console.____ to be used without linting errors.

"react/jsx-uses-react": 1,
"react/react-in-jsx-scope": 1,
"no-console": 0,
"no-case-declarations": 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that can be fixed by wrapping declarations inside cases within blocks (did it for parse-server)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't actually fix any linting errors. I noticed the no-case-declarations errors a lot so I disabled that rule.

@flovilmart
Copy link
Contributor

@JeremyPlease awesome work! Can we try to reduce to eslint:recommended with the additional plugins?

@JeremyPlease
Copy link
Contributor Author

@flovilmart With the current configuration there are 243 linting errors. Should I fix all linting errors in order for us to get the code into good shape and then add to travis before_script?

Also can you clarify what you mean by:

Can we try to reduce to eslint:recommended with the additional plugins?

@facebook-github-bot
Copy link

@JeremyPlease updated the pull request - view changes

@flovilmart
Copy link
Contributor

@JeremyPlease that's tedious, but I did it for parse-server, no rush though.

Also can you clarify what you mean by:
Can we try to reduce to eslint:recommended with the additional plugins?

Like in parse-server, we tried to stick with eslint:recommended

with very few additional rules to reduce the amount of debate :)

@JeremyPlease
Copy link
Contributor Author

@flovilmart I can probably do a little marathon of lint error fixing next week.

When I go through and fix errors I'll remove no-console and no-case-declarations. But, we should keep the eslint-plugin-react and 3 current react related rules. Linting react with jsx is sad an inaccurate without these.

@flovilmart
Copy link
Contributor

Linting react with jsx is sad an inaccurate without these.

Makes total sense, It took me a few hours to fix the linting for parse-server, it was less tedious than expected ;)

@flovilmart flovilmart merged commit f8bbf56 into parse-community:master May 22, 2017
@JeremyPlease
Copy link
Contributor Author

I'm sorry that I never came back to this and cleaned up all the linting errors 😞

@flovilmart
Copy link
Contributor

Ah that's fine! Let's move ahead with that, lint is not running on the CI, that gives you a chance to fix them till then!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants