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

Add Biome Linting Support #2275

Open
jdsee opened this issue Sep 25, 2024 · 6 comments
Open

Add Biome Linting Support #2275

jdsee opened this issue Sep 25, 2024 · 6 comments

Comments

@jdsee
Copy link

jdsee commented Sep 25, 2024

Hi 👋

if I am not mistaken, the Biome-Formatter in Spotless currently only supports formatting but doesn’t check or apply linting rules. It would be great if the integration could support Biome’s linting as well to enforce the same rules as the referenced biome.json.

I think at the moment Spotless only runs biome format. To check the Linting as well we'd need to run biome check instead.

Thanks for considering this (or telling me that there's a configuration option that i missed 😆 )!

Cheers, Joscha

@blutorange
Copy link
Contributor

blutorange commented Oct 4, 2024

I did that intentionally when I added biome integration, since spotless is a formatter. On a technical level, it shouldn't be a problem to run the linter and apply the autofixes.

On a conceptual level, I'm not sure. As I said, spotless is a formatter. I've seen some ideas to integrate linting with spotless, see e.g. #1097 #2149

Personally I wouldn't mind adding an option for applying autofixable linter fixes. That feels in the spirit of formatting. Erroring when a manual fix is needed does not sound right to me though. I wonder what @nedtwigg thinks about applying auto fixable linter fixes in spotless?

@jdsee
Copy link
Author

jdsee commented Oct 8, 2024

Thanks for the clarification. The diktat integration checks linting as well as formatting, so I was hoping other formatters/linters would too.

Our main use case for Spotless is enforcing formatting/linting in CI/CD with one tool. Manually checking Biome in a separate step defeats that purpose a bit.

It'd be really great if we could configure the biome integration to check the linting rules as well. I understand that Spotless doesn't support Linting as a standalone concept yet, but maybe reporting linting errors through the formatting channel (as done for detekt, i suspect). Making it opt-in shouldn't hurt anyone.

@blutorange
Copy link
Contributor

I haven't used Diktat yet, so I don't know what it does exactly. Just to be clear, what would you like to happen?

  1. Apply fixes for linter issues that can be autofixed
  2. Output warning log messages when there are linter violations
  3. Raise an error and fail the build when a file has linter violations

(1. sounds goods to me, 2. isn't really useful if you want to use automated tooling, 3. feels wrong to me but I'm open for other opinions)

@jdsee
Copy link
Author

jdsee commented Oct 11, 2024

For our release builds we want to enforce, that the formatter and linter has been run on changed code. If we want to stick with spotless only, we'd need option 3.

1 isn't really necessary for our purposes, but would surely be a convenient addition.
2 doesn't really make sense, since it's not automatable and too easy to miss.

For reference, the Diktat integration simply fails on linter validations, when running spotless:check.

To make it concrete, ideally we'd need the following:

  • a config option, to enable Linting for Biome
  • if enabled, sptless:check will fail on linting violations
  • if enabled, spotless:apply will fix autofixable linting violations

Thanks for considering!

@blutorange
Copy link
Contributor

blutorange commented Oct 11, 2024

I would probably split that into 2 options (failOnLintRuleViolations and applyLintRuleFixes=(safe|unsafe))

Doesn't sound too hard to implement, but since I'm not the maintainer of spotless (I just added the biome formatter), I'd like to wait for @nedtwigg opinion on this.

@jdsee
Copy link
Author

jdsee commented Oct 11, 2024

Sounds really good to me. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants