UNPKG

charlike

Version:

Small, fast, simple and streaming project scaffolder for myself, but not only. Supports hundreds of template engines through the @JSTransformers API or if you want custom `render` function passed through options

44 lines (31 loc) 988 B
/** * @fileoverview Disallow sparse arrays * @author Nicholas C. Zakas */ "use strict"; //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = { meta: { docs: { description: "disallow sparse arrays", category: "Possible Errors", recommended: true }, schema: [] }, create(context) { //-------------------------------------------------------------------------- // Public //-------------------------------------------------------------------------- return { ArrayExpression(node) { const emptySpot = node.elements.indexOf(null) > -1; if (emptySpot) { context.report(node, "Unexpected comma in middle of array."); } } }; } };