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

Disable code activation on save only for plugin jsdoc in VsCode #941

Closed
antho227 opened this issue Jan 11, 2023 · 4 comments
Closed

Disable code activation on save only for plugin jsdoc in VsCode #941

antho227 opened this issue Jan 11, 2023 · 4 comments

Comments

@antho227
Copy link

antho227 commented Jan 11, 2023

Hello,

I'd like to disable the auto fix on save only for eslint-plugin-jsdoc in my VS Code Workspace. And I want to keep the auto fix for eslint.

My VS Code Workspace :

"editor.codeActionsOnSave": {
    "source.fixAll.eslint": true,
    "source.fixAll.eslint-plugin-jsdoc": false // not working
},

And the content of my ".eslintrc.json" :

{
  "parserOptions": {
    "ecmaVersion": 2020,
    "sourceType": "module"
  },
  "env": {
    "es6": true,
    "browser": true,
    "node": true,
    "mocha": true
  },
  "globals": {
    "console": true
  },
  "plugins": [
    "jsdoc"
  ],
  "extends": [
    "eslint:recommended",
    "plugin:jsdoc/recommended"
  ],
  "rules": {
    "jsdoc/newline-after-description": 0,
    ...all rules
  }
}
@antho227 antho227 changed the title Disable Code Activation On Save only for plugin jsdoc in VsCode Disable code activation on save only for plugin jsdoc in VsCode Jan 11, 2023
@brettz9
Copy link
Collaborator

brettz9 commented Jan 11, 2023

ESLint is a specific extension for VSCode. I believe you would need to contact VSC or possibly the ESLint extension creators to support disabling fixes in that way.

Some of our rules do, however, have options which let you disable fixers. Which fixing behavior do you wish to disable?

@antho227
Copy link
Author

antho227 commented Jan 11, 2023

I want to be able to write a function without JSDOC, like a generic function for a class...

And I have two others questions.

I got an error jsdoc/valid-types with this code (@typedef {CommandData & Command} ModifiedCommand) :

/**@typedef { import('../../Commands/0-Command.js').Command } Command */
/**
 * @typedef {object} CommandData
 * @property {string} iconName Description
 * @property {string} codeLabel Description
 * @property {string} enabled Description
 * @property {object} CommandPrototype Description
 */
/**
 * Description
 * @typedef {CommandData & Command} ModifiedCommand
 */

And I got jsdoc/no-undefined-types on HTMLCollectionOf :

  /**
   * Description
   * @param {Array<Command>} commands Description
   * @param {HTMLCollectionOf<HTMLDivElement>} lines Description
   */
  myFunction(commands, lines) {
    // my code
  }

It seem's that HTMLCollectionOf does not exist for the extension and the ability to extend an object too.

@brettz9
Copy link
Collaborator

brettz9 commented Jan 11, 2023

You can, in your ESLint config, set:

'jsdoc/require-jsdoc': ['error', {enableFixer: false}]

That will prevent injection of:

/**
 *
 */
  1. Regarding the jsdoc/valid-types error, you need to set the following in your ESLint config:
      settings: {
        jsdoc: {
          mode: 'typescript',
        },
      },

or you need to have:

parser: '@typescript-eslint/parser'

and install @typescript-eslint/parser.

Intersections (&) are not supported by regular JSDoc. Those are an innovation by the TypeScript flavor of JSDoc.

  1. Regarding HTMLCollectionOf and jsdoc/no-undefined-types, that is issue no-undefined-types: false positives for built-in interface types in typescript mode #888 . For now, feel free to disable the rule or put /* eslint-disable jsdoc/no-undefined-types */ and /* eslint-enable jsdoc/no-undefined-types */ around the problematic code blocks.

Closing as that should resolve, but feel free to comment further as needed.

@brettz9 brettz9 closed this as completed Jan 11, 2023
@antho227
Copy link
Author

Thank you !

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

No branches or pull requests

2 participants