Sha256: 395222f8826b7a8baa1c6d34e237f4b733215ca4f8b15427b7da10eacbe6b47f
Contents?: true
Size: 1.73 KB
Versions: 45
Compression:
Stored size: 1.73 KB
Contents
/** * @fileoverview Rule to flag use of console object * @author Nicholas C. Zakas */ "use strict"; //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = { meta: { docs: { description: "disallow the use of `console`", category: "Possible Errors", recommended: true }, schema: [ { type: "object", properties: { allow: { type: "array", items: { type: "string" }, minItems: 1, uniqueItems: true } }, additionalProperties: false } ] }, create: function(context) { return { MemberExpression: function(node) { if (node.object.name === "console") { var blockConsole = true; if (context.options.length > 0) { var allowedProperties = context.options[0].allow; var passedProperty = node.property.name; var propertyIsAllowed = (allowedProperties.indexOf(passedProperty) > -1); if (propertyIsAllowed) { blockConsole = false; } } if (blockConsole) { context.report(node, "Unexpected console statement."); } } } }; } };
Version data entries
45 entries across 45 versions & 2 rubygems