Urara-Blog/node_modules/.pnpm-store/v3/files/12/3d1a05254ab58225a30c98432ea1f6372000b43e2370c374f9092dc9a9ea66f11bae0bd67bc90bfa73c0da8616623bc5e827b169ad09295507ad3ed681c129
2022-08-14 01:14:53 +08:00

43 lines
1.2 KiB
Text

/**
* @fileoverview Rule to disallow an empty pattern
* @author Alberto Rodríguez
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../shared/types').Rule} */
module.exports = {
meta: {
type: "problem",
docs: {
description: "Disallow empty destructuring patterns",
recommended: true,
url: "https://eslint.org/docs/rules/no-empty-pattern"
},
schema: [],
messages: {
unexpected: "Unexpected empty {{type}} pattern."
}
},
create(context) {
return {
ObjectPattern(node) {
if (node.properties.length === 0) {
context.report({ node, messageId: "unexpected", data: { type: "object" } });
}
},
ArrayPattern(node) {
if (node.elements.length === 0) {
context.report({ node, messageId: "unexpected", data: { type: "array" } });
}
}
};
}
};