mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
ESLint 2.9.0 fixes some minor bugs that we have been experiencing and introduces some new rules that we may wish to consider. PR-URL: https://github.com/nodejs/node/pull/6498 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
37 lines
986 B
JavaScript
37 lines
986 B
JavaScript
/**
|
|
* @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: function(context) {
|
|
return {
|
|
ObjectPattern: function(node) {
|
|
if (node.properties.length === 0) {
|
|
context.report(node, "Unexpected empty object pattern.");
|
|
}
|
|
},
|
|
ArrayPattern: function(node) {
|
|
if (node.elements.length === 0) {
|
|
context.report(node, "Unexpected empty array pattern.");
|
|
}
|
|
}
|
|
};
|
|
}
|
|
};
|