Closed Bug 1008799 Opened 11 years ago Closed 7 years ago

Detect suite.only calls in linter and reject them by default

Categories

(Firefox OS Graveyard :: Gaia::Build, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: drs, Unassigned)

References

Details

We sometimes have suite.only calls left in by accident in commits, and this can potentially be very bad, especially if not detected for a long time. We should detect this in the linter and reject them by default.
I got started on this a while ago. jshint doesn't have any way that I can see built in to do anything like this. I forked it and started building a regex parser which allows us to match certain expressions. So we'd give it something like /.*suite.only\(.*/ and reject any matching files. I don't think this is a good way to go anymore as it requires a lot of work and is a very backwards and unreliable way of fixing this. I think we should instead add something that hooks the suite.only() function wherever sinon is initialized and, if an env var is set (sorry, I don't know what tbpl uses that is only set there), we throw an error. I'm open to suggestions, though.
James: Do you have any recommendation on the best way to prevent this?
Flags: needinfo?(jlal)
Short term we could hack something terrible to just read through all our files (we do this multiple times already...) and detect the use of suite.only / test.only though I think what we really want is to switch to something like eslint which is super pluggable (but there is some pain involved switching yet-again). This is enough for another bug but ultimately I think gaia is strange/custom enough that an AST based custom linter rules [eslint] would be awesome (also see things like esformatter for formatting)
Flags: needinfo?(jlal)
Firefox OS is not being worked on
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.