biome icon indicating copy to clipboard operation
biome copied to clipboard

๐Ÿ“Ž `--write` everywhere

Open Conaclos opened this issue 2 years ago โ€ข 7 comments

Description

See #2240 for more context.

  • [ ] Add --write and --unsafe option to lint/check CLI commands - --write indicates if (safe) code fixes should be applied - --unsafe indicates that safe and unsafe code fixes should be applied if --write is passed
  • [ ] Make biome <lint|check> --apply an alias of biome <lint|check> --write
  • [ ] Make biome <lint|check> --apply-unsafe an alias of biome <lint|check> --write --unsafe

Conaclos avatar Apr 01 '24 16:04 Conaclos

Since this isn't clear unless someone reads the original discussion, --apply and --apply-unsafe have to be deprecated.

ematipico avatar Apr 02 '24 06:04 ematipico

On second thought, I think we should use --fix instead of --write because it is a more common option name among linters. This will generate more deprecations, but I think it is time or never?

Conaclos avatar May 15 '24 11:05 Conaclos

But Biome isn't just a linter ๐Ÿ™„

ematipico avatar May 15 '24 11:05 ematipico

But Biome isn't just a linter ๐Ÿ™„

Yes. However, biome format --fix makes sense?

Conaclos avatar May 15 '24 11:05 Conaclos

I feel that almost everything (write, fix, apply) is natural, but I'm not sure how people perceive lint --write. I'm in favor of unifying --fix but considering --fix-unsafe, users might think the option only fixes unsafe code even though it does fix to the code with applying unsafe fix.

By the way, do we need to separate --fix (or others) and --unsafe? I feel it makes things a bit more complex.

unvalley avatar May 15 '24 12:05 unvalley

I don't understand what you mean, it seems to me that the following two paragraphs are contradictory.

I'm in favor of unifying --fix but considering --fix-unsafe, users might think the option only fixes unsafe code even though it does fix to the code with applying unsafe fix.

By the way, do we need to separate --fix (or others) and --unsafe? I feel it makes things a bit more complex.

I agree that --apply-unsafe is confusing: users could think that it only applies unsafe fixes, while it applies both safe and unsafe fixes. It is why I proposed --unsafe. Combined with --fix it applies safe and unsafe fixes. This is what Ruff is doing, although the option is named --unsafe--fixes.

Conaclos avatar May 15 '24 12:05 Conaclos

I looked back and sure enough, there was a contradiction๐Ÿ˜… Ah right, the second paragraph, 'complex' was for handling command line arguments. But I got what this task means.

unvalley avatar May 15 '24 13:05 unvalley

Alternatively, we could accept both --write and --fix because we have users migrating from Prettier (that uses --write) and ESLint (that uses --fix).

Conaclos avatar May 16 '24 10:05 Conaclos

Alternatively, we could accept both --write and --fix because we have users migrating from Prettier (that uses --write) and ESLint (that uses --fix).

So one would be the alias of the other? I like the idea!

ematipico avatar May 16 '24 14:05 ematipico

I also like it.

unvalley avatar May 16 '24 14:05 unvalley

So one would be the alias of the other?

Yes. I am not fond of aliases, however, in our case, this looks like a good UX.

Conaclos avatar May 16 '24 14:05 Conaclos

What should we do when biome <lint|check> --unsafe is given? (without --write and --fix)

It looks like a command to show lint errors subject to unsafe fixes. But here we should show an error incompatible arguments?

unvalley avatar May 17 '24 08:05 unvalley

It looks like a command to show lint errors subject to unsafe fixes. But here we should show an error incompatible arguments?

For now, I could just throw a diagnostic saying that the flag is only usable with --fix. We could re-evaluate this in the future if we find a use case.

Conaclos avatar May 17 '24 08:05 Conaclos