Skip to content

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

@budjmt

Description

@budjmt

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions