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.

eslint-plugin-tsdoc: allow policies to be ignored in tsdoc/syntax rule

See original GitHub issue

Now that less-strict parsing for @param tags is merged (https://github.com/microsoft/tsdoc/issues/128), I’d love to be able to loosen the requirements of the tsdoc/syntax rule to allow for certain deviations from the expected syntax.

Primarily, VSCode’s built-in JSDoc support automatically adds a doc comment where each @param tag is followed immediately by a description, without the expected hyphen. With the following .eslintrc configuration:

{
  rules: {
    'tsdoc/syntax': 'warn'
  }
}

This snippet is valid:

/**
 * Description
 * @param a - first number
 * @param b - second number
 */
const add = (a: number, b: number) => a + b;

While this snippet:

/**
 * Description
 * @param a first number
 * @param b second number
 */
const add = (a: number, b: number) => a + b;

Warns with the following:

tsdoc-param-tag-missing-hyphen: The @param block should be followed by a parameter name and then a hyphen eslint(tsdoc/syntax)

I’d love to be able to ignore this particular syntax deviation with something like:

{
  rules: {
    'tsdoc/syntax': ['warn', ignore: ['tsdoc-param-tag-missing-hyphen'] ]
  }
}

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:24
  • Comments:6

github_iconTop GitHub Comments

11reactions
rob4226commented, Aug 23, 2021

Yes, please an "ignoreMessageIds" is very much needed. Unless I am missing something it seems the eslint-plugin-tsdoc is all or nothing. Is there any way to stop reporting on some message ids at the moment?

6reactions
octogonzcommented, Mar 27, 2020

This is a good idea. However I think we might want to approach it via the tsdoc.json config file rather than via ESLint’s configuration. The reason is that you are not really suppressing a warning, but rather defining the kind of TSDoc parsing that you want for your source files. Putting the suppression in tsdoc.json will prevent other tools from reporting the same errors when they invoke the parser.

Long term, we intend to provide a “lax mode” as well as other compatibility settings for the TSDoc parser. But in the short term, this kind of problem can be solved pretty well by simply filtering out specific error IDs as you suggest. (The reason that’s not a perfect solution is that the syntax highlighting may sometimes color the bad characters in red even though the error message is hidden.)

eslint-plugin-tsdoc already supports tsdoc.json, so we would simply need to improve tsdoc.schema.json to support something like this:

your-project/tsdoc.json

{
  "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
  "ignoreMessageIds": [
    "tsdoc-config-file-not-found"
  ]
}

…and then pass that setting through to the parser. It’s mostly plumbing work, since in the end all we’re doing is adding a filter to ParserMessageLog.addMessage().

Read more comments on GitHub >

github_iconTop Results From Across the Web

require-jsdoc - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
eslint-plugin-tsdoc
This ESLint plugin provides a rule for validating that TypeScript doc comments conform to the TSDoc specification. Usage. Configure ESLint for your TypeScript ......
Read more >
eslint-plugin-jsdoc - npm Package Health Analysis - Snyk
Inline ESLint config within @example JavaScript is allowed (or within @default , etc.), though the disabling of ESLint directives which are not needed...
Read more >
eslint-plugin-jsdoc - npm
JSDoc linting rules for ESLint. eslint-plugin-jsdoc. Installation; Configuration; Options; Settings. Allow tags ( @private or @internal ) to ...
Read more >
eslint-plugin-functional | Yarn - Package Manager
ESLint rules to disable mutation and promote fp in TypeScript. eslint, eslint plugin, fp, functional. readme. eslint-logo. eslint-plugin ...
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