github-pages-deploy-action/node_modules/eslint/lib/rules/no-sparse-arrays.js

51 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-03-07 11:45:40 +08:00
/**
* @fileoverview Disallow sparse arrays
* @author Nicholas C. Zakas
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = {
meta: {
type: "problem",
docs: {
description: "disallow sparse arrays",
category: "Possible Errors",
recommended: true,
url: "https://eslint.org/docs/rules/no-sparse-arrays"
},
2020-05-15 05:33:08 +08:00
schema: [],
messages: {
unexpectedSparseArray: "Unexpected comma in middle of array."
}
2020-03-07 11:45:40 +08:00
},
create(context) {
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
return {
ArrayExpression(node) {
const emptySpot = node.elements.indexOf(null) > -1;
if (emptySpot) {
2020-05-15 05:33:08 +08:00
context.report({ node, messageId: "unexpectedSparseArray" });
2020-03-07 11:45:40 +08:00
}
}
};
}
};