itowns icon indicating copy to clipboard operation
itowns copied to clipboard

Coding style: enable all airbnb rules

Open peppsac opened this issue 8 years ago • 10 comments

PR #212 enabled code style checking following airbnb coding style. Some of the existing problems were fixed, but there's some work left.

Let's use this issue to track down the remaining eslint disabled rules.

  • [x] func-names
  • [x] no-trailing-spaces
  • [x] padded-blocks
  • [x] one-var
  • [x] no-use-before-define
  • [ ] no-mixed-operators
  • [ ] no-underscore-dangle
  • [ ] eqeqeq
  • [ ] max-len
  • [ ] no-param-reassign
  • [ ] no-else-return
  • [ ] no-var
  • [ ] vars-on-top
  • [ ] no-shadow
  • [x] no-unneeded-ternary ??? :hot_pepper:
  • [ ] no-restricted-properties
  • [ ] prefer-spread
  • [x] default-case ??? :hot_pepper:
  • [ ] camelcase
  • [x] block-scoped-var ??? :hot_pepper:
  • [ ] no-bitwise
  • [ ] no-restricted-syntax
  • [ ] guard-for-in ??? :hot_pepper:
  • [x] no-tabs
  • [ ] consistent-return
  • [x] brace-style
  • [ ] new-cap
  • [x] no-cond-assign ??? :hot_pepper:
  • [x] no-unused-expressions ??? :hot_pepper:
  • [x] no-unused-vars
  • [ ] no-continue
  • [x] import/no-extraneous-dependencies
  • [x] no-lonely-if ??? :hot_pepper:
  • [x] no-prototype-builtins ??? :hot_pepper:
  • [x] no-throw-literal ??? :hot_pepper:
  • [x] operator-assignment ??? :hot_pepper:
  • [x] no-return-assign ??? :hot_pepper:
  • [x] no-useless-concat ??? :hot_pepper:
  • [x] no-loop-func ??? :hot_pepper:
  • [x] import/no-mutable-exports ??? :hot_pepper:
  • [x] import/prefer-default-export ??? :hot_pepper:
  • [x] import/no-named-as-default-member ??? :hot_pepper:
  • [x] import/no-named-as-default ??? :hot_pepper:
  • [x] import/newline-after-import ??? :hot_pepper:
  • [x] import/no-unresolved ??? :hot_pepper:
  • [x] import/extensions ??? :hot_pepper:

peppsac avatar Nov 22 '16 16:11 peppsac

Also, we need to think about linebreak-style (which is off since https://github.com/iTowns/itowns2/commit/65ccaa7064395bac577414e7eee50976382d5d75). Apparently it causes errors on windows with some settings. Actually, as we use a .gitattribute in the repo maybe we don't need a rule about line ending in the linter if everybody use a git client that honors it (apparently, some of them ignore this file).

@nosy-b could you detail your setup here? (I mean, what editor and git client you use, and the relevant part of your .gitconfig, especially core.autocrlf).

autra avatar Nov 22 '16 19:11 autra

We also have end_of_line = lf in .editorconfig...

peppsac avatar Nov 22 '16 19:11 peppsac

My .gitconfig has core.autoclrf set to true. doc on this (I code on netbeans on both win and mac). I could tune it differently but should all external users on win have to do special things to clone and build the master without errors? I'm not an expert on this, I leave you this job :)

nosy-b avatar Nov 23 '16 10:11 nosy-b

Looks like we could add

*.js eol=lf

to our .gitattributes (in addition to the existing * text=auto) to force the EOL to LF (therefore following our .editorconfig and ESLint configurations) See https://git-scm.com/docs/gitattributes#_end_of_line_conversion

tbroyer avatar Nov 23 '16 10:11 tbroyer

Referencing https://github.com/iTowns/itowns2/pull/220 here. It will correct func-names

autra avatar Dec 12 '16 13:12 autra

Referencing https://github.com/iTowns/itowns2/pull/226

autra avatar Jan 16 '17 17:01 autra

Looks like we could add

*.js eol=lf

to our .gitattributes (in addition to the existing * text=auto) to force the EOL to LF (therefore

Maybe we can force eol to lf everywhere actually. We would also have the benefits of it on glsl, html, css files... Do you think it will work?

autra avatar Jan 16 '17 17:01 autra

Maybe we can force eol to lf everywhere actually.

answering myself, the answer is probably no. Let's have a eol=lf for a selected set of extensions.

autra avatar Jan 16 '17 18:01 autra

https://github.com/iTowns/itowns2/pull/224 corrected one-var

autra avatar Jan 23 '17 12:01 autra

https://github.com/iTowns/itowns2/pull/227 corrected another bunch.

autra avatar Jan 23 '17 12:01 autra

The current coding style seams good enough for now. Don't hesitate to reopen if you have new ideas on the subject.

mgermerie avatar Oct 13 '22 08:10 mgermerie