Closed
Description
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