eHealthAfrica / eHealthAfrica.github.io

The GHI eHealth Africa website
http://eHealthAfrica.github.io
4 stars 3 forks source link

Coding styleguide and linting for HTML/Angular views #22

Open FrancescoK opened 9 years ago

FrancescoK commented 9 years ago

Suggestion:

Syntax

(mostly from mdo’s codeguide.co):

HTML attributes should come in this particular order for easier reading of code.

To discuss:

tthew commented 9 years ago

:+1: no strong feelings about {{ viewModel }} vs {{viewModel}}.

febeling commented 9 years ago

I like the {{ viewModel }} version better.

Anything about html tags with lots of attributes on multiple lines vs. single line? (I like to arrange them vertically.)

We should agree on some transition process. Reordering all attributes e.g. right now wouldn't feel like responsible use of time =).

FrancescoK commented 9 years ago

@febeling We could leave attributes on multiple lines vs. single line to the author’s judgement. It’s more readable if it’s a lot and helps not exceed a certain line-length, but for two or three might be too much?

As for transition process, the “scout rule” seems reasonable: Correct the style when you work in a template/HTML file, but let’s not go back through the entire codebase just to fix style.

febeling commented 9 years ago

@FrancescoK sounds both reasonable

tlvince commented 9 years ago

+1 on {{ viewModel }}. +1 on "scout rule". If we're enforcing attribute order, I'd suggest id first as it has higher CSS specificity. Regarding multi/single line attributes, I prefer the former as it's easier to Git (akin to JS function params).

Enforcing these rules is going to be tricky. Is there a decent HTML linter? tidy is painful to work with.

FrancescoK commented 9 years ago

IDs first makes sense, though I would argue they should only be used as JS hooks, never for styling (following csswizardry’s advice) precisely because of their heavyweight specificity.

FrancescoK commented 9 years ago

To evaluate: https://www.npmjs.com/package/grunt-html-angular-validate

admbtlr commented 9 years ago

+1 on never using id's for styling, and actually not even for JS hooks either: I prefer to just 'js-' prefixed class-names. That way you can easily add the hook to multiple elements at a later date.