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

📎 --write everywhere #2267

Closed
3 of 4 tasks
Conaclos opened this issue Apr 1, 2024 · 13 comments · Fixed by #2898
Closed
3 of 4 tasks

📎 --write everywhere #2267

Conaclos opened this issue Apr 1, 2024 · 13 comments · Fixed by #2898
Assignees
Labels
A-CLI Area: CLI S-Feature Status: new feature to implement

Comments

@Conaclos
Copy link
Member

Conaclos commented Apr 1, 2024

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
  • Deprecate --apply and --apply-unsafe
@Conaclos Conaclos added the A-CLI Area: CLI label Apr 1, 2024
@ematipico ematipico added the S-Feature Status: new feature to implement label Apr 2, 2024
@ematipico
Copy link
Member

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

@unvalley unvalley self-assigned this May 13, 2024
@Conaclos
Copy link
Member Author

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?

@ematipico
Copy link
Member

But Biome isn't just a linter 🙄

@Conaclos
Copy link
Member Author

Conaclos commented May 15, 2024

But Biome isn't just a linter 🙄

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

@unvalley
Copy link
Member

unvalley commented May 15, 2024

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.

@Conaclos
Copy link
Member Author

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.

@unvalley
Copy link
Member

unvalley commented May 15, 2024

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.

@Conaclos
Copy link
Member Author

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

@ematipico
Copy link
Member

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!

@unvalley
Copy link
Member

unvalley commented May 16, 2024

I also like it.

@Conaclos
Copy link
Member Author

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.

@unvalley
Copy link
Member

unvalley commented May 17, 2024

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?

@Conaclos
Copy link
Member Author

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.

unvalley added a commit to unvalley/biome that referenced this issue May 17, 2024
unvalley added a commit to unvalley/biome that referenced this issue May 17, 2024
unvalley added a commit to unvalley/biome that referenced this issue May 19, 2024
unvalley added a commit to unvalley/biome that referenced this issue May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: CLI S-Feature Status: new feature to implement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants