1 |
|
2 |
|
3 |
|
4 |
|
5 | "use strict";
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | module.exports = {
|
12 | meta: {
|
13 | docs: {
|
14 | description: "disallow empty destructuring patterns",
|
15 | category: "Best Practices",
|
16 | recommended: true,
|
17 | url: "https://eslint.org/docs/rules/no-empty-pattern"
|
18 | },
|
19 |
|
20 | schema: [],
|
21 |
|
22 | messages: {
|
23 | unexpected: "Unexpected empty {{type}} pattern."
|
24 | }
|
25 | },
|
26 |
|
27 | create(context) {
|
28 | return {
|
29 | ObjectPattern(node) {
|
30 | if (node.properties.length === 0) {
|
31 | context.report({ node, messageId: "unexpected", data: { type: "object" } });
|
32 | }
|
33 | },
|
34 | ArrayPattern(node) {
|
35 | if (node.elements.length === 0) {
|
36 | context.report({ node, messageId: "unexpected", data: { type: "array" } });
|
37 | }
|
38 | }
|
39 | };
|
40 | }
|
41 | };
|