Originally added by rP20364 (D213).
Per discussion on rP23172:
This can be useful also in context of ProfileStart/ProfileEnd block to make
it clear what code it is meant to encapsulate. It is effectively similar
to how code can be split into separate functions without there necessarily
being something in the code that makes use of JS features unique to
function scope. It is a way of organising the code.
While it is possible that blocks are sometimes left behind by refactoring,
I suppose we prefer to catch the bad things in code review, instead of
having to tell the linter with inline structions to whitelist the cases
where it is intended.
Background
This follows-up rP23172, which introduced the following ESLint warnings:
binaries/data/mods/public/gui/lobby/LobbyPage/Game.js 153:3 warning Nested block is redundant no-lone-blocks 202:3 warning Nested block is redundant no-lone-blocks binaries/data/mods/public/gui/lobby/LobbyPage/GameList.js 110:3 warning Nested block is redundant no-lone-blocks
Alternatives
If we keep this in our ruleset, there are two other ways to address it:
- Make an inline exemption, e.g. like so:
// eslint-disable-next-line no-lone-bocks { foo.bar(); }
- Or, adapt the code to follow the rule by removing the curly braces.