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.

checkValues.js 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _semver = _interopRequireDefault(require("semver"));
  7. var _spdxExpressionParse = _interopRequireDefault(require("spdx-expression-parse"));
  8. var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc"));
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. var _default = (0, _iterateJsdoc.default)(({
  11. utils,
  12. report,
  13. context
  14. }) => {
  15. const options = context.options[0] || {};
  16. const {
  17. allowedLicenses = null,
  18. allowedAuthors = null,
  19. numericOnlyVariation = false,
  20. licensePattern = '/([^\n\r]*)/gu'
  21. } = options;
  22. utils.forEachPreferredTag('version', (jsdocParameter, targetTagName) => {
  23. const version = utils.getTagDescription(jsdocParameter).trim();
  24. if (!version) {
  25. report(`Missing JSDoc @${targetTagName} value.`, null, jsdocParameter);
  26. } else if (!_semver.default.valid(version)) {
  27. report(`Invalid JSDoc @${targetTagName}: "${utils.getTagDescription(jsdocParameter)}".`, null, jsdocParameter);
  28. }
  29. });
  30. if (numericOnlyVariation) {
  31. utils.forEachPreferredTag('variation', (jsdocParameter, targetTagName) => {
  32. const variation = utils.getTagDescription(jsdocParameter).trim();
  33. if (!variation) {
  34. report(`Missing JSDoc @${targetTagName} value.`, null, jsdocParameter);
  35. } else if (!Number.isInteger(Number(variation)) || Number(variation) <= 0) {
  36. report(`Invalid JSDoc @${targetTagName}: "${utils.getTagDescription(jsdocParameter)}".`, null, jsdocParameter);
  37. }
  38. });
  39. }
  40. utils.forEachPreferredTag('since', (jsdocParameter, targetTagName) => {
  41. const version = utils.getTagDescription(jsdocParameter).trim();
  42. if (!version) {
  43. report(`Missing JSDoc @${targetTagName} value.`, null, jsdocParameter);
  44. } else if (!_semver.default.valid(version)) {
  45. report(`Invalid JSDoc @${targetTagName}: "${utils.getTagDescription(jsdocParameter)}".`, null, jsdocParameter);
  46. }
  47. });
  48. utils.forEachPreferredTag('license', (jsdocParameter, targetTagName) => {
  49. const licenseRegex = utils.getRegexFromString(licensePattern, 'g');
  50. const match = utils.getTagDescription(jsdocParameter).match(licenseRegex);
  51. const license = match && match[1] || match[0];
  52. if (!license.trim()) {
  53. report(`Missing JSDoc @${targetTagName} value.`, null, jsdocParameter);
  54. } else if (allowedLicenses) {
  55. if (allowedLicenses !== true && !allowedLicenses.includes(license)) {
  56. report(`Invalid JSDoc @${targetTagName}: "${license}"; expected one of ${allowedLicenses.join(', ')}.`, null, jsdocParameter);
  57. }
  58. } else {
  59. try {
  60. (0, _spdxExpressionParse.default)(license);
  61. } catch {
  62. report(`Invalid JSDoc @${targetTagName}: "${license}"; expected SPDX expression: https://spdx.org/licenses/.`, null, jsdocParameter);
  63. }
  64. }
  65. });
  66. utils.forEachPreferredTag('author', (jsdocParameter, targetTagName) => {
  67. const author = utils.getTagDescription(jsdocParameter).trim();
  68. if (!author) {
  69. report(`Missing JSDoc @${targetTagName} value.`, null, jsdocParameter);
  70. } else if (allowedAuthors && !allowedAuthors.includes(author)) {
  71. report(`Invalid JSDoc @${targetTagName}: "${utils.getTagDescription(jsdocParameter)}"; expected one of ${allowedAuthors.join(', ')}.`, null, jsdocParameter);
  72. }
  73. });
  74. }, {
  75. iterateAllJsdocs: true,
  76. meta: {
  77. docs: {
  78. description: 'This rule checks the values for a handful of tags: `@version`, `@since`, `@license` and `@author`.',
  79. url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-values'
  80. },
  81. schema: [{
  82. additionalProperties: false,
  83. properties: {
  84. allowedAuthors: {
  85. items: {
  86. type: 'string'
  87. },
  88. type: 'array'
  89. },
  90. allowedLicenses: {
  91. anyOf: [{
  92. items: {
  93. type: 'string'
  94. },
  95. type: 'array'
  96. }, {
  97. type: 'boolean'
  98. }]
  99. },
  100. licensePattern: {
  101. type: 'string'
  102. },
  103. numericOnlyVariation: {
  104. type: 'boolean'
  105. }
  106. },
  107. type: 'object'
  108. }],
  109. type: 'suggestion'
  110. }
  111. });
  112. exports.default = _default;
  113. module.exports = exports.default;
  114. //# sourceMappingURL=checkValues.js.map