I'm using 02_jshint.js to code lint my Ionic project, everything goes well until I receive this error:
35:4 -> Missing semicolon. -> })
and it's pointing to the last constant's bracket of my code:
angular.module('myApp.constants',['ionic'])
.constant('A','2.1.4')
.constant('B','1.1.3')
.constant("c", {
"d": "cost1",
"e": "cost2",
"f": "cost3"
})
I would like to know if there is a way to avoid this warning or to correct the error, it's clear that the code is correct but I would like to build my project (it doesn't allow to do that if there are any errors). Any advice?
Check jshint documentation jshint.com/docs.
In case you know why you don't want to put a semicolon there (which would be a good practice) try to put some ignore
directives around it:
A directive for telling JSHint to ignore a block of code.
// Code here will be linted with JSHint.
/* jshint ignore:start */
// Code here will be ignored by JSHint.
/* jshint ignore:end */
Additionally, you can ignore a single line with a trailing comment:
ignoreThis(); // jshint ignore:line
angular.module('myApp.constants',['ionic']).whatevergoeshere()
is a chained statement. In JavaScript you always should terminate statements using a semicolon.
I advice you not to switch this rule off but just add the semicolon.
The semicolon (;) character is used to separate statements in JavaScript code.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Control_flow_and_error_handling
you missed semicolon in the last.
angular.module('myApp.constants',['ionic'])
.constant('A','2.1.4')
.constant('B','1.1.3')
.constant("c", {
"d": "cost1",
"e": "cost2",
"f": "cost3"
});