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

jsdoc/no-restricted-syntax: context does not support full range of selectors if any other context is any/* #818

Closed
budjmt opened this issue Dec 17, 2021 · 5 comments

Comments

@budjmt
Copy link

budjmt commented Dec 17, 2021

Expected behavior

I am able to use the full range of AST selectors with no-missing-syntax; I would expect no-restricted-syntax to have parity, regardless of which other contexts are used

Actual behavior

error Syntax is restricted: undefined jsdoc/no-restricted-syntax
Note that the configured message is also not used

ESLint Config

parser is @typescript-eslint/parser, this is the only rule needed:

"jsdoc/no-restricted-syntax": [ "error", {
            "contexts": [
                {
                    "context": "any",
                    "comment": "JsdocBlock[postDelimiter='']:has(JsdocTag ~ JsdocTag[tag=/private|protected/])",
                    "message": "Access modifier tags must come first"
                },
                {
                    "context": ":declaration:not(TSEnumDeclaration):not(:has(ObjectExpression)), :function",
                    "comment": "JsdocBlock[postDelimiter='']:has(JsdocTag[tag='enum'])",
                    "message": "@enum is only allowed on potential enum types"
                },
            ]
        } ]

If the other rule is deleted or the context is changed to something else (excluding *), the context is interpreted correctly

ESLint sample

/**
 * @enum {String}
 * Object holding values of some custom enum
 */
const MY_ENUM = Object.freeze({
  VAL_A: "myvala"
} as const);

Environment

  • Node version: 16.13.1
  • ESLint version 8.4.1
  • eslint-plugin-jsdoc version: 37.2.2
@budjmt budjmt changed the title jsdoc/no-restricted-syntax: context does not support full range of selectors if any other context is any/* jsdoc/no-restricted-syntax: context does not support full range of selectors if any other context is any/* Dec 17, 2021
@gajus
Copy link
Owner

gajus commented Dec 18, 2021

🎉 This issue has been resolved in version 37.2.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Dec 18, 2021
@brettz9
Copy link
Collaborator

brettz9 commented Dec 18, 2021

Thank you for the report. Turns out we had two problems. One was that there was indeed a specific issue with no-restricted-syntax that could cause it to report just because there was a context match (without a comment match). Another more serious issue was that if one reused the same context, the old value would be overwritten. Both of these issues should now be fixed.

However, I think there may be still one issue remaining (I believe with no-restricted-syntax alone); namely, if there is an "any" context, only handling for such a context occurs.

@brettz9
Copy link
Collaborator

brettz9 commented Dec 18, 2021

Ok, should now hopefully be all fixed in v37.2.6.

@brettz9
Copy link
Collaborator

brettz9 commented Dec 18, 2021

Sigh, still one more was needed: 37.2.7

@budjmt
Copy link
Author

budjmt commented Dec 18, 2021

Thanks for the quick response!!

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