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

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

Closed
YaroslavChub opened this issue Dec 13, 2023 · 1 comment · Fixed by #1173
Closed

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

YaroslavChub opened this issue Dec 13, 2023 · 1 comment · Fixed by #1173

Comments

@YaroslavChub
Copy link

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

  • Node version: 16.14.2
  • ESLint version 7.32.0
  • eslint-plugin-jsdoc version: 46.9.0
Copy link

🎉 This issue has been resolved in version 46.9.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant