ãJavaScriptã®æ§æãã§ãã«ã¼JSLintãEmacsãã使ããã§ç´¹ä»ããJSLintã¯ãevalãããã¨ãevalã¯evilï¼éªæªï¼ã ãã¨å¿ ãæå¥ãè¨ãã¾ããããè¨ããã¦ãevalã使ãããã¨ãã¯ããã¾ããä¾ãã°ãå®ç´ãªJSONãã³ã¼ããä½ãããå ´åï¼
/* evil.js */
function decodeJson(jsonText) {
return eval('(' + jsonText + ')');
}
JSLintã¯ããè¨ãã¾ãã
evil.js:3: character 10: eval is evil.
return eval('(' + jsonText + ')');
ãã¼ãããããããããªã¨ãã次ã®åªæãæ¸ãã¨JSLintãé»ãããã§ãã
/* evil.js */
/*jslint evil: true */function decodeJson(jsonText) {
return eval('(' + jsonText + ')');
}
JSLintã®ã½ã¼ã¹å ãæ¢ãããã次ã®ãããªãªãã·ã§ã³ä¸è¦§ãããã¾ãããevilã¨åæ§ãªæ¹æ³ã§ãªãã·ã§ã³ã調æ´ããã¨ãä½è¨ãªãç¯ä»ãããããããã¨ãã§ããã§ãããã
// These are all of the JSLint options.allOptions = {
adsafe : true, // if use of some browser features should be restricted
bitwise : true, // if bitwise operators should not be allowed
browser : true, // if the standard browser globals should be predefined
cap : true, // if upper case HTML should be allowed
debug : true, // if debugger statements should be allowed
eqeqeq : true, // if === should be required
evil : true, // if eval should be allowed
forin : true, // if for in statements must filter
fragment : true, // if HTML fragments should be allowed
laxbreak : true, // if line breaks should not be checked
nomen : true, // if names should be checked
on : true, // if HTML event handlers should be allowed
passfail : true, // if the scan should stop on first error
plusplus : true, // if increment/decrement should not be allowed
rhino : true, // if the Rhino environment globals should be predefined
undef : true, // if variables should be declared before used
white : true, // if strict whitespace rules apply
widget : true // if the Yahoo Widgets globals should be predefined
},