0

I'm starting a web project in Aptana and have downloaded bootstrap (v 3.3.7) and jQuery (compressed). When I imported the files into my js folder, all the files came up with a warning sign and the only warnings I can see are that there are missing semicolons everywhere. I think I've read that semicolons aren't necessary in js (although it's best practice to use them), but I've downloaded these files before for class and didn't receive this warning.

Have I done something wrong? Are these files OK to work with?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Cara
  • 41
  • 1
  • 8
  • You downloaded "compressed" files... one of the compression techniques is to eliminate as many semicolons as possible without breaking the code. These files are OK to work with. – Salman A Jan 02 '18 at 18:24

1 Answers1

2

Are these files OK to work with?

Yes, missing semicolons in most (but not all) places can be corrected by the JavaScript parser using the error-correction procedure* called Automatic Semicolon Insertion, which is built into the language specification. So leaving them out in the places ASI will fix for you is indeed allowed. But it's important to know ASI's rules if you're doing that. (And important to know the rules for ; in any case.) The Bootstrap team knows the rules. (jQuery uses explicit semicolons.)

It sounds like you just have a lint-style warning enabled that you didn't have enabled before that flags up missing semicolons even in places ASI will fix.

You could disable the warning by searching in the options for "lint" or "code style" or "code quality" options, finding the relevant option, and turning it off, but I wouldn't. Instead, I'd look for how to exempt libraries from lint/code style/code quality analysis, since the source of every library you use is unlikely to fit your overall coding style rules.


* According to the language's original creator, Brendan Eich:

ASI is (formally speaking) a syntactic error correction procedure. If you start to code as if it were a universal significant-newline rule, you will get into trouble.

(Amusingly, he also said he wishes he'd made newlines more significant originally, rather than less. But as he said, that ship sailed in 1995...)

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • Thanks! Just to clarify: There isn't anything wrong with the code, the files are just using a different style, but I should find a way to leave out certain libraries from lint/code style/code so that I don't get these warnings all the time? – Cara Jan 02 '18 at 17:28
  • @Cara: Yes, they're fine. And yes, that's what I'd do. I'm sure Aptana has a way to say "these are libs, don't bother to check lint/etc. checks on them." Sadly I don't know what it is, not using Aptana. – T.J. Crowder Jan 02 '18 at 17:36