prettier#Plugin TypeScript Examples

The following examples show how to use prettier#Plugin. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.ts    From prettier-plugin-jsdoc with MIT License 7 votes vote down vote up
findPluginByParser = (parserName: string, options: ParserOptions) => {
  const tsPlugin = options.plugins.find((plugin) => {
    return (
      typeof plugin === "object" &&
      (plugin as any).name &&
      plugin.parsers &&
      // eslint-disable-next-line no-prototype-builtins
      plugin.parsers.hasOwnProperty(parserName)
    );
  }) as Plugin | undefined;

  return !tsPlugin ||
    (tsPlugin as any).name === "prettier-plugin-jsdoc" ||
    // eslint-disable-next-line no-prototype-builtins
    tsPlugin.parsers?.hasOwnProperty("jsdoc-parser")
    ? undefined
    : tsPlugin.parsers?.[parserName];
}