eslint-plugin-jsdoc icon indicating copy to clipboard operation
eslint-plugin-jsdoc copied to clipboard

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

Open macku opened this issue 4 years ago • 2 comments

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

macku avatar Jan 17 '22 00:01 macku

I was trying to fix that over the weekend with the jsdoccomment project: https://github.com/es-joy/jsdoccomment/pull/6

macku avatar Jan 17 '22 00:01 macku

:tada: This issue has been resolved in version 37.7.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

gajus avatar Jan 26 '22 01:01 gajus