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.

checkPropertyNames.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. const validatePropertyNames = (targetTagName, enableFixer, jsdoc, jsdocNode, utils) => {
  9. const propertyTags = Object.entries(jsdoc.tags).filter(([, tag]) => {
  10. return tag.tag === targetTagName;
  11. });
  12. return propertyTags.some(([, tag], index) => {
  13. let tagsIndex;
  14. const dupeTagInfo = propertyTags.find(([tgsIndex, tg], idx) => {
  15. tagsIndex = tgsIndex;
  16. return tg.name === tag.name && idx !== index;
  17. });
  18. if (dupeTagInfo) {
  19. utils.reportJSDoc(`Duplicate @${targetTagName} "${tag.name}"`, dupeTagInfo[1], enableFixer ? () => {
  20. utils.removeTag(tagsIndex);
  21. } : null);
  22. return true;
  23. }
  24. return false;
  25. });
  26. };
  27. const validatePropertyNamesDeep = (targetTagName, jsdocPropertyNames, jsdoc, report) => {
  28. let lastRealProperty;
  29. return jsdocPropertyNames.some(({
  30. name: jsdocPropertyName,
  31. idx
  32. }) => {
  33. const isPropertyPath = jsdocPropertyName.includes('.');
  34. if (isPropertyPath) {
  35. if (!lastRealProperty) {
  36. report(`@${targetTagName} path declaration ("${jsdocPropertyName}") appears before any real property.`, null, jsdoc.tags[idx]);
  37. return true;
  38. }
  39. let pathRootNodeName = jsdocPropertyName.slice(0, jsdocPropertyName.indexOf('.'));
  40. if (pathRootNodeName.endsWith('[]')) {
  41. pathRootNodeName = pathRootNodeName.slice(0, -2);
  42. }
  43. if (pathRootNodeName !== lastRealProperty) {
  44. report(`@${targetTagName} path declaration ("${jsdocPropertyName}") root node name ("${pathRootNodeName}") ` + `does not match previous real property name ("${lastRealProperty}").`, null, jsdoc.tags[idx]);
  45. return true;
  46. }
  47. } else {
  48. lastRealProperty = jsdocPropertyName;
  49. }
  50. return false;
  51. });
  52. };
  53. var _default = (0, _iterateJsdoc.default)(({
  54. context,
  55. jsdoc,
  56. jsdocNode,
  57. report,
  58. utils
  59. }) => {
  60. const {
  61. enableFixer = false
  62. } = context.options[0] || {};
  63. const jsdocPropertyNamesDeep = utils.getJsdocTagsDeep('property');
  64. if (!jsdocPropertyNamesDeep.length) {
  65. return;
  66. }
  67. const targetTagName = utils.getPreferredTagName({
  68. tagName: 'property'
  69. });
  70. const isError = validatePropertyNames(targetTagName, enableFixer, jsdoc, jsdocNode, utils);
  71. if (isError) {
  72. return;
  73. }
  74. validatePropertyNamesDeep(targetTagName, jsdocPropertyNamesDeep, jsdoc, report);
  75. }, {
  76. iterateAllJsdocs: true,
  77. meta: {
  78. docs: {
  79. description: 'Ensures that property names in JSDoc are not duplicated on the same block and that nested properties have defined roots.',
  80. url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-property-names'
  81. },
  82. fixable: 'code',
  83. schema: [{
  84. additionalProperties: false,
  85. properties: {
  86. enableFixer: {
  87. type: 'boolean'
  88. }
  89. },
  90. type: 'object'
  91. }],
  92. type: 'suggestion'
  93. }
  94. });
  95. exports.default = _default;
  96. module.exports = exports.default;
  97. //# sourceMappingURL=checkPropertyNames.js.map