1 | 'use strict';
|
2 | const getDocumentationUrl = require('./utils/get-documentation-url');
|
3 |
|
4 | const message = 'Array destructuring may not contain consecutive ignored values.';
|
5 | const isCommaFollowedWithComma = (element, index, array) =>
|
6 | element === null && array[index + 1] === null;
|
7 |
|
8 | const create = context => {
|
9 | return {
|
10 | 'ArrayPattern[elements.length>=3]': node => {
|
11 | if (node.elements.some((element, index, array) => isCommaFollowedWithComma(element, index, array))) {
|
12 | context.report({
|
13 | node,
|
14 | message
|
15 | });
|
16 | }
|
17 | }
|
18 | };
|
19 | };
|
20 |
|
21 | module.exports = {
|
22 | create,
|
23 | meta: {
|
24 | type: 'suggestion',
|
25 | docs: {
|
26 | url: getDocumentationUrl(__filename)
|
27 | }
|
28 | }
|
29 | };
|