Skip to content

linter: jsdoc/require-returns raised when using @callback #19434

Description

@overpolish

What version of Oxlint are you using?

1.47.0

What command did you run?

VS Code extension

What does your .oxlintrc.json config file look like?

{
  "$schema": "./node_modules/oxlint/configuration_schema.json",
  "categories": {
    "correctness": "error",
    "pedantic": "error",
    "restriction": "warn",
    "style": "warn"
  },
  "plugins": ["jsdoc"],
  "jsPlugins": [{ "name": "jsdoc-js", "specifier": "eslint-plugin-jsdoc" }],
  "rules": {
    "jsdoc/require-returns": "off", // Disabled as part of the around
    "jsdoc/require-param-description": "off",
    "jsdoc-js/require-jsdoc": "error",
    "jsdoc-js/require-returns": "error",
    "new-cap": ["warn", { "capIsNewExceptions": ["RuleCreator"] }],
    "oxc/no-optional-chaining": "off",
    // Sort handled by oxfmt
    "sort-imports": "off",
    "unicorn/no-typeof-undefined": "off",
    "no-inline-comments": ["error", { "ignorePattern": "type" }],
    "eslint/id-length": [
      "warn",
      {
        "exceptions": ["i", "a", "b"]
      }
    ],
    "eslint/no-magic-numbers": [
      "warn",
      {
        "ignore": [0, 1, -1]
      }
    ]
  },
  "overrides": [
    {
      "files": ["**/rules/*.ts"],
      "rules": {
        "max-lines": "off"
      }
    }
  ]
}

What happened?

When using JSDoc @callback oxc incorrectly reports a duplicate returns statement even though these are separate.

From what I can tell oxc thinks that the JSDoc of the callback should be applied to the next available function, rather than being able to stand on its own.

Duplicate `@returns` tags.
help: Remove the redundant `@returns` tag.oxc[eslint-plugin-jsdoc(require-returns)](https://oxc.rs/docs/guide/usage/linter/rules/jsdoc/require-returns.html)
/**
 * Callback to get the order index of a property name based on compiled regex patterns.
 * @callback OrderIndexGetter
 * @param {string} propName Property name to check.
 * @returns {number} Order index based on matching pattern, or length of patterns if no match.
 */

/**
 * Create a function that returns the order index of a property name based on
 * compiled regex patterns. Returns pattern array length if no match found.
 * @param {RegExp[]} compiledOrder - Compiled regex patterns in priority order.
 * @returns {OrderIndexGetter} Function that takes a property name and returns its order index.
 */
const createOrderIndexGetter = (compiledOrder) => (propName) => {
  for (let i = 0; i < compiledOrder.length; i += 1) {
    if (compiledOrder[i].test(propName)) {
      return i;
    }
  }
  return compiledOrder.length;
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions