3 ms·
Funny enough, for-of is not allowed in Airbnb eslint config, and you are expected to use forEach instead: https://github.com/airbnb/javascript/issues/1122 http
by g947o 10mo ago
Funny enough, for-of is not allowed in Airbnb eslint config, and you are expected to use forEach instead:
https://github.com/airbnb/javascript/issues/1122 https://github.com/airbnb/javascript/issues/1122
https://github.com/airbnb/javascript/issues/1271 https://github.com/airbnb/javascript/issues/1271
Because the style guide thinks "forEach is cleaner than for-of". (No I did not make that up.)
https://github.com/airbnb/javascript?tab=readme-ov-file#iterators--nope https://github.com/airbnb/javascript?tab=readme-ov-file#iter...
- wiseowise 10mo agoNo way this is not a satire. https://github.com/airbnb/javascript/issues/1122#issuecomment-259876436 https://github.com/airbnb/javascript/issues/1122#issuecommen... https://github.com/airbnb/javascript/issues/1122#issuecomment-259884000 https://github.com/airbnb/javascript/issues/1122#issuecommen...
- g947o 10mo agoI know. Which is why I completely got rid of airbnb rules in my personal projects or projects that I control. I wasted so much time fighting those stupid rules instead of actually writing code.
- vorticalbox 10mo agoi have pretty strict rules for the code bases at work and one is to use for..of
- tentacleuno 10mo agoThey don't seem to like generators either, which is even stranger. Why block the usage of features which might be useful in some cases?
- deleted 10mo ago[deleted]
- mattacular 10mo agoThe AirBNB JS style guide is kind of like a relic in time from the transition to ES6 etc. Leave it in the past. Their only argument for not supporting eg. "for-of" is because of "legacy" browsers not supporting it. Maybe a salient argument at the time of writing (these issue threads are nearly 10 years ago), but certainly not today.
- Hendrikto 10mo agoIt’s mostly the argument of a single guy (ljharb), who has very strong and weird opinions. There were several extremely long and unproductive GitHub discussion with him posted to HN before, where he sent unsolicited and unwanted PRs to lots of projects that tanked performance by orders of magnitude and introduced tens of dependencies (he wrote himself), to ensure that projects would be backwards compatible with completely irrelevant targets they never supported in the first place (like Internet Explorer 1.3 under Windows 95 or something along those lines). When projects did not want to take these contributions, he played his TC39 authority card, and when that did not help became more and more incoherent in his ramblings. My take is that this guy actually wants to and thinks he is doing good, while actually having lost the plot a while ago.
- agumonkey 10mo agovery interesting thread i used to be like ljharb, changing company/stack made me live in python for loops but then i miss composable operators ..
- g947o 10mo ago> Their only argument for not supporting eg. "for-of" is because of "legacy" browsers not supporting it. Not really, their rational is written in the document I linked -- Why? This enforces our immutable rule. Dealing with pure functions that return values is easier to reason about than side effects. // bad let sum = 0; for (let num of numbers) { sum += num; } sum === 15; // good let sum = 0; numbers.forEach((num) => { sum += num; }); sum === 15; Which is... ridiculous. None of this is actually immutable, as "sum" is constantly being modified. A real FP purist would be using "reduce" in the "good" example. Otherwise, forEach is not better than for-of in terms of readability or maintainability in any way. In addition, I think an issue is that for a long time, when you use ESLint CLI to create a new config file, airbnb is the default option, which ends up making it used very widely, even after the config itself is in maintenance mode. They were only removed in 2024: https://github.com/eslint/create-config/pull/108 https://github.com/eslint/create-config/pull/108
- benoau 10mo agoThere's lots of little annoyances like this, but I just gave up and accepted it. I think this kind of highlights what is actually right about it: it lets everyone move past discussing such details in perpetuity.
- g947o 10mo ago> I just gave up and accepted it > lets everyone move past discussing such details in perpetuity That's definitely a reasonable attitude towards coding standards generally. However, in this case, there are "better" eslint rules out there that flags real, serious issues but still allows you to be productive, which is what I end up using.
- esprehn 10mo agoAirbnb doesn't really follow that guide internally anymore. There's a lot of weird in there. I wish they'd publish the actual internal style and lint rules instead.
- nobleach 10mo agoAirBnB doesn't use this config and you probably shouldn't either. Much of this was based on Jordan Harband's opinions in 2016. He's likely changed his mind since then. Perhaps not. But I bet he'd tell you to do your own profiling and consider your own targets before blindly accepting a one-size-fits-all configuration for your linter.
- g947o 10mo ago> do your own profiling and consider your own targets before blindly accepting a one-size-fits-all configuration for your linter Too bad ESLint has been recommending airbnb as the style until 2024. You can't expect everyone to start with nothing and hand pick every rule themselves. Doable for a large organization, not possible for a personal project. https://github.com/eslint/create-config/pull/108 https://github.com/eslint/create-config/pull/108
- tracker1 10mo agoThat's the biggest one that turned me off of their entire rule set... IIRC similar for for-await-of iirc.