I want to know how can i disable JSHint’s checking for this type of declarations, so i can do:
obj.new = function(){
//...
};
instead of
obj['new'] = function(){
//...
};
thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the
es5option, since reserved words as property names are only valid as of ES5. Put this directive at the top of the file(s) in question:However, it’s worth bearing in mind that older browsers will throw errors if they encounter such syntax. If your code needs to run in older browsers (notably IE8) then you’re better off sticking to the alternative syntax, or using non-reserved words as property identifiers.
Edit: I’ve added a bit more detail about this error to its page on jslinterrors.com.