Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

no-sparse-arrays.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * @fileoverview Disallow sparse arrays
  3. * @author Nicholas C. Zakas
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Rule Definition
  8. //------------------------------------------------------------------------------
  9. module.exports = {
  10. meta: {
  11. type: "problem",
  12. docs: {
  13. description: "disallow sparse arrays",
  14. category: "Possible Errors",
  15. recommended: true,
  16. url: "https://eslint.org/docs/rules/no-sparse-arrays"
  17. },
  18. schema: []
  19. },
  20. create(context) {
  21. //--------------------------------------------------------------------------
  22. // Public
  23. //--------------------------------------------------------------------------
  24. return {
  25. ArrayExpression(node) {
  26. const emptySpot = node.elements.indexOf(null) > -1;
  27. if (emptySpot) {
  28. context.report({ node, message: "Unexpected comma in middle of array." });
  29. }
  30. }
  31. };
  32. }
  33. };