项目原始demo,不改动
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
Dieses Repo ist archiviert. Du kannst Dateien sehen und es klonen, kannst aber nicht pushen oder Issues/Pull-Requests öffnen.
 
 
 
 

42 Zeilen
1.1 KiB

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