-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add eslint and editorconfig for linting and codestyle #568
Conversation
By analyzing the blame information on this pull request, we identified @drew-gross, @flovilmart and @dvanwinkle to be potential reviewers. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insert_final_newline?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆 How ironic.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
@JeremyPlease awesome work! Can we try to reduce to eslint:recommended with the additional plugins? |
@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 Also can you clarify what you mean by:
|
@JeremyPlease updated the pull request - view changes |
@JeremyPlease that's tedious, but I did it for parse-server, no rush though.
Like in parse-server, we tried to stick with eslint:recommended with very few additional rules to reduce the amount of debate :) |
@flovilmart I can probably do a little marathon of lint error fixing next week. When I go through and fix errors I'll remove |
Makes total sense, It took me a few hours to fix the linting for parse-server, it was less tedious than expected ;) |
I'm sorry that I never came back to this and cleaned up all the linting errors 😞 |
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! |
I attempted to base this configuration on the current code style.
.editorconfig
:lf
as end of lineEslint config:
console.___
and case declaration.Let's discuss! Anyone have any feedback, additions, or recommendations?