Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
macku opened this issue Jan 17, 2022 · 2 comments

Comments

@macku
Copy link

macku commented Jan 17, 2022

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
Copy link
Author

macku commented Jan 17, 2022

I was trying to fix that over the weekend with the jsdoccomment project:
es-joy/jsdoccomment#6

@gajus
Copy link
Owner

gajus commented Jan 26, 2022

🎉 This issue has been resolved in version 37.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants