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

refactor: style recommendation and new recommended severity #4730

Merged
merged 4 commits into from
Dec 13, 2024

Conversation

ematipico
Copy link
Member

@ematipico ematipico commented Dec 12, 2024

Summary

Part of #4662

style rules aren't recommended anymore

It's possible that people won't agree with this choice, so let's discuss it. However, our recommended rules are a lot, and we should slim them down.

With the introduction of domains, there's also a faster and better (granular) way to add recommended rules.

Styling rules can be very opinionated, and we should avoid imposing a tool's opinion on users unless there's a design behind it. Our linter wasn't born to be opinionated by design, as opposed to our formatter. In the last months, I could see some displeasure among our users, asking why certain style rules were recommended, considering that until v1.*, the recommended ones were emitting an error.

Important

We can still revert the change, however I would like reduce the number of errors and noice. For example, noVar shouldn't be an error.

New "on" option

Until v1, when users wanted to enable non-recommended rules, they needed to choose a severity from info, warn, and error.

However, now that all rules have a default severity, users can decide to use the severity suggested by Biome. In the following example, when a user uses "on" for noArguments, violations of this rule will raise errors, because that's its default severity suggested by us. Instead, noNamespace will raise an info diagnostics:

{
	"linter": {
		"rules": {
			"style": {
				"noArguments": "on",
				"noNamespace": "on"
			}
		}
	}
}

Better biome explain <RULE>

I didn't like the explanation of our rules. I revamped it, here's a preview from my terminal:

Screenshot 2024-12-12 at 17 09 30 Screenshot 2024-12-12 at 17 08 39

Test Plan

Added new tests and update many of our current tests

@github-actions github-actions bot added A-CLI Area: CLI A-Project Area: project A-Linter Area: linter A-Tooling Area: internal tools L-JavaScript Language: JavaScript and super languages A-Diagnostic Area: diagnostocis labels Dec 12, 2024
@ematipico ematipico marked this pull request as ready for review December 12, 2024 17:11
@ematipico ematipico requested review from a team December 12, 2024 17:13
Copy link

codspeed-hq bot commented Dec 12, 2024

CodSpeed Performance Report

Merging #4730 will not alter performance

Comparing feat/on-rules (954547f) with next (0a9d85a)

Summary

✅ 97 untouched benchmarks

@Conaclos
Copy link
Member

I like this change! I suggest using Default severirity instead of Suggested severity in biome explain. This is less confusing IMO.

Copy link
Contributor

@arendjr arendjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn’t have time for a full review, but I’m on board too 👍

Just two suggestions:

  • I think biome migrate should keep them enabled for users coming from Biome 1.x. For new users we can indeed leave them disabled by default going forward.
  • For noVar specifically: var actually has confusing semantics, and can cause bugs in combination with loops, for instance. It feels this more than just a style choice, so maybe we need to recategorize the rule?

@ematipico
Copy link
Member Author

ematipico commented Dec 13, 2024

so maybe we need to recategorize the rule?

Definitely wise to do that. Maybe we can move it to the suspicious group

I think biome migrate should keep them enabled for users coming from Biome 1.x. For new users we can indeed leave them disabled by default going forward.

That's wise, I will follow up with another PR

@ematipico ematipico merged commit a478377 into next Dec 13, 2024
12 checks passed
@ematipico ematipico deleted the feat/on-rules branch December 13, 2024 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: CLI A-Diagnostic Area: diagnostocis A-Linter Area: linter A-Project Area: project A-Tooling Area: internal tools L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants