Last active
September 9, 2015 06:38
-
-
Save jasonmit/034f3114149faa39da7d to your computer and use it in GitHub Desktop.
Warn on jquery in controllers, routes, models
This file contains hidden or 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
var Filter = require('broccoli-filter'); | |
var controller = new RegExp(/(^controllers\/)|(^models\/)|(^routes\/)/); | |
var jquery = new RegExp(/\W(\$\.)|(\.\$\.)|(\$\()/); | |
NoJquery.prototype = Object.create(Filter.prototype); | |
NoJquery.prototype.constructor = NoJquery; | |
function NoJquery(inputNode) { | |
if (!(this instanceof NoJquery)) { | |
return new NoJquery(inputNode); | |
} | |
Filter.call(this, inputNode); | |
}; | |
NoJquery.prototype.extensions = ['js']; | |
NoJquery.prototype.targetExtension = 'js'; | |
NoJquery.prototype.processString = function (content, relativePath) { | |
if (controller.test(relativePath) && jquery.test(content)) { | |
console.error(relativePath); | |
content.split('\n').forEach(function(line, idx) { | |
var found = line.match(jquery); | |
if (found) { | |
console.error('Found some jquery on line' + idx); | |
console.error(line); | |
} | |
}); | |
} | |
}; | |
module.exports = NoJquery; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment