Skip to content

Conversation

@JoshuaKGoldberg
Copy link
Contributor

@JoshuaKGoldberg JoshuaKGoldberg commented Aug 7, 2025

Fixes #896.

Adds all rules from recommended to a new unopinionated config, with the exception of rules that add in subjective opinions >1% of users might not want (per my vague guesstimation). This list was generated by looking through #896 & linked issues, then running on my personal repos:

Rule Reason Mentioned
catch-error-name Subjective naming preference #896
consistent-function-scoping Subjective preference; doesn't impact control flow
empty-brace-spaces Formatters also handle this #2634
explicit-length-check Subjective preference; increases character count
filename-case Subjective naming preference #896
no-array-callback-reference Subjective preference; not always cleaner code
no-array-reduce Subjective code structure preference #896
no-await-expression-member Subjective preference; not always cleaner code
no-for-loop Subjective preference; not always optimal
no-nested-ternary Very opinionated; some projects need this #896
no-null Subjective preference some libraries don't work with #896
prefer-export-from Subjective preference; not always less code
prefer-query-selector Subjective preference not relevant to all projects #896
prefer-spread Subjective preference; doesn't impact control flow
prevent-abbreviations Subjective naming preference #896
switch-case-braces Subjective preference; not always cleaner code
template-indent Conflicts with Vitest-style .toMatchInlineSnapshot()

This unopinionated config does include the following rules that were mentioned as being candidates for removal:

Rule Reason Mentioned
no-useless-undefined Legitimate improvement; consistent-return doesn't enforce correctness #2715

I recognize I'm not an expert on this plugin and look forward to learning why some rules should(n't) be on those lists. ☺️

@fisker
Copy link
Collaborator

fisker commented Aug 7, 2025

I don't think "Type safety makes this much less useful" is a good reason to make rule 'opinionated'.

If I understand it correctly. It should only include rules for correctness, there should be only a few rules.

@JoshuaKGoldberg JoshuaKGoldberg force-pushed the config-unopinionated branch 2 times, most recently from 45b069b to b31c759 Compare August 7, 2025 15:47
@fisker
Copy link
Collaborator

fisker commented Aug 7, 2025

Rules like consistent-assert, consistent-empty-array-spread are 'opinionated'.

Strictly speaking, part of no-useless-undefined are 'unopinionated', these examples are very "stupid" as JS code https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-undefined.md#fail

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review August 7, 2025 17:43
@JoshuaKGoldberg
Copy link
Contributor Author

Ok I think I adjusted for that?

@sindresorhus sindresorhus requested a review from fisker August 11, 2025 09:43
@fisker
Copy link
Collaborator

fisker commented Sep 1, 2025

I didn't go through all rules, but I still think there are too many rules in this preset.

Copy link
Collaborator

@fisker fisker left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@fisker
Copy link
Collaborator

fisker commented Sep 1, 2025

Can you fix the conflicts?

@JoshuaKGoldberg
Copy link
Contributor Author

👍 Done. I added the two newly introduced rules, prefer-bigint-literals and no-array-sort, to the unopinionated preset too.

@JoshuaKGoldberg
Copy link
Contributor Author

Update: also the new require-module-attributes rule.

@sindresorhus
Copy link
Owner

One more rule to add: 5f27ec2

And a merge conflict fix. and then this is ready for merge.

@sindresorhus sindresorhus merged commit c13d09b into sindresorhus:main Sep 5, 2025
18 checks passed
@sindresorhus
Copy link
Owner

Thanks for doing this 🙏

@JoshuaKGoldberg JoshuaKGoldberg deleted the config-unopinionated branch September 5, 2025 11:54
@JoshuaKGoldberg
Copy link
Contributor Author

Thanks for all the feedback & reviews, this is really exciting!

@sindresorhus
Copy link
Owner

@Hypfer
Copy link

Hypfer commented Oct 15, 2025

It appears that I might've run into the downstream effects of this PR.
Specifically, Sonarcloud seems to have adapted all of these, given that they were labelled "unopinionated".

They don't seem to all actually be though. For example, no-negated-condition and its "Negated conditions are more difficult to understand.", while reasonable in a vacuum, might not actually hold true in the real world.

Think for example this

const result = doThing()

if (result !== undefined) {
    ... happy path...
} else {
    ... some other handling/cleanup...
}

The way this is written is a direct representation of my mental model of the control flow being put into code.
The first thing I want to see is the happy path. Everything else is not all that relevant.

Sonarcloud however now is telling me that this would be a code smell, because it's "hard to understand", even though the way it is written makes things easier to understand (for me at least).

Thus, you may perhaps want to revisit the "unopinionated" rule classifications.
It's of course not your responsibility what Sonar does, but still IMO the labels are incorrect.

That all said, I don't have a horse in this race since I just got rid of Sonar and don't use this eslint plugin, so feel free to discard this input.

@fisker
Copy link
Collaborator

fisker commented Oct 15, 2025

Please open an issue for the rules you think are opinionated. We can discuss.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unopinionated preset

4 participants