I seem to be having a problem with SublimeLinter-jshint and I couldn't find what I was looking for in the JSLint docs. At first, I thought it was a problem specifically with "Missing semicolon" (after an opening curly brace) but as I tried to ignore the issue and carry on with coding, more and more other errors kept popping up.
I am currently working through a JS tutorial and have all my scripts inline. I did notice that when I moved all of my JavaScript into a script in the head of the HTML file, all of the warnings disappeared (I tested it by intentionally breaking some of the code to see if it was still working, and all was fine).
What is it I'm doing wrong?
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Object Oriented JS</title>
<script type="text/javascript">
/*jslint evil: true */
function Person(name, street){
this.name = name;
this.street = street;
this.info = function(){
return "My name is " + this.name + " and I live on " + this.street;
};
}
</script>
</head>
<body>
<script type="text/javascript">
function Mammal(name){
this.name = name;
this.getInfo = function(){
return "The mammals name is " + this.name;
};
}
Mammal.prototype.sound = "Grrr";
Mammal.prototype.makeSound = function() {
return this.name + " says " + this.sound;
};
var grover = new Mammal("Grover");
document.write(grover.makeSound() + "<br />");
for(var prop in grover){
document.write(prop + " : " + grover[prop] + "<br />");
}
</script>
</body>
</html>
Just to add, everything is loading absolutely fine in the browser so I'm pretty sure these are false warnings.