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
37 lines (32 loc) • 956 B
JavaScript
/**
* @fileoverview Rule to disallow an empty pattern
* @author Alberto Rodríguez
*/
;
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = {
meta: {
docs: {
description: "disallow empty destructuring patterns",
category: "Best Practices",
recommended: true
},
schema: []
},
create(context) {
return {
ObjectPattern(node) {
if (node.properties.length === 0) {
context.report(node, "Unexpected empty object pattern.");
}
},
ArrayPattern(node) {
if (node.elements.length === 0) {
context.report(node, "Unexpected empty array pattern.");
}
}
};
}
};