Expected behavior
When several // comments sit on consecutive lines above a declaration, I'd expect the fixer to convert the whole group into one JSDoc block:
/**
* one
* two
* three
*/
type Foo = string;
Actual behavior
Only the last line is converted, and the earlier lines are left above the new block:
// one
// two
/**
* three
*/
type Foo = string;
The report is anchored on the last comment too, so it reads as though only that line is at fault.
This may well be by design, since ESLint hands the rule one comment token at a time and each // line is its own token. If so it might be worth a note in the docs — a paragraph written as stacked // lines is common enough that --fix over a codebase produces a lot of this, and the output is worse than the input.
ESLint Config
import jsdoc from 'eslint-plugin-jsdoc';
import tseslint from 'typescript-eslint';
export default [
{
files: ['**/*.ts'],
languageOptions: { parser: tseslint.parser },
plugins: { jsdoc },
rules: {
'jsdoc/convert-to-jsdoc-comments': [
'error',
{ contexts: ['TSTypeAliasDeclaration'] },
],
},
},
];
ESLint sample
// one
// two
// three
type Foo = string;
Run eslint --fix on it.
Environment
- Node version: 24.14.1
- ESLint version: 9.39.4
eslint-plugin-jsdoc version: 64.3.5
Expected behavior
When several
//comments sit on consecutive lines above a declaration, I'd expect the fixer to convert the whole group into one JSDoc block:Actual behavior
Only the last line is converted, and the earlier lines are left above the new block:
The report is anchored on the last comment too, so it reads as though only that line is at fault.
This may well be by design, since ESLint hands the rule one comment token at a time and each
//line is its own token. If so it might be worth a note in the docs — a paragraph written as stacked//lines is common enough that--fixover a codebase produces a lot of this, and the output is worse than the input.ESLint Config
ESLint sample
Run
eslint --fixon it.Environment
eslint-plugin-jsdocversion: 64.3.5