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.

require-jsdoc.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /**
  2. * @fileoverview Rule to check for jsdoc presence.
  3. * @author Gyandeep Singh
  4. */
  5. "use strict";
  6. module.exports = {
  7. meta: {
  8. type: "suggestion",
  9. docs: {
  10. description: "require JSDoc comments",
  11. category: "Stylistic Issues",
  12. recommended: false,
  13. url: "https://eslint.org/docs/rules/require-jsdoc"
  14. },
  15. schema: [
  16. {
  17. type: "object",
  18. properties: {
  19. require: {
  20. type: "object",
  21. properties: {
  22. ClassDeclaration: {
  23. type: "boolean",
  24. default: false
  25. },
  26. MethodDefinition: {
  27. type: "boolean",
  28. default: false
  29. },
  30. FunctionDeclaration: {
  31. type: "boolean",
  32. default: true
  33. },
  34. ArrowFunctionExpression: {
  35. type: "boolean",
  36. default: false
  37. },
  38. FunctionExpression: {
  39. type: "boolean",
  40. default: false
  41. }
  42. },
  43. additionalProperties: false,
  44. default: {}
  45. }
  46. },
  47. additionalProperties: false
  48. }
  49. ],
  50. deprecated: true,
  51. replacedBy: [],
  52. messages: {
  53. missingJSDocComment: "Missing JSDoc comment."
  54. }
  55. },
  56. create(context) {
  57. const source = context.getSourceCode();
  58. const DEFAULT_OPTIONS = {
  59. FunctionDeclaration: true,
  60. MethodDefinition: false,
  61. ClassDeclaration: false,
  62. ArrowFunctionExpression: false,
  63. FunctionExpression: false
  64. };
  65. const options = Object.assign(DEFAULT_OPTIONS, context.options[0] && context.options[0].require);
  66. /**
  67. * Report the error message
  68. * @param {ASTNode} node node to report
  69. * @returns {void}
  70. */
  71. function report(node) {
  72. context.report({ node, messageId: "missingJSDocComment" });
  73. }
  74. /**
  75. * Check if the jsdoc comment is present or not.
  76. * @param {ASTNode} node node to examine
  77. * @returns {void}
  78. */
  79. function checkJsDoc(node) {
  80. const jsdocComment = source.getJSDocComment(node);
  81. if (!jsdocComment) {
  82. report(node);
  83. }
  84. }
  85. return {
  86. FunctionDeclaration(node) {
  87. if (options.FunctionDeclaration) {
  88. checkJsDoc(node);
  89. }
  90. },
  91. FunctionExpression(node) {
  92. if (
  93. (options.MethodDefinition && node.parent.type === "MethodDefinition") ||
  94. (options.FunctionExpression && (node.parent.type === "VariableDeclarator" || (node.parent.type === "Property" && node === node.parent.value)))
  95. ) {
  96. checkJsDoc(node);
  97. }
  98. },
  99. ClassDeclaration(node) {
  100. if (options.ClassDeclaration) {
  101. checkJsDoc(node);
  102. }
  103. },
  104. ArrowFunctionExpression(node) {
  105. if (options.ArrowFunctionExpression && node.parent.type === "VariableDeclarator") {
  106. checkJsDoc(node);
  107. }
  108. }
  109. };
  110. }
  111. };