IITC-CE / ingress-intel-total-conversion

intel.ingress.com total conversion user script with some new features. Should allow easier extension of the intel map.
https://iitc.app
ISC License
284 stars 110 forks source link

Uniform code style #39

Open johnd0e opened 5 years ago

johnd0e commented 5 years ago

In current code base we can see now a variety of different styles. It would be great to bring everything to some common code style.

So let's discuss here:

  1. Elements of iitc-code uniform style

  2. Tools to implement style checking, and ways to include them in our CI-chain.

johnd0e commented 5 years ago

So if we prefer to keep existing style's elements then we should use eslint. Otherwise, we could use some 'opinionated' formatter, like prettier or StandardJS.

modos189 commented 5 years ago

Project code style is specified in https://github.com/IITC-CE/ingress-intel-total-conversion/blob/master/HACKING.md#code-style

But eslint only reports discrepancy to code style? I think utility itself should format code to our style

johnd0e commented 5 years ago

Project code style is specified in https://github.com/IITC-CE/ingress-intel-total-conversion/blob/master/HACKING.md#code-style

Great. I will make .eslintrc with that rules.

But eslint only reports discrepancy to code style?

There is --fix option. But not all issues could be resolves automatically.

I think utility itself should format code to our style

prettier is even more automatic, but it's rules are predefined, so we can use it only if we agree with the whole style.

P.S. Anyway, we need to merge all old PR's before any global changes.

johnd0e commented 5 years ago

BTW, found inconsistency in the document. Here is a rule:

  • there should be a space after if, for, etc. E.g. if (true) { doStuff(); } else { dontDoStuff(); }

But see at example two lines upper:

  • opening brace on the same line: if(blub) {
johnd0e commented 5 years ago

And perhaps we need to add some other rules to the list. E.g. https://eslint.org/docs/rules/semi

johnd0e commented 5 years ago

Here is the same specification with eslint rules' references added (.eslintrc will follow). Perhaps we should add some more rules, so consider it's still a draft.

Code Style

Please follow the these guidelines. Some are just preference, others are good practice.