Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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-restricted-matchers.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _utils = require("./utils");
  7. var _default = (0, _utils.createRule)({
  8. name: __filename,
  9. meta: {
  10. docs: {
  11. category: 'Best Practices',
  12. description: 'Disallow specific matchers & modifiers',
  13. recommended: false
  14. },
  15. type: 'suggestion',
  16. schema: [{
  17. type: 'object',
  18. additionalProperties: {
  19. type: ['string', 'null']
  20. }
  21. }],
  22. messages: {
  23. restrictedChain: 'Use of `{{ chain }}` is disallowed',
  24. restrictedChainWithMessage: '{{ message }}'
  25. }
  26. },
  27. defaultOptions: [{}],
  28. create(context, [restrictedChains]) {
  29. return {
  30. CallExpression(node) {
  31. if (!(0, _utils.isExpectCall)(node)) {
  32. return;
  33. }
  34. const {
  35. matcher,
  36. modifier
  37. } = (0, _utils.parseExpectCall)(node);
  38. if (matcher) {
  39. const chain = matcher.name;
  40. if (chain in restrictedChains) {
  41. const message = restrictedChains[chain];
  42. context.report({
  43. messageId: message ? 'restrictedChainWithMessage' : 'restrictedChain',
  44. data: {
  45. message,
  46. chain
  47. },
  48. node: matcher.node.property
  49. });
  50. return;
  51. }
  52. }
  53. if (modifier) {
  54. const chain = modifier.name;
  55. if (chain in restrictedChains) {
  56. const message = restrictedChains[chain];
  57. context.report({
  58. messageId: message ? 'restrictedChainWithMessage' : 'restrictedChain',
  59. data: {
  60. message,
  61. chain
  62. },
  63. node: modifier.node.property
  64. });
  65. return;
  66. }
  67. }
  68. if (matcher && modifier) {
  69. const chain = `${modifier.name}.${matcher.name}`;
  70. if (chain in restrictedChains) {
  71. const message = restrictedChains[chain];
  72. context.report({
  73. messageId: message ? 'restrictedChainWithMessage' : 'restrictedChain',
  74. data: {
  75. message,
  76. chain
  77. },
  78. loc: {
  79. start: modifier.node.property.loc.start,
  80. end: matcher.node.property.loc.end
  81. }
  82. });
  83. return;
  84. }
  85. }
  86. }
  87. };
  88. }
  89. });
  90. exports.default = _default;