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

📎 Implement biome lint --rule=<rule-name> #58

Closed
Conaclos opened this issue Aug 23, 2023 · 5 comments · Fixed by #2860
Closed

📎 Implement biome lint --rule=<rule-name> #58

Conaclos opened this issue Aug 23, 2023 · 5 comments · Fixed by #2860
Assignees
Labels
A-CLI Area: CLI A-Linter Area: linter S-Help-wanted Status: you're familiar with the code base and want to help the project

Comments

@Conaclos
Copy link
Member

Conaclos commented Aug 23, 2023

Description

Executing biome lint --rule=<rule-name> should only run the rule with name <rule-name>, otherwise it will throw an error. See rome#4747 for more context.

EDIT: --rule=<rule-name> should override the config, i.e. run <rule-name> even if the rule is disabled in the config. However, the rule options and severity level should be taken into account.

If the option is combined with --summary (e.g. biome lint --summary --rule=<rule-name>) we should restrict the summary to <rule-name>. See #57 for more details about the --summary option.

An example:

$ biome lint --rule useSingleCaseStatement src

src/services/types.ts:1121:5 lint/nursery/useNamingConvention ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ⚠ This property name should be in camelCase.
  
  > 1121 │     InsertSpaceAfterConstructor?: boolean;
         │     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  
  ℹ The name could be renamed to `insertSpaceAfterConstructor`.


$ biome lint --summary --rule useSingleCaseStatement src

Rule name                          Diagnostics
nursery/useSingleCaseStatement        1

Possible extensions

  • Multi rule filtering (keeping diagnostics of a given set of rules)
  • reverse filtering, i.e. keeping all diagnostics except the diagnostics of a given rule
@Conaclos Conaclos added A-CLI Area: CLI A-Linter Area: linter labels Aug 23, 2023
@ematipico
Copy link
Member

I believe the description is misleading. Or maybe I didn't understand.

I would expect that Biome will run the codebase only against the rule passed by CLI, I wouldn't expect to run all rules and then filter the result.

Did I misunderstand the proposal?

@Conaclos
Copy link
Member Author

Conaclos commented Sep 3, 2023

Updated :)

@ematipico
Copy link
Member

Can this option be paired with --apply and --apply-unsafe?

@Conaclos
Copy link
Member Author

Conaclos commented Sep 3, 2023

Can this option be paired with --apply and --apply-unsafe?

I don't see any blocker :) Composability is great.

@Conaclos Conaclos added the S-Help-wanted Status: you're familiar with the code base and want to help the project label Sep 3, 2023
@Conaclos
Copy link
Member Author

This could also be good to expose this option in the playground. Someone testing the rule in the playground could then focus on the behavior of the rule without triggering other rules. This could allow also adding a Try this rule on every rule's page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: CLI A-Linter Area: linter S-Help-wanted Status: you're familiar with the code base and want to help the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants