gajus / eslint-plugin-jsdoc

JSDoc specific linting rules for ESLint.
Other
1.08k stars 155 forks source link

Excluding ArrowFunctionExpression in CallExpressions reporting as errors #1195

Closed martiensk closed 5 months ago

martiensk commented 5 months ago

Expected behavior

When using the rule jsdoc/require-jsdoc with contexts with :not(CallExpression) > ArrowFunctionExpression, the plugin should not trigger an error on Vue lifecycle hooks (or setTimeout).

Actual behavior

An error is triggered.

ESLint Config

"jsdoc/require-jsdoc": [
  "error", 
  {
    "contexts": [
      ":not(CallExpression) > ArrowFunctionExpression"
    ],
    "require": {
      "ArrowFunctionExpression":false,
      "FunctionDeclaration": true,
      "MethodDefinition": true,
      "FunctionExpression": true
    }
  }
]

ESLint sample

setTimeout(() => {}, 10);
// Or in the case of Vue
onMounted(() => {
    initScrollTriggerAnimation();
});

Environment

brettz9 commented 5 months ago

I am not able to replicate getting any errors for this.

Feel free to try to replicate against https://eslint-online-playground.netlify.app/#eNp1U8FOAyEQ/RXCqTWtq9c1mhirN+PBxot4QJhWlB3WAbTG7L8Ly65tjeWwgZnHmzfM22/uSVWwkU1r4fjV85pXRwy8NRjm2nj5bIGhm0fUsGJHlUCBHsLSNOBimEym7PyCfXczdnoyPRNYVeyOmEEWXoAp6YG5FXuIINDhrYsYQI93BLK0DJpwr8hZuySzXgNdomlkMA4nma/LHz7jx0URqSTRYRLZXxccNgFQe8Fr9phOPagmUK5pUhy04LOEam1cG6xfvXaq2ss+zQpPK8kD3bW5cM82yEucqpEPQD4lclxwKwP4kIhHhHeRFCy/WiiAxulo0z7nu4GfUmSfdxTzHg3BvD+NXRA5ysIHbEYrl55uE4ZGh3BO1OjC5Epae71pCXyWOWUX7DJxfN5EVLmhbaqIyqs0XjgGETvySvwgSb2S1sMvQ8aOsAUoK6kfYOYLFPdxtxBenF7AKg/+EOjfmj1sRHVl0z31j5x8kjzSSvUm19nEuw7R8LGANo8blfkzg+KXA2Md/oHine2Atsjf0t0P+MkQTg==

martiensk commented 5 months ago

@brettz9 I managed to fix my problem - it is not a bug with eslint. It is a bug with my knowledge. Below is what caused the problem, I fixed it by changing my contexts string to :not(CallExpression):not(Property) > ArrowFunctionExpression

"jsdoc/require-jsdoc": [
      "warn", 
      {
        "contexts": [
          ":not(CallExpression) > ArrowFunctionExpression",
          ":not(Property) > ArrowFunctionExpression"
        ],
        "require": {
          "ArrowFunctionExpression":false,
          "FunctionDeclaration": true,
          "MethodDefinition": true,
          "FunctionExpression": true
        }
      }
    ]