Closed Bug 1528751 Opened 9 months ago Closed 9 months ago

Check consistent if bracing with eslint


(Firefox Build System :: Lint and Formatting, enhancement)

Not set


(firefox67 fixed)

Tracking Status
firefox67 --- fixed


(Reporter: mak, Assigned: mak)




(1 file)

We use to enforce (in reviews) a rule where if a side of an if/elseif/else is braced, all the sides should be braced.
In general I think it makes sense from a readability point of view, and can prevent cases where the else body may be wrongly interpreted; for example bug 1528486.

It would also not prevent people from using non braced constructs, provided all the sides are non braced.

This requires us to also enable "multi-line", that is currently commented out.
There was some discussion here

Looks like this is tricky, none of the ruleset works for us, the closer to our needs would be allowing to just use "consistent", without any other rule :(

We've been having some initial discussions about a JS formatter for the tree (similar to clang-format). As there's not a clear rule we could use, it might be better to put this off until we have some idea of the direction we're going to go with there.

Or we could have discussions about changing the style completely, but I'm inclined to wait a bit.

Could we write a mozilla-only rule checking consistent? It should be possible right?

Summary: Add "consistent" to the eslint curly ruleset → Check consistent if bracing with eslint
Pushed by
Add a custom eslint rule to check "consistent" if bracing. r=Standard8
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla67
Pushed by
Port bug 1528751 - fix inconsistent if bracing. r=me DONTBUILD
You need to log in before you can comment on or make changes to this bug.