Do you usually use semicolon when you program? And why?
In my case, I don't use semicolon. I know how ASI(Auto Semicolon Insertion) works and it's...
For further actions, you may consider blocking this person and/or reporting abuse
When I join a codebase I use whatever the codebase defines, to keep it consistent within.
As for my own projects, yes, I always use semicolons and have setup my linting config in a way to respect that. I just like my semis! ๐
This. Evidently, adapt to the prevalent style in the codebase, and be consistent with it. But I also prefer using them and enforcing them through linting rules. In fact, I'm currently in the process of adding linter rules to the codebase I was just put in charge of, and semicolons are on the list of rules to enable as soon as I have time to resolve the existing inconsistencies.
It's true linter makes us not fall into conflict๐ And as one of the people who uses semicolons, may I ask why you prefer to use semicolons?
For a start, semicolons are more readable - they terminate a statement, regardless of indentation confusing things. But also because, for me at least, omitting them takes more thought than just adding them, so it's a timesink, too.
Frankly, it's not a big deal to follow the rules they already use. Thank you ๐
Semicolons are part of the standard; use them if you want or don't, but please keep it consistent.
thank you for sharing your opinion :)
I personally don't use semicolons and also enforce them to be absent, using standard as my linter (precisely standardx to allow a few customized settings).
I already got so used to it that writing with semicolons feels annoying to me.
100% agree. And it's a good news that I'm not the only one who feels awkward when using semis๐
No-semicolon seems a must when writing variable declaration in Elm/Haskell style.
Changing the order require to remove and add semi-colon if semi-colon is enforced by the linter or formatter.
I use semicolons. I guess I'm just used to it. It feels weird to me to not use semicolons. For a beginner, or someone who is not already pretty good at JS, I recommend always using semicolons. Otherwise it's only a matter of time until you run into a really confusing error caused by "incorrect" AIS and have to beg for help. No-semicolons is cool and all (I guess?) but learn the language very well first, or you are asking for trouble.
It can be really confusing for beginners. I think, however, it will be an option to use it after understanding the principles of ASI. ๐ค
I used to care a lot about this, until I started working on a mix of projects w/ and without them, and just leave it up to the linter to fix the changes on save.
With that in mind, I tend to not use them when I know the linter will just do its thing, but if there happens to not be a linter involved I will usually insert them because it feels purer to me.
I've always used semicolons. The first time I heard about this new trend of not writing them, to be honest I found it quite dumb, like it made no sense. When I asked for the reasoning behind it on Twitter the only two kind of answers I got were "because they're not necessary" and "it saves you time". I wondered, how many seconds can you save in a day by not writing semicolons?
Then I landed on a project which codebase did not use semicolons. I did not bat an eye to it and just went along with being in a "modern" and "cool" project.
That is, until we got around to define our linting and auto-fix rules, when everyone agreed semicolons should be added on file formatting. What was the point then?
I guess it all comes down to personal preference, but as others have said, consistency is the most important thing.
I use them, mostly auto inserted by Prettier (format on save).
I feel it more readable for humans as you can find easier where the statements end without extra effort.
Nope, vs code does it for me ๐
I like to use standard js eslint rules in my personal projects. Will use whatever rules that have already been established for a project though.
standardjs.com/
Let's imagine someone wrote the first snippet. It will take him forever to debug the problem.
I use them when I feel like it makes the line neater
I saw a similar title of a post somewhere.
"Do you use semicolons in JS or you are a Demon ?" :D
Yes, totally, this is one of old discussions. I should go checkout that post rn๐
Use no semicolons in personal projects, because it makes code looks cleaner to me and use whatever is defined in corporate ones.
I do use them actually. not always but when I feel like this line needs a semicolon then I use it
Not really; either way, everyone's code will compile with semicolons because of ASI(automatic semicolon insertion)
Definitely yes! I don't know why but a coding line doesn't look "finished" without a semicolon to my eyes
Personally I like semicolons for the code readability especially when it's an unfamiliar codebase but for my code I don't type them directly I have the formatter or the lint add them for me
That's a kind of good way. Thanks for letting me know๐
No.
Outside of the fact that I don't have to, it's a waste of time and is unnecessary.