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

feature request: Organize import using Biome.js for typescript, javascript, typescriptreact, javascriptreact #585

Open
1 task done
rahulpeacock opened this issue Nov 25, 2024 · 6 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@rahulpeacock
Copy link

rahulpeacock commented Nov 25, 2024

Did you check existing requests?

  • I have searched the existing issues

Describe the feature

I want to organize the imports using biome.js when I format my buffer/file using biome.js for typescript, javascript, typescriptreact, javascriptreact

Provide background

No response

What is the significance of this feature?

strongly desired

Additional details

For now I am using the args to organize the imports. But it is highly recommend to have a config to organize the imports using biome

This is a workaround for now

-- confirm.lua
return {
  {
    "stevearc/conform.nvim",
    opts = {
      formatters_by_ft = {
        lua = { "stylua" },
        ["javascript"] = { "biome" },
        ["javascriptreact"] = { "biome" },
        ["typescript"] = { "biome" },
        ["typescriptreact"] = { "biome" },
        ["json"] = { "biome" },
        ["css"] = { "biome" },
      },
      formatters = {
        biome = {
          command = "biome",
          args = { "check", "--formatter-enabled=true", "--linter-enabled=false", "--organize-imports-enabled=true", "--write", "--stdin-file-path", "$FILENAME" },
        },
      },
    },
  },
}
@rahulpeacock rahulpeacock added the enhancement New feature or request label Nov 25, 2024
@stevearc
Copy link
Owner

According to the docs it looks like the formatter, linter, and import sorter are all enabled by default. The default conform biome formatter calls biome format. If you want to use biome check, use the biome-check formatter.

Also, to make changes to a formatter args, you can provide append_args or prepend_args instead of overriding the args entirely.

@stevearc stevearc added the question Further information is requested label Nov 25, 2024
@rahulpeacock
Copy link
Author

@stevearc Yes I can pass args but I can't pass the arg --import-sort-enable to the biome format command because it doesn't support that arg

@github-actions github-actions bot removed the question Further information is requested label Nov 25, 2024
@rahulpeacock
Copy link
Author

@stevearc can you share any config with biome-check.

@andrew-t-james-core
Copy link

@rahulpeacock I had some luck with this setup.

@rahulpeacock
Copy link
Author

@andrew-t-james-core this is also a workaround but is there a default config from conform ??

@stevearc
Copy link
Owner

Can you not just use the built-in biome-check formatter? It runs biome check which, from my understanding, will organize the imports

      formatters_by_ft = {
        lua = { "stylua" },
        ["javascript"] = { "biome-check" },
        ["javascriptreact"] = { "biome-check" },
        ["typescript"] = { "biome-check" },
        ["typescriptreact"] = { "biome-check" },
        ["json"] = { "biome-check" },
        ["css"] = { "biome-check" },
      },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants