question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: eslint & eslint-plugin-jsdoc integration

See original GitHub issue

Description

I’m attempting to integrate this plugin into my workflow, but it doesn’t seem the plugin is integrated with eslint-plugin-jsdoc, nor eslint itself.

Specifically, the lack of support for the tagNamePreference setting in eslint-plugin-jsdoc results in faulty errors regarding tags.

I’m not entirely sure, but I also suspect that the lack of integration with eslint (or maybe prettier-vscode?) means the following:

  • Issues yielded by this plugin are only displayed by directly running eslint
    • If I open a file with alleged issues, my editor (VSCode) doesn’t show any red squigglies where the plugin identified the issues; I have to run eslint to get a full report
  • Issues that are auto-fixable are not fixed on save
    • Normally when I save a file that has auto-fixable issues (even if the file doesn’t have any changes), those issues are fixed on save. This does not happen with issues yielded by this plugin; I have to run eslint --fix instead

Example

tagNamePreference settings:

{
    jsdoc: {
      tagNamePreference: {
        augments: 'extends',
        constant: 'const',
        fileoverview: 'file',
        returns: 'return'
      }
    }
}

Take the following file:

/**
 * @file Katas - tribonacci
 * @module katas/tribonacci
 */

/**
 * Given a starting sequence, `[a, b, c]`, the function returns an array with
 * the first `n` elements of the sequence.
 *
 * @see https://codewars.com/kata/556deca17c58da83c00002db
 *
 * @example tribonacci([1, 1, 1], 10) => [1, 1, 1, 3, 5, 9, 17, 31, 57, 105]
 * @example tribonacci([0, 0, 1], 10) => [0, 0, 1, 1, 2, 4, 7, 13, 24, 44]
 *
 * @param {[number, number, number]} args - Starting sequence
 * @param {number} n - Total number of elements in sequence
 * @return {number[]} First `n` elements of sequence
 */
const tribonacci = (
  [a, b, c]: [number, number, number],
  n: number
): number[] => {
  // Base case: If n is less than or equal to zero, return empty array
  if (n <= 0) return []

  /** @const {number} sum - Sum of {@link a}, {@link b}, and {@link c} */
  const sum: number = a + b + c

  // Generate and return sequence
  return [a, ...tribonacci([b, c, sum], n - 1)]
}

export default tribonacci

After running eslint ./src/katas/tribonacci.ts --exit-on-fatal-error --report-unused-disable-directives --fix:

/Users/lex/Projects/UNICORNWARE/katas/src/katas/tribonacci.ts
  17:11  error  Insert `s`                                                                       prettier/prettier
  26:12  error  Insert `tan`                                                                     prettier/prettier

✖ 8 problems (8 errors, 0 warnings)
  8 errors and 0 warnings potentially fixable with the `--fix` option.
  • 17:11: the plugin wants me to use @returns => my settings dictate using @return
  • 26:12: the plugin wants me to use @constant => my settings dictate using @const

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
hosseinmdcommented, Apr 7, 2022

My suggestion is, don’t use eslint-plugin-jsdoc and prettier-plugin-jsdoc both.

1reaction
hosseinmdcommented, Oct 4, 2022

Please don’t make that a goal of this project. Its main value is consistency within a codebase and making it inflexible makes it harder to adopt into codebases. The default settings suffice to nudge people towards your chosen norms.

Yes you are totaly right. but implemention is hard, some logic was hard code,

Read more comments on GitHub >

github_iconTop Results From Across the Web

eslint-plugin-jsdoc - npm
Start using eslint-plugin-jsdoc in your project by running `npm i ... features of JavaScript, one may use @babel/eslint-parser or to be able ...
Read more >
1510561 - Investigate switching to eslint-plugin-jsdoc
I'd like to separate out adding the node module for eslint-plugin-jsdoc into a separate bug - I would like to generate the patch...
Read more >
eslint-config-jsdoc-strict | Yarn - Package Manager
eslint -config-jsdoc-strict. ESLint shareable config for JSDoc-related rules: ESLint require-jsdoc and valid-jsdoc rules,; All eslint-plugin-jsdoc plugin ...
Read more >
Configuration Files (New) - ESLint - Pluggable JavaScript Linter
This is an experimental feature. To opt-in, place an eslint.config.js file in the root of your project or set the ESLINT_USE_FLAT_CONFIG environment ...
Read more >
@eslint-recommended/eslint-config-typescript - NPM Package ...
Recommended ESLint Shareable Config for TypeScript. ... Update dependency eslint-plugin-jsdoc to v39.6.4 by @renovate in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found