Closed Bug 981610 Opened 11 years ago Closed 10 years ago

Activate the CSS Linter as a pre-commit hook

Categories

(Firefox OS Graveyard :: Gaia, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: vingtetun, Assigned: vingtetun)

References

Details

Attachments

(21 files, 3 obsolete files)

1.82 KB, patch
iliu
: review+
Details | Diff | Splinter Review
849 bytes, patch
benfrancis
: review+
Details | Diff | Splinter Review
3.37 KB, patch
kgrandon
: review+
Details | Diff | Splinter Review
2.56 KB, patch
wilsonpage
: review+
Details | Diff | Splinter Review
1.31 KB, patch
mcav
: review+
Details | Diff | Splinter Review
3.08 KB, patch
salva
: review-
Details | Diff | Splinter Review
1.92 KB, patch
jrburke
: review+
Details | Diff | Splinter Review
344 bytes, patch
djf
: review+
Details | Diff | Splinter Review
3.44 KB, patch
djf
: review+
Details | Diff | Splinter Review
952 bytes, patch
bdahl
: review+
Details | Diff | Splinter Review
4.58 KB, patch
jj.evelyn
: review+
Details | Diff | Splinter Review
1.27 KB, patch
steveck
: review+
Details | Diff | Splinter Review
3.86 KB, patch
alive
: review+
Details | Diff | Splinter Review
4.15 KB, text/css
djf
: review+
Details
1.83 KB, patch
jmcf
: review+
Details | Diff | Splinter Review
2.03 KB, patch
etienne
: review+
Details | Diff | Splinter Review
1.93 KB, patch
arcturus
: review+
Details | Diff | Splinter Review
2.43 KB, patch
ranbena
: review+
Details | Diff | Splinter Review
1.66 KB, patch
janjongboom
: review+
Details | Diff | Splinter Review
11.90 KB, patch
ochameau
: review+
Details | Diff | Splinter Review
3.14 KB, patch
arnau
: review+
Details | Diff | Splinter Review
Would be nice to have it as a pre-commit hook. A system like the one which is used for jshint files that are failing would be nice too to turn it on. It would be better if this system can also have the number of errors/warnings in the file, and so people won't be able to add new one, but only to remove some.
At some points the linter should be activated as a pre-commit hook. In order to do so we will likely have to have a file to exclude some css files, but I hope we can reduce the list to a minimum. So let's starts to land some css clean up into some bugs before finishing the pre-commit hook patch...
Those patches are just some small and safe (in theory) removals of some css warnings/errors. There is still errors and warnings with those fixes, but a bit less. Asking reviews to you on some of those patches sounds also a simple and friendly way to make you know about the css linter :) The idea is to be able to turn on the linter with as few ignored files as possible. The rules for the linter can be discussed as much as you want (for the moment i enabled only things that seems to make sense to me, but i have no strong opinions), but those fixes should be pretty straightforward imho. If you want to run the linter yourself on the app, just do |APP=... make csslint| until the pre-commit hook lands.
Comment on attachment 8390498 [details] [diff] [review] homescreen.warnings.patch Sorry Vivien, attach the patch, I think that it is just a log :)
Attachment #8390498 - Flags: review?(crdlc) → review-
Attachment #8390492 - Flags: review?(wilsonpage) → review+
Attachment #8390490 - Flags: review?(kgrandon) → review+
(In reply to Cristian Rodriguez (:crdlc) from comment #19) > Comment on attachment 8390498 [details] [diff] [review] > homescreen.warnings.patch > > Sorry Vivien, attach the patch, I think that it is just a log :) oups :) I will attached the real patch!
Attachment #8390502 - Flags: review?(schung) → review+
Comment on attachment 8390566 [details] [diff] [review] homescreen.warnings.patch All changes are done in the ev.me code so I prefer that Ran will take a look to this better than me. Thx!
Attachment #8390566 - Flags: review?(crdlc) → review?(ran)
Attachment #8390493 - Flags: review?(m) → review+
Comment on attachment 8390562 [details] [diff] [review] contacts.warnings.patch Review of attachment 8390562 [details] [diff] [review]: ----------------------------------------------------------------- thanks
Attachment #8390562 - Flags: review?(jmcf) → review+
Attachment #8390487 - Flags: review?(bfrancis) → review+
Attachment #8390495 - Flags: review?(jrburke) → review+
Attached patch precommit.css.patch (obsolete) — Splinter Review
Here is the pre-commit hook. For the moment the list of exclusion is contains in build/csslint/xfail.list. The file is still empty as I intend to populate it before landing as it does not really makes sense to do it right now. I also relaxed a bit the warnings part since have having played with the linter a bit I have some doubts that some of the rules are going to be fixed one day.
Attachment #8390503 - Flags: review?(alive) → review+
Attachment #8390486 - Flags: review?(iliu) → review+
Comment on attachment 8390563 [details] [diff] [review] dialer.warnings.patch Review of attachment 8390563 [details] [diff] [review]: ----------------------------------------------------------------- impressive bug :)
Attachment #8390563 - Flags: review?(etienne) → review+
Comment on attachment 8390564 [details] [diff] [review] ftu.warnings.patch Thanks Vivien!
Attachment #8390564 - Flags: review?(francisco.jordano) → review+
Comment on attachment 8390496 [details] [diff] [review] fl.warnings.patch Review of attachment 8390496 [details] [diff] [review]: ----------------------------------------------------------------- just removes an unused class. trivially correct.
Attachment #8390496 - Flags: review?(dflanagan) → review+
Comment on attachment 8390497 [details] [diff] [review] gallery.warnings.patch trivially correct patch that just removes unneeded units from 0 values.
Attachment #8390497 - Flags: review?(dflanagan) → review+
Comment on attachment 8390505 [details] video.warnings.css trivially correct patch that just removes units from zero values.
Attachment #8390505 - Flags: review?(dflanagan) → review+
Comment on attachment 8390500 [details] [diff] [review] pdfjs.warnings.patch Review of attachment 8390500 [details] [diff] [review]: ----------------------------------------------------------------- Upstreamed https://github.com/mozilla/pdf.js/pull/4454
Attachment #8390500 - Flags: review?(bdahl) → review+
Comment on attachment 8390501 [details] [diff] [review] settings.warnings.patch thanks!
Attachment #8390501 - Flags: review?(ehung) → review+
Comment on attachment 8390566 [details] [diff] [review] homescreen.warnings.patch Review of attachment 8390566 [details] [diff] [review]: ----------------------------------------------------------------- Good catches! :)
Attachment #8390566 - Flags: review?(ran) → review+
Assignee: nobody → 21
Whiteboard: [leave-open]
Comment on attachment 8390499 [details] [diff] [review] keyboard.warnings.patch + margin: -0.6rem 0 0rem 0; /* I don't know why we need the top margin */ 0rem -> should be 0
Attachment #8390499 - Flags: review?(janjongboom) → review-
(In reply to Jan Jongboom [:janjongboom] from comment #37) > Comment on attachment 8390499 [details] [diff] [review] > keyboard.warnings.patch > > + margin: -0.6rem 0 0rem 0; /* I don't know why we need the top margin */ > > 0rem -> should be 0 Good catch thanks.
Comment on attachment 8390954 [details] [diff] [review] precommit.css.patch Review of attachment 8390954 [details] [diff] [review]: ----------------------------------------------------------------- Doesn't apply/work. Isn't there a missing patch? ::: tools/pre-commit @@ +94,5 @@ > + > +$XULRUNNER_SDK $XPCSHELL_SDK \ > + -e "const GAIA_BUILD_DIR='file://$(pwd)/build/'" \ > + -f build/xpcshell-commonjs.js \ > + -e "quit(require('csslint').lint('$(pwd)', '$changed_files'));" What about calling a Makefile's target instead (like what we are doing with gjslint)? It looks weird to pull Makefile variables with such special echo rule. @@ +108,1 @@ > for file in $(git diff --staged --name-only); do pre-commit doesn't apply, nor works as $changed_files only track .js files... Also, even if I fixed that, I get some stange behavior: $ git diff diff --git a/apps/browser/style/settings.css b/apps/browser/style/settings.css index 186fba6..db2d535 100644 --- a/apps/browser/style/settings.css +++ b/apps/browser/style/settings.css @@ -1,3 +1,4 @@ + #settings ul { margin: 0; padding: 0; alex@ubuntu:~/gaia$ git commit apps/browser/style/settings.css apps/browser/style/settings.css There were errors while linting the files, please see above. We don't see any meaningfull error message.
Attachment #8390954 - Flags: review?(poirot.alex) → review-
Not sure why you didn't see anything in the console. I forgot to fix the changed_files stuff since I initially develop the pre-commit hook into a shell script. I killed the build/xulrunner_config file but keep the command to call the linter in the pre-commit file as it seems that the Makefile is already huge and I prefer to keep the logic where it belongs. I will walk and seat next to you to see if there is anything wrong and why nothing is showned on your console (if it still happens).
Attachment #8390954 - Attachment is obsolete: true
Attachment #8392880 - Flags: review?(poirot.alex)
Comment on attachment 8392880 [details] [diff] [review] bug981610.precommit Review of attachment 8392880 [details] [diff] [review]: ----------------------------------------------------------------- Works great now! That would be really great if you can move the xpcshell call in the Makefile so that we get a common place where we call it.
Attachment #8392880 - Flags: review?(poirot.alex) → review+
Just merged the linter: https://github.com/mozilla-b2g/gaia/commit/c250da9f8fdc511ad718ba594a0aa60a5959e74b It makes me a bit stressed since if it's buggy it may be painful for people. If there is any issue, please don't hesitate to backout the changeset c250da9f8fdc511ad718ba594a0aa60a5959e74b and I will fix the issue before relanding.
Comment on attachment 8393008 [details] [diff] [review] bug981610.shared.patch Thanks Vivien, that will help us catching some errors!
Attachment #8393008 - Flags: review?(arnau) → review+
Attachment #8392218 - Flags: review?(janjongboom) → review+
shared patch: https://github.com/mozilla-b2g/gaia/commit/71df836011d1d116c94551c23ffce522ded958ae I also realized that there was an issue with the shared/ folder beeing not taken correctly by the pre-commit hook, so I fixed that and land it as well.
Comment on attachment 8390494 [details] [diff] [review] costcontrol.warnings.patch Review of attachment 8390494 [details] [diff] [review]: ----------------------------------------------------------------- The patch does not apply on master. Maybe something changed. Here in: --- a/apps/costcontrol/style/views/firsttime.css +++ a/apps/costcontrol/style/views/firsttime.css @@ -1,1 +1,0 @@ - color: #fff; color: #fff does not exist. But I found a dupllicated entry with color: #000 instead.
Attachment #8390494 - Flags: review?(salva) → review-
This is done, let's close.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Whiteboard: [leave-open]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: