Skip to content

The jsdoc/no-restricted-syntax rule doesn't work with a single line JSDoc comment #831

Closed
@macku

Description

@macku

Expected behavior

The jsdoc/no-restricted-syntax rule works with an inline and a single line JSDoc blocks.

Actual behavior

The jsdoc/jsdoc/no-restricted-syntax doesn't report the issue when using an inline or single line JSDoc comment block. The rule works only for a multiline JSDdoc comment:

Screen Shot 2022-01-17 at 09 36 18

Screen Shot 2022-01-17 at 09 35 46

ESLint Config

module.exports = {
  rules: {
    'jsdoc/no-restricted-syntax': [
      'error',
      {
        contexts: [
          {
            comment: 'JsdocBlock:has(JsdocTag[tag="type"]:has([value=/FunctionComponent/]))',
            context: 'any',
            message: 'The `FunctionComponent` type is not allowed. Please use `FC` instead.',
          },
        ],
      },
    ],
  }
};

ESLint sample

/** @type {React.FunctionComponent<{ children: React.ReactNode }>}*/
const MyComponent = ({ children }) => {
   return children;
}

Environment

  • Node version: v16.13.0
  • ESLint version v8.7.0
  • eslint-plugin-jsdoc version: 37.6.1

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions