Skip to content

Switch eslint-plugin-unicorn to the unopinionated preset#13984

Merged
Turbo87 merged 7 commits into
rust-lang:mainfrom
Turbo87:unicorn-unopinionated
Jun 18, 2026
Merged

Switch eslint-plugin-unicorn to the unopinionated preset#13984
Turbo87 merged 7 commits into
rust-lang:mainfrom
Turbo87:unicorn-unopinionated

Conversation

@Turbo87

@Turbo87 Turbo87 commented Jun 18, 2026

Copy link
Copy Markdown
Member

We were enabling unicorn's recommended preset and then switching off a growing list of opinionated style rules. unopinionated is the same baseline without those rules, so it matches what we actually want to enforce and lets us drop most of the overrides. The remaining commits enable a handful of the non-style rules that were previously off and adjust the affected call sites.

All rules and the unopinionated config already exist in the currently pinned eslint-plugin-unicorn (65.0.1), so this stands on its own. It also pairs with the v66 update in #13977, which is what surfaced several of these rules.

Related

Turbo87 added 7 commits June 18, 2026 14:05
`recommended` enables unicorn's opinionated style rules, which we kept
switching off one by one, and the v66 upgrade added more of them.
`unopinionated` is the baseline without those rules, so it matches what
we actually want to enforce: unicorn's bug-catching rules, not its style
preferences.

Adopting it makes nine of our `off` overrides redundant, along with a few
inline `eslint-disable` directives, so they get removed. The overrides
that remain stay because `unopinionated` still enables those rules.
The override turned the rule off, but the codebase has no `.apply()`
calls for it to flag, so it was inert. Dropping it lets the
`unopinionated` preset enforce the rule and guards against future
`fn.apply(...)` usage.
The override turned the rule off for one violation in the trusted
publishing docs script, which escaped backslashes inside a template
literal. That script now uses `String.raw`, so the override is no longer
needed and the rule enforces the cleaner form going forward.
The call sites that used `.replace(/.../g, ...)` now use `.replaceAll()`,
with simple literal patterns passed as plain strings. With no remaining
violations, the override is removed so the rule is enforced going forward.
`Array#toReversed()` is supported well enough now, so the override is
removed and the rule enforced. The two call sites reversed throwaway
arrays from `.map()`, so they switch to the non-mutating `.toReversed()`
without any behavior change.
`Array#toSorted()` is supported well enough now, so the override is
removed and the rule enforced. Every flagged `.sort()` ran on a freshly
built array or reassigned its result, so switching to the non-mutating
`.toSorted()` keeps the same behavior. The token list no longer needs its
defensive `[...tokens]` copy, since `.toSorted()` already returns a new
array.
The flagged accesses are global properties (`onerror`,
`onunhandledrejection`, `crypto`, `location`) that the client-only files
reach through `window`. They switch to `globalThis`, which resolves to the
same object in the browser.
@Turbo87 Turbo87 force-pushed the unicorn-unopinionated branch from 59516e0 to b5929ac Compare June 18, 2026 12:05
@rustbot

rustbot commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@Turbo87 Turbo87 merged commit 2a62ef4 into rust-lang:main Jun 18, 2026
13 checks passed
@Turbo87 Turbo87 deleted the unicorn-unopinionated branch June 18, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants