jinxdash / prettier-plugin-rust

Prettier Rust is an opinionated code formatter that autocorrects bad syntax.
MIT License
180 stars 8 forks source link

Error during output formatting: Couldn't resolve parser "rust-parse" #29

Open vladilen11 opened 1 year ago

vladilen11 commented 1 year ago

Input code

import * as prettier from "prettier";
import * as rustPlugin from "prettier-plugin-rust";

export async function formatMove(content: string, prettierConfigPath?: string): Promise<string> {
  let config;
  if (prettierConfigPath) {
    config = await prettier.resolveConfig(prettierConfigPath);
  }
  try {
    return prettier.format(content, {
      plugins: [rustPlugin],
      parser: "rust-parse",

      printWidth: 120,
      semi: true,
      tabWidth: 2,
      useTabs: false,
      bracketSpacing: true,

      ...config,
    });
  } catch (error) {
    let message;
    if (error instanceof Error) {
      message = error.message;
    } else {
      message = error;
    }
    console.log(chalk.yellow(`Error during output formatting: ${message}`));
    return content;
  }
}

Output code

Error during output formatting: Couldn't resolve parser "rust-parse"
Promise {

Additional context

No response