6 ms·
StandardJS just turned 10.0.0
- tzaman 10y agoI've been always meaning to try this out but always just keep reusing the ESLint config, which is probably a bit out of date now. So the question is, could someone explain to me (and everyone who has these same thoughts) why is StandardJS worth a try?
- Lazare 10y agoIf you want a prebuilt eslint config, and you don't like the really popular ones (eg, airbnb[0]) because they default to requiring semicolons, then this is definitely the most popular of the ones that require you to omit semicolons. Beyond that, there are no advantages. It's just a decent eslint config that requires you to omit semicolons wherever possible. If that's important to you, use it. If it's not important, or you'd rather not omit semicolons, or if you do want to omit semicolons but you're happy making a one line change to the airbnb preset, then there's nothing to set this apart from more, if you'll pardon the expression, "standard" options. :) [0]: https://github.com/airbnb/javascript https://github.com/airbnb/javascript
- ikurei 10y agoYou can just disable that rule and use the rest of the airbnb preset, which is what I'd recommend. I hate semicolons, and I do a couple of things that I like but airbnb apparently doesn't, so I override those settings on my .eslintrc and use the rest as a great foundation.
- Lazare 10y agoExactly. I think airbnb is a really good base for a project.
- tzaman 10y agoThanks, I do in fact use AirBnB's config, just wondering whether there's anything I was missing.
- k__ 10y agoHow does it compare to Prettier?
- 0xCMP 10y agoI believe this is just a standard set of rules for ESLint but Prettier is more like gofmt for javascript. Last I used it Prettier it was very opinionated, but I think you can override it with ESLint rules now which you could use StandardJS to do without needing to write your own.
- Lazare 10y agoHonestly, Prettier attempts to solve the same problem and does it better.
- timdorr 10y agoPrettier is a formatter. It doesn't check for errors, it merely parses JS and enforces a style. It actively corrects any style problems that are found. Standard is a linter (ESLint) configuration and frontend. It doesn't correct errors, just checks for them. It goes beyond style to actually check for logical errors (usage of deprecated APIs, invalid regexps, etc). In theory, you can run the two together. Ideally, you'd use plain ESLint with a config geared around catching programming errors, and leave Prettier for just styling concerns.
- partycoder 10y agoStandardJS is like TornadoGuard from xkcd. https://xkcd.com/937/ https://xkcd.com/937/ Very good reviews, but it doesn't achieve the grandiose things it claims to achieve. While consistent indentation is important, a coding standard is much more than that. I consider this to be an actual standard: https://google.github.io/styleguide/jsguide.html https://google.github.io/styleguide/jsguide.html For example Python enforces consistent indentation, but you know that there is still a lot of room to create a mess even with those restrictions. StandardJS was designed to maximize adoption, not to ensure actual quality: - Want a 1,000 characters long line of code? StandardJS badge of approval. - Want a 10,000 lines of code function? StandardJS badge of approval. - Want a function with a cyclomatic complexity of 10,000? StandardJS badge of approval. Those are very basic measures of code quality and StandardJS does not have an actual position about them. Then... StandardJS actually goes against good practices. Omitting semicolons actually has an effect in JavaScript, and there are many examples of that. The Google JavaScript coding standard advises specifically against it for good reasons. Remember that Google created v8, and has a lot more authority in this matter than whoever created StandardJS. ESLint can enforce a cyclomatic complexity limit, number of statements per function, lines per file, etc.
- conradk 10y agoIt may not be perfect for everyone, but in that case, no need to rage. You can just use any of the 38472647893242 different linters out there. What I like about StandardJS is that I don't need yet another config file just for a linter. lintrc, babelrc, webpack.config.js, karma.config.js, etc, etc. Having one less thing for people to need to understand is a nice feature in and of itself IMO. And I actually tended to disagree with some of the StandardJS choices before adopting it. After working with it for a few weeks, I realize it makes absolutely no difference. I just have a linter that works with no config.
- partycoder 10y agoFor me StandardJS is the same as having no linter at all, because it doesn't take action on the problems that can be actually harmful, like the ones I mentioned. An excessively long function, statement or a complex function is a liability because it almost certainly cannot be tested or reasoned about. And all the negative consequences of not being able to test or verify code.
- ronilan 10y agoFeross (of YouTube Instant and Webtorrent fame) did a great branding job on this. However, from my own limited experience, this is an unneeded layer on top of the fantastically good ESLint.
- fiatjaf 10y agoI used Standard for a while, because it matched my personal preferences almost 100%. Some day, however, I decided to do a small modification. Now I'm alone with my own eslintrc and my own dotfiles management.
- timdorr 10y agoYou can just extend the eslint config and disable or tune any rules you don't like: https://github.com/feross/eslint-config-standard https://github.com/feross/eslint-config-standard
- draw_down 10y agoI used to be on a team that wrote JS this way and I really enjoyed it. Now I'm in a Flow/React/semicolons-and-classses-everywhere type place. I find this style so much more pleasant.
- 0xCMP 10y agoIt's almost like it doesn't matter unless it's consistent ;)
- draw_down 10y agoWell, I agree with that and all. But why type (and more importantly, look at) a bunch of semicolons if you don't have to, ya know?
- betenoire 10y agoBecause they signal a complete thought. Like a period.
- mikerybka 10y agoSo kinda like lines.
- betenoire 10y agoKinda. But not. Statements have little to do with lines, and they span lines very often. Variable declarations, especially objects and arrays. Many times for method calls too with many arguments. Kinda.
- iLoch 10y agoBecause it's impossible to complete a thought without a period Seems like a silly conclusion
- betenoire 10y ago
- vram22 10y agoI thought for a moment that this was a joke, like the one about the vanilla JS tool, long ago, here. That was a good one.
- RyanCavanaugh 10y agoSo what's the goal of this project? From the announcement it says there are lots of new rules in 10.0.0 designed to help catch bugs and make programmer intent more explicit. Then in the FAQ it says Can I use a JavaScript language variant, like Flow? Before using a custom JS language variant, consider whether the added complexity (and effort required to get new contributors up-to-speed) is worth it. The goal of variants like Flow is to catch bugs and make intent more explicit! We have to consider if it's worth training up new contributors on this, but we don't have to consider the contributor cost to learn all of feross's personal JS style preferences and API opinions? I get the goal of having a uniform style - that's important and valuable, even though StandardJS's decisions don't match the style predominant in the JS community. But it seems like there's been a lot of scope creep here where now there are specific rules for specific APIs and other stuff that is well outside the domain of "Let's all format our code the same".
- fiatjaf 10y agoFlow doesn't run on my home computer nor in my personal VPS I use for development. It also doesn't run in my Linux girlfriend's computer which I use sometimes, or the computer I sometimes use at work.
- peterjmag 10y agoeven though StandardJS's decisions don't match the style predominant in the JS community I find it particularly ironic that there's a reasonably popular fork called semistandard. [1] In all seriousness though, I'd really love to see the JS community move towards tools like prettier[2] instead of continuously trying to establish "one eslint config to rule them all". I just want each repo I work with to configure my editor for me and reformat stuff automatically (a la gofmt) so I can forget about it. Even if some of the particular style decisions are ones that I personally don't agree with, it doesn't matter — the value of having those decisions abstracted away from me in the first place is significant enough that any minor quibbles fade away pretty quickly. Then I can focus on writing and reading code, not on arguing about whether we should enforce or disallow dangling commas in our lint config. [1] https://github.com/Flet/semistandard https://github.com/Flet/semistandard [2] https://github.com/prettier/prettier https://github.com/prettier/prettier
- imcotton 10y agoCall me old faction or what, but semicolons and 4 spaces indentation, I'm off the grid, so long for so called "Standard" JS.
- andrewmcwatters 10y agoI agree. Furthermore, it is really deceitful to use the name "Standard" when it's far from it. For years this was not the standard way of writing JavaScript. I get that standards change. However, this isn't even the way most companies write JavaScript. The way I interpret this: some group of developers thought it would be a good idea to hijack the word "standard," and wedge this particular new style into the concept. It just isn't standard. It's as absurd as having a company called "Blue Shine" and selling only green colored cleaning products. At least be honest about it. Call it something else, like "Colonless," since that's the most obvious thing that sticks out when using this style.
- TAForObvReasons 10y ago> it is really deceitful to use the name "Standard" when it's far from it. reminds me of the debacle around "Standard Markdown", now called "CommonMark"
- Semiapies 10y agoIt's nobody's Standard except its partisans.
- codedokode 10y agoThis is an awful project. Someone took his own preferences for code style and tries to make it look like some "standard". The parts that I don't like the most are 2 spaces for indentation (why so small? who else is using such small indentation?) and "no semicolons" rule. It would be better to adopt some style guide from Java, because JS has similar syntax and because Java has been in use in large projects for a long time.