You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

36 lines
956 B

/**
* @fileoverview Rule to disallow an empty pattern
* @author Alberto Rodríguez
*/
"use strict";
//------------------------------------------------------------------------------
// 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.");
}
}
};
}
};