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.

matchName.js 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc"));
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. var _default = (0, _iterateJsdoc.default)(({
  9. context,
  10. jsdoc,
  11. report,
  12. info: {
  13. lastIndex
  14. },
  15. utils
  16. }) => {
  17. const {
  18. match
  19. } = context.options[0] || {};
  20. if (!match) {
  21. report('Rule `no-restricted-syntax` is missing a `match` option.');
  22. return;
  23. }
  24. const {
  25. allowName,
  26. disallowName,
  27. replacement,
  28. tags = ['*']
  29. } = match[lastIndex];
  30. const allowNameRegex = allowName && utils.getRegexFromString(allowName);
  31. const disallowNameRegex = disallowName && utils.getRegexFromString(disallowName);
  32. let applicableTags = jsdoc.tags;
  33. if (!tags.includes('*')) {
  34. applicableTags = utils.getPresentTags(tags);
  35. }
  36. let reported = false;
  37. applicableTags.forEach(tag => {
  38. const allowed = !allowNameRegex || allowNameRegex.test(tag.name);
  39. const disallowed = disallowNameRegex && disallowNameRegex.test(tag.name);
  40. const hasRegex = allowNameRegex || disallowNameRegex;
  41. if (hasRegex && allowed && !disallowed) {
  42. return;
  43. }
  44. if (!hasRegex && reported) {
  45. return;
  46. }
  47. const fixer = () => {
  48. tag.source[0].tokens.name = tag.source[0].tokens.name.replace(disallowNameRegex, replacement);
  49. };
  50. let {
  51. message
  52. } = match[lastIndex];
  53. if (!message) {
  54. if (hasRegex) {
  55. message = disallowed ? `Only allowing names not matching \`${disallowNameRegex}\` but found "${tag.name}".` : `Only allowing names matching \`${allowNameRegex}\` but found "${tag.name}".`;
  56. } else {
  57. message = `Prohibited context for "${tag.name}".`;
  58. }
  59. }
  60. utils.reportJSDoc(message, hasRegex ? tag : null, // We could match up
  61. disallowNameRegex && replacement !== undefined ? fixer : null, false, {
  62. // Could also supply `context`, `comment`, `tags`
  63. allowName,
  64. disallowName,
  65. name: tag.name
  66. });
  67. if (!hasRegex) {
  68. reported = true;
  69. }
  70. });
  71. }, {
  72. matchContext: true,
  73. meta: {
  74. docs: {
  75. description: 'Reports the name portion of a JSDoc tag if matching or not matching a given regular expression.',
  76. url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-match-name'
  77. },
  78. fixable: 'code',
  79. schema: [{
  80. additionalProperies: false,
  81. properties: {
  82. match: {
  83. additionalProperies: false,
  84. items: {
  85. properties: {
  86. allowName: {
  87. type: 'string'
  88. },
  89. comment: {
  90. type: 'string'
  91. },
  92. context: {
  93. type: 'string'
  94. },
  95. disallowName: {
  96. type: 'string'
  97. },
  98. message: {
  99. type: 'string'
  100. },
  101. tags: {
  102. items: {
  103. type: 'string'
  104. },
  105. type: 'array'
  106. }
  107. },
  108. type: 'object'
  109. },
  110. type: 'array'
  111. }
  112. },
  113. required: ['match'],
  114. type: 'object'
  115. }],
  116. type: 'suggestion'
  117. }
  118. });
  119. exports.default = _default;
  120. module.exports = exports.default;
  121. //# sourceMappingURL=matchName.js.map