-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Linting and codeing style #2697
Comments
The reason we did not use linting until now is mainly because it would destroy the "blame" history and some contribution statistics. I personally planned enabling linting and enforcing some code style wit the next real big break. Such a break could be the splitting of the project (#2405). |
Actually, the reason I have decided to send a PR is because there is an eslint file in the repo. But, the dependencies are not installed and so my editor was crying because it could not find eslint to lint the code. But when you have PR it's better to lint because then there will be useless discussions about style in every PR. Who said semi-colon? :P |
I'm totally with you on the benefits of linting, but I'm not sure about the right moment to change a big part of the existing code. |
I often use standardjs in my projects or in our company. |
I personally like airbnb/javascript. It's a pretty unopinionated set of rules for |
I'm for everything that makes the code better, and linting is a great idea. But I am aware that introducing linting in one go is going to generate a lot of errors, and hence a lot of work to correct this. I hereby propose adding linting gradually. I've been reading up on
In this way, linting can be enabled stepwise, until all code is being checked. I like this idea also because it allows contributors to make their changes as good as possible.
I would rather give contributors an option to improve according to the standards that should exist. A message along the line of:
And then a list, like:
|
A lot of rules are auto fixable. I don't think it will be such a hassle to update. You can simply turn on a bunch of rules little by little and auto fix. If a rule will require more work, it can be done later. |
I suppose that is a valid approach. Still, there will be sweeping changes through the 100+ files even if they only are small. I would think a more restrained approach would be advisable. |
Why do you feel uncomfortable with it? In case it breaks some things? |
To give a direct answer: yes. I believe that is part of the job of being a maintainer. Another thought I have is that doing a full adjustment according to linting output may leave the code in an interim state for a while until it has been done. This would result in complications due to parallel submissions, needing extra work to consolidate. Also, see my second point above. I would like a possibility for contributors to adhere to the guidelines that should be there. |
It can't be done without planning, that's for sure. But only maintainers know what's going on. Usually if a change affects the whole code, we tell people that there will be a code freeze. So we merge the PRs etc, freeze, do our maintenance and then resume. |
OK, good to know. The above was the personal thought I wanted to share, if there are other good ways of doing it, that's fine with me. |
I propose the following:
OK? |
OK by me. All sounds sensible. |
Oh, this is nice. It looks like we could do the change without loosing the git history (my main concern at the moment): |
I think the airBnb one looks like a step in the right direction, except for the iterators part. While more readable, there is a severe performance hit. For anything backend I'd still use for (let i...) because of this. The 15.3 also seems odd. I'd prefer explicit checks always, even for booleans. Simple reason is that sometimes those can be undefined due to typos etc. (happened so many times in vis :)) Keep up the great work guys! On a sidenote; |
I started a poll to find a coding style: #2904 |
I'm with |
I'm a fan of Airbnb's config personally. I haven't really encountered much
that I don't agree with.
|
The AirBnB is a "hard-core" ES6 style. I'm not sure if we really want to change all the code to ES6...But is is obviously widely used and very "modern". |
Why not? ES6 should be integrated. It really isn't that different than JS. |
No hard preference, but would prefer not to invite our own (or modify someone elses significantly). Just pick something. |
It's ES6 is JS. It’s the next version of JavaScript, it’s a concrete standard with growing browser support uncompiled. No reason to keep using an older version of the language when we could start to improve code structure and fully take advantage of the power of the language |
Good idea to add a coding standard. Thanks for asking. I don't have a strong opinion on which standard is best, just having a standard is good :) |
I'm not sure If all of you understand what it means to enforce e.g. the airbnb style on the whole project! Feel free to checkout the eslint branch and run Once again: AirBnB is a ES6-only style. We would have to convert the whole code base to ES6. |
When I did the lint PR, I originally checked with Anyway if a project is started without enforcing a style, it's inevitable that the whole codebase will be affected once rules are imposed. I think it should be thought by looking at the expected goal. What's the goal: have a sets of rules that don't belong to anyone so that the code looks like written by a single person. Plus linting does save us from some bugs. The style itself is almost irrelevant except that it should not get in the way of people contributions. Some people will never send a PR to a typescript / coffeescript project for example. If one wants ES6 code, it's not about style, it's about using new features of the language. |
@wimrijnders This is also the preset currently in place: https://github.com/almende/vis/blob/develop/.eslintrc#L11 From there we would only need to remove the special rules one by one.. |
We should discuss about introducing linting and enforcing some coding style.
The text was updated successfully, but these errors were encountered: