eslint-plugin-detect-bad-words
Version:
Detect bad/profanity words in code
31 lines (30 loc) • 998 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var util_1 = require("../util");
module.exports = {
create: function (context) {
var settings = context.settings || {};
var customBadWords = settings.customBadWords || [];
var sourceCode = context.getSourceCode();
var validate = function (comment) {
if (!comment.loc || !comment.value)
return;
var result = util_1.searchForBadWords(customBadWords, comment.value);
if (!util_1.isEmpty(result)) {
context.report({
loc: comment.loc,
message: util_1.buildErrorMessage(result[0].trim()),
});
}
else {
return;
}
};
return {
Program: function () {
var comments = sourceCode.getAllComments();
comments.forEach(validate);
},
};
},
};