prettier-plugin-jsdoc
Prettier plugin for format jsdoc and convert to standard Match with Visual studio and other IDE which support jsdoc.
Last updated 4 years ago by hosseinmdeveloper .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ npm install prettier-plugin-jsdoc 
SYNC missed versions from official npm registry.

NPM

install size dependencies

prettier-plugin-jsdoc

Prettier plugin for format jsdoc and convert to standard Match with Visual studio and other IDE which support jsdoc.

Many good examples of how this plugin work, are in tests directory. Compare tests and their snapshot

configured with best practices of jsDoc style guides

initial source code (https://gitlab.com/gumen/prettier-plugin-jsdoc)

TOC

Installation

  1. Install and configure Prettier as usual
  2. Install prettier-plugin-jsdoc
npm i prettier-plugin-jsdoc --save
yarn add prettier-plugin-jsdoc
  1. add a parser override to your prettier file for js files
{
  //any other config you have
  "plugins": ["jsdoc-parser"], // format all javascript and typescript files
};

or add plugins override to your prettier file for js files

module.exports = {
  // any other config you have
  overrides: [
    {
      files: '*.js',
      options: {
        plugins: ['jsdoc-parser'],
      },
    },
  ],
};

avoid setting the parser value on the root of your config file, it will disable prettier's default behavior and will not parse non-js files

Examples

Single line

/**
 * @param {  string   }    param0 description
 */
function fun(param0) {}

Format to

/** @param {string} param0 Description */
function fun(param0) {}

React Component

/**
 * @type {React.FC<{   message:string}   >}
 */
const Component = memo(({ message }) => {
  return <p>{message}</p>;
});

Format to

/** @type {React.FC<{message: string}>} */
const Component = memo(({ message }) => {
  return <p>{message}</p>;
});

Typescript Objects

/**
 @typedef {
    {
        "userId": {
        "profileImageLink": *,
        "isBusinessUser": "isResellerUser"|"isBoolean"|  "isSubUser" |    "isNot",
        "shareCode": number,
        "referredBy": any,
        },
        id:number
      }
     } User
     */

Format to

/**
 * @typedef {{
 *   userId: {
 *     profileImageLink: any;
 *     isBusinessUser: "isResellerUser" | "isBoolean" | "isSubUser" | "isNot";
 *     shareCode: number;
 *     referredBy: any;
 *   };
 *   id: number;
 * }} User
 */

Example

Add code to example tag

/**
 * @examples
 *   var one= 5
 *   var two=10
 *
 *   if(one > 2) { two += one }
 */

to

/**
 * @example
 *   var one = 5;
 *   var two = 10;
 *
 *   if (one > 2) {
 *     two += one;
 *   }
 */

Description

/**
 * This format of the description is being supported now:
 *
 *    1. Thing 1
 *    2. Thing 2
 *    3. Thing 3
 */

Options

Key type Default
jsdocSpaces Number 1
jsdocDescriptionWithDot Boolean false
jsdocDescriptionTag Boolean false
jsdocVerticalAlignment Boolean false
jsdocKeepUnParseAbleExampleIndent Boolean true

Full up to date list and description of options can be found in Prettier help. First install plugin then run Prettier with "--help" option.

$ prettier --help # global installation

$ ./node_modules/.bin/prettier --help # local installation

Links

Prettier

JSDoc

Current Tags

  • 1.3.0                                ...           latest (a year ago)
  • 0.2.0-rc4                                ...           next (4 years ago)

99 Versions

  • 1.3.0                                ...           a year ago
  • 1.1.1                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
  • 0.4.2                                ...           2 years ago
  • 0.4.1                                ...           2 years ago
  • 0.3.38                                ...           3 years ago
  • 0.3.36                                ...           3 years ago
  • 0.3.35                                ...           3 years ago
  • 0.3.34                                ...           3 years ago
  • 0.3.33                                ...           3 years ago
  • 0.3.32                                ...           3 years ago
  • 0.3.31                                ...           3 years ago
  • 0.3.30                                ...           3 years ago
  • 0.3.29                                ...           3 years ago
  • 0.3.28                                ...           3 years ago
  • 0.3.27                                ...           3 years ago
  • 0.3.26                                ...           3 years ago
  • 0.3.25                                ...           3 years ago
  • 0.3.24                                ...           3 years ago
  • 0.3.23                                ...           3 years ago
  • 0.3.22                                ...           4 years ago
  • 0.3.21                                ...           4 years ago
  • 0.3.20                                ...           4 years ago
  • 0.3.19                                ...           4 years ago
  • 0.3.18                                ...           4 years ago
  • 0.3.17                                ...           4 years ago
  • 0.3.16                                ...           4 years ago
  • 0.3.15                                ...           4 years ago
  • 0.3.14-rc1                                ...           4 years ago
  • 0.3.14                                ...           4 years ago
  • 0.3.13                                ...           4 years ago
  • 0.3.12                                ...           4 years ago
  • 0.3.11                                ...           4 years ago
  • 0.3.10                                ...           4 years ago
  • 0.3.9                                ...           4 years ago
  • 0.3.8                                ...           4 years ago
  • 0.3.7                                ...           4 years ago
  • 0.3.6                                ...           4 years ago
  • 0.3.5                                ...           4 years ago
  • 0.3.4                                ...           4 years ago
  • 0.3.3                                ...           4 years ago
  • 0.3.2                                ...           4 years ago
  • 0.3.1                                ...           4 years ago
  • 0.3.0                                ...           4 years ago
  • 0.2.13                                ...           4 years ago
  • 0.2.12                                ...           4 years ago
  • 0.2.11                                ...           4 years ago
  • 0.2.9                                ...           4 years ago
  • 0.2.10                                ...           4 years ago
  • 0.2.8                                ...           4 years ago
  • 0.2.7                                ...           4 years ago
  • 0.2.6                                ...           4 years ago
  • 0.2.5                                ...           4 years ago
  • 0.2.4                                ...           4 years ago
  • 0.2.3                                ...           4 years ago
  • 0.2.2                                ...           4 years ago
  • 0.2.1                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
  • 0.2.0-rc4                                ...           4 years ago
  • 0.2.0-rc3                                ...           4 years ago
  • 0.2.0-rc2                                ...           4 years ago
  • 0.2.0-rc1                                ...           4 years ago
  • 0.1.3                                ...           4 years ago
  • 0.1.2                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
  • 0.0.26                                ...           4 years ago
  • 0.0.25                                ...           4 years ago
  • 0.0.24                                ...           4 years ago
  • 0.0.24-rc                                ...           4 years ago
  • 0.0.23                                ...           4 years ago
  • 0.0.22                                ...           4 years ago
  • 0.0.21                                ...           4 years ago
  • 0.0.20                                ...           4 years ago
  • 0.0.19                                ...           4 years ago
  • 0.0.18                                ...           4 years ago
  • 0.0.17                                ...           5 years ago
  • 0.0.16                                ...           5 years ago
  • 0.0.15                                ...           5 years ago
  • 0.0.14                                ...           5 years ago
  • 0.0.13                                ...           5 years ago
  • 0.0.12                                ...           5 years ago
  • 0.0.11                                ...           5 years ago
  • 0.0.10                                ...           5 years ago
  • 0.0.9                                ...           5 years ago
  • 0.0.8                                ...           5 years ago
  • 0.0.7                                ...           5 years ago
  • 0.0.6                                ...           5 years ago
  • 0.0.5                                ...           5 years ago
  • 0.0.4                                ...           5 years ago
  • 0.0.3                                ...           5 years ago
  • 0.0.2                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (10)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE