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

Reformat with Biome Plugin does not work #44

Open
hankaguila opened this issue Mar 28, 2024 · 0 comments
Open

Reformat with Biome Plugin does not work #44

hankaguila opened this issue Mar 28, 2024 · 0 comments

Comments

@hankaguila
Copy link

WebStorm v2023.3.5
Biome Plugin v1.0.0

The only way it partially works is enabling formatting on save. I say partially because on some files with errors, I would save to format and the entire file contents are deleted. This never happens when running the biome cli so it must be an issue with the plugin/jetbrains.

In the meantime, I'm running the following External Tool with a keymap (Ctrl+B) so as to not have to type the format command every time.

image

// runBiomeCheck.js
const { exec } = require("child_process");

// Getting the file path from the command line arguments
const filePath = process.argv[2];
if (!filePath) {
  console.error('Usage: node runBiomeFormat.js <file_path>');
  process.exit(1);
}

// Construct the command to execute
const command = `npx @biomejs/biome check --apply-unsafe "${filePath}"`;

// Execute the command
exec(command, (error, stdout, stderr) => {
  if (error) {
    console.error(`Error: ${error.message}`);
    return;
  }
  if (stderr) {
    console.error(`Stderr: ${stderr}`);
    return;
  }
  console.log(`Output: ${stdout}`);
});

I hope this helps. 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

1 participant