hosseinmd / prettier-plugin-jsdoc

A Prettier plugin to format JSDoc comments.
MIT License
232 stars 28 forks source link

after `jsdocParser` removal, how can we ignore some files? #214

Closed tommytroylin closed 11 months ago

tommytroylin commented 1 year ago

in out project we disable jsdoc plugin like this

module.exports = {
  plugins: [
    require.resolve('prettier-plugin-jsdoc'),
  ],
  overrides: [
      {
        files: '*.md',
        options: {
          jsdocParser: false
        },
      },
    ],
}

since jsdoc plugin may mass our FrontMatter comments

/**
 * transform: true
 * compact: true
 */
//  will be format to
/**
 * transform: true compact: true
 */

so is there an another way to tell jsdoc plugin do not format these jsdoc comments or this file?

hosseinmd commented 1 year ago

Hi, your config should be like this


module.exports = {
  plugins: [
    require.resolve('prettier-plugin-jsdoc'),
  ],
  overrides: [
      {
        files: '*.md',
        plugins: [],
        options: {
          jsdocParser: false
        },
      },
    ],
}
tommytroylin commented 1 year ago

@hosseinmd

plugins field in overrides seems to not be working at all

my config is

module.exports = {
  pluginSearchDirs: false,
  plugins: [
    require.resolve('prettier-plugin-organize-imports'),
    require.resolve('prettier-plugin-packagejson'),
    require.resolve('prettier-plugin-jsdoc'),
  ],
  printWidth: 80,
  proseWrap: 'never',
  singleQuote: true,
  trailingComma: 'all',
  overrides: [
    {
      files: '*.md',
      plugins: [require.resolve('prettier-plugin-organize-imports')],
      options: {
        proseWrap: 'preserve',
        jsdocParser: false,
      },
    },
  ],
  organizeImportsSkipDestructiveCodeActions: true,
};

and VSCode output something like

["INFO" - 10:44:15] File Info:
{
  "ignored": false,
  "inferredParser": "markdown"
}
["INFO" - 10:44:15] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used
["INFO" - 10:44:15] Prettier Options:
{
  "filepath": "./form/index.md",
  "parser": "markdown",
  "useTabs": false,
  "tabWidth": 2,
  "endOfLine": "lf",
  "pluginSearchDirs": false,
  "plugins": [
    "./node_modules/prettier-plugin-organize-imports/index.js",
    "./node_modules/prettier-plugin-packagejson/lib/index.js",
    ./node_modules/prettier-plugin-jsdoc/dist/index.js"
  ],
  "printWidth": 80,
  "proseWrap": "preserve",
  "singleQuote": true,
  "trailingComma": "all",
  "organizeImportsSkipDestructiveCodeActions": true,
  "jsdocParser": false
}
hosseinmd commented 1 year ago

Sorry, Add plugins to options

module.exports = {
  plugins: [
    require.resolve('prettier-plugin-jsdoc'),
  ],
  overrides: [
      {
        files: '*.md',
        options: {
          plugins: [],
          jsdocParser: false
        },
      },
    ],
}
tommytroylin commented 11 months ago

many thanks