gajus / eslint-plugin-jsdoc

JSDoc specific linting rules for ESLint.
Other
1.09k stars 157 forks source link

check-examples works incorrect if name of project directory contains dot #1172

Closed YaroslavChub closed 9 months ago

YaroslavChub commented 9 months ago

Expected behavior

ESlint should check example from docs without errors.

Actual behavior

Name of my project directory contains a dot, let's say it has name eslint.with.dot.test I get the following error : error @example error: Parsing error: The keyword 'const' is reserved jsdoc/check-examples

I investigated this behavior and the reason is the following: ESlint config from my project was not found. It was not found because this regex cuts directory name https://github.com/gajus/eslint-plugin-jsdoc/blob/main/src/rules/checkExamples.js#L353 It looks like it should be changed to /.[^.]+$/u

ESLint Config

{
  "parserOptions": {
    "ecmaVersion": 2016
    // support ES6 syntax
  },
  "env": {
    "commonjs": true,
    "es6": true
  },
  "extends": [
    "eslint:recommended",
    "plugin:jsdoc/recommended"
  ],
  "plugins": [
      "jsdoc"
  ],
  "rules": {
    "jsdoc/check-examples": 2,
    "no-unused-vars": 0
  }
}

ESLint sample

/**
 * Do something.
 * @param {String} [name] Some name
 * @example 
 * const res = myfunc('name');
 * @returns {Object} Some result
 */
let myfunc = function (name) {};
// Format JS code here

Environment

github-actions[bot] commented 9 months ago

:tada: This issue has been resolved in version 46.9.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: