exlibris-fed / exlibris

MIT License
4 stars 0 forks source link

linting / style guidelines #35

Closed Sigafoos closed 4 years ago

Sigafoos commented 4 years ago

Currently the vue code is a bit of a mess, style-wise (because this came out of a hackathon: if go weren't an asshole about style that provides its own formatter it would have issues too). We need to:

Sigafoos commented 4 years ago

I started looking into standard, and quite liked this philosophy:

The whole point of standard is to save you time by avoiding bikeshedding about code style. There are lots of debates online about tabs vs. spaces, etc. that will never be resolved. These debates just distract from getting stuff done. At the end of the day you have to 'just pick something', and that's the whole philosophy of standard -- its a bunch of sensible 'just pick something' opinions. Hopefully, users see the value in that over defending their own opinions.

But I can't get it working with vue files, getting errors that I can't find reported in their Github issues: in part,

  /home/dconley/repos/exlibris/src/components/BookGrid.vue:6:9: Parsing error: Unexpected token :
  /home/dconley/repos/exlibris/src/components/BookGridCard.vue:3:26: Parsing error:Unexpected token :
  /home/dconley/repos/exlibris/src/components/Home.vue:4:18: Parsing error: Unexpected character '@'
  /home/dconley/repos/exlibris/src/components/SearchBar.vue:3:12: Parsing error: Unexpected character '@'

(ie <input @input="onInput" placeholder="Search Books..." size="40"/> which is valid vue syntax)

I then tried regular ol' eslint, which caught and automatically fixed plenty of errors, but didn't care about whether you used spaces or tabs as long as you didn't use them on the same line. This means we'd need to decide what standard to use, which is kinda the point of standard.

Running standard as an eslint plugin seems to work, mostly, except that mixing spaces and tabs makes it throw up its hands and give up. Use tabs? It can convert it into spaces. Use spaces and tabs? That's too much, man!

At this point the main hurdles are self-imposed, though, as my editor (vim) is trying to use tabs (because tabs are clearly superio- oh wait the point is I don't actually care). I think standard-in-eslint is the way to go, and I'll change my settings to make it easily fixible (ideally I'll have ale's fix-on-save functionality, but that's being a pill right now)