Closed Bug 1528751 Opened 5 years ago Closed 5 years ago

Check consistent if bracing with eslint

Categories

(Developer Infrastructure :: Lint and Formatting, enhancement)

enhancement
Not set
normal

Tracking

(firefox67 fixed)

RESOLVED FIXED
mozilla67
Tracking Status
firefox67 --- fixed

People

(Reporter: mak, Assigned: mak)

References

Details

Attachments

(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 https://bugzilla.mozilla.org/show_bug.cgi?id=1229097#c20

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 mak77@bonardo.net:
https://hg.mozilla.org/integration/autoland/rev/74ce5e253d22
Add a custom eslint rule to check "consistent" if bracing. r=Standard8
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla67
Assignee: nobody → mak77
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/d8419a366f68
Port bug 1528751 - fix inconsistent if bracing. r=me DONTBUILD
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: