Last active
August 29, 2015 14:16
-
-
Save jschilli/2e867fc23c1eac602525 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function() {}; | |
module.exports.prototype = { | |
configure: function(noHandlebarsCompileExpression) { | |
this._isEnabled = noHandlebarsCompileExpression; | |
}, | |
getOptionName: function() { | |
return 'noHandlebarsCompile'; | |
}, | |
check: function(file, errors) { | |
if (!this._isEnabled) { | |
return; | |
} | |
file.iterateNodesByType('CallExpression', function(node) { | |
var lastCalleeToken = file.getLastNodeToken(node.callee); | |
if (lastCalleeToken.value === 'compile') { | |
var calleeObject = node.callee.object && node.callee.object.property; | |
if (calleeObject && calleeObject.name === 'Handlebars') { | |
errors.add( | |
'Don\'t call the Handlebars compile', | |
lastCalleeToken.loc.start | |
); | |
} | |
} | |
}); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"additionalRules": [ "tools/jscs-rules/*.js" ], | |
"excludeFiles": ["tests/fixtures/*"], | |
"noHandlebarsCompile": true, // -> will change to true when we excise remaining em.handlebars.compile | |
"usePrecompileTemplateProperly": true, | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function() {}; | |
module.exports.prototype = { | |
configure: function(usePrecompileProperly) { | |
this._isEnabled = usePrecompileProperly; | |
}, | |
getOptionName: function() { | |
return 'usePrecompileTemplateProperly'; | |
}, | |
check: function(file, errors) { | |
if (!this._isEnabled) { | |
return; | |
} | |
file.iterateNodesByType('CallExpression', function(node) { | |
if (node.callee.name === 'precompileTemplate' && node.arguments[0] && node.arguments[0].type !== 'Literal') { | |
errors.add( | |
'precompileTemplate must be called with a literal expression to work properly\ne.g precompileTemplate("{{foo}}"', | |
node.loc.start | |
); | |
} | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment