.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / eslint / lib / rules / no-empty-pattern.js
1 /**
2  * @fileoverview Rule to disallow an empty pattern
3  * @author Alberto Rodríguez
4  */
5 "use strict";
6
7 //------------------------------------------------------------------------------
8 // Rule Definition
9 //------------------------------------------------------------------------------
10
11 module.exports = {
12     meta: {
13         type: "problem",
14
15         docs: {
16             description: "disallow empty destructuring patterns",
17             category: "Best Practices",
18             recommended: true,
19             url: "https://eslint.org/docs/rules/no-empty-pattern"
20         },
21
22         schema: [],
23
24         messages: {
25             unexpected: "Unexpected empty {{type}} pattern."
26         }
27     },
28
29     create(context) {
30         return {
31             ObjectPattern(node) {
32                 if (node.properties.length === 0) {
33                     context.report({ node, messageId: "unexpected", data: { type: "object" } });
34                 }
35             },
36             ArrayPattern(node) {
37                 if (node.elements.length === 0) {
38                     context.report({ node, messageId: "unexpected", data: { type: "array" } });
39                 }
40             }
41         };
42     }
43 };