noRestrictedSyntax.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.js"));
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. var _default = exports.default = (0, _iterateJsdoc.default)(({
  9. context,
  10. info: {
  11. comment
  12. },
  13. report,
  14. utils
  15. }) => {
  16. if (!context.options.length) {
  17. report('Rule `no-restricted-syntax` is missing a `contexts` option.');
  18. return;
  19. }
  20. const {
  21. contexts
  22. } = context.options[0];
  23. const {
  24. foundContext,
  25. contextStr
  26. } = utils.findContext(contexts, comment);
  27. // We are not on the *particular* matching context/comment, so don't assume
  28. // we need reporting
  29. if (!foundContext) {
  30. return;
  31. }
  32. const message = /** @type {import('../iterateJsdoc.js').ContextObject} */(foundContext === null || foundContext === void 0 ? void 0 : foundContext.message) ?? 'Syntax is restricted: {{context}}' + (comment ? ' with {{comment}}' : '');
  33. report(message, null, null, comment ? {
  34. comment,
  35. context: contextStr
  36. } : {
  37. context: contextStr
  38. });
  39. }, {
  40. contextSelected: true,
  41. meta: {
  42. docs: {
  43. description: 'Reports when certain comment structures are present.',
  44. url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-restricted-syntax.md#repos-sticky-header'
  45. },
  46. fixable: 'code',
  47. schema: [{
  48. additionalProperties: false,
  49. properties: {
  50. contexts: {
  51. items: {
  52. anyOf: [{
  53. type: 'string'
  54. }, {
  55. additionalProperties: false,
  56. properties: {
  57. comment: {
  58. type: 'string'
  59. },
  60. context: {
  61. type: 'string'
  62. },
  63. message: {
  64. type: 'string'
  65. }
  66. },
  67. type: 'object'
  68. }]
  69. },
  70. type: 'array'
  71. }
  72. },
  73. required: ['contexts'],
  74. type: 'object'
  75. }],
  76. type: 'suggestion'
  77. },
  78. nonGlobalSettings: true
  79. });
  80. module.exports = exports.default;
  81. //# sourceMappingURL=noRestrictedSyntax.js.map