Skip to content

fix(linter): Fix incorrect allowNames config option name in typescript/no-this-alias rule.#16852

Merged
graphite-app[bot] merged 1 commit intomainfrom
fix-field-name
Dec 14, 2025
Merged

fix(linter): Fix incorrect allowNames config option name in typescript/no-this-alias rule.#16852
graphite-app[bot] merged 1 commit intomainfrom
fix-field-name

Conversation

@connorshea
Copy link
Copy Markdown
Member

@connorshea connorshea commented Dec 14, 2025

This change corrects the configuration option name from allowNames to allowedNames in the no-this-alias rule of the linter. The previous name was seemingly a mistake, the original typescript-eslint rule uses allowedNames.

I've retained allowNames as an alias for backwards compatibility with existing configurations that set up their config based on the config docs we previously had.

See https://typescript-eslint.io/rules/no-this-alias/

Generated docs after this PR:

## Configuration

This rule accepts a configuration object with the following properties:

### allowDestructuring

type: `boolean`

default: `true`

Whether to allow destructuring of `this` to local variables.


### allowedNames

type: `string[]`

default: `[]`

An array of variable names that are allowed to alias `this`.

Copilot AI review requested due to automatic review settings December 14, 2025 18:49
@connorshea connorshea requested a review from camc314 as a code owner December 14, 2025 18:49
@github-actions github-actions bot added A-linter Area - Linter C-bug Category - Bug labels Dec 14, 2025
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Dec 14, 2025
@camc314 camc314 self-assigned this Dec 14, 2025
Copy link
Copy Markdown
Contributor

camc314 commented Dec 14, 2025

Merge activity

Copy link
Copy Markdown

@charliecreates charliecreates bot left a comment

Choose a reason for hiding this comment

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

Config parsing is currently duplicated between serde (#[serde(alias = "allowNames")]) and manual JSON extraction in from_configuration, which increases drift risk over time. Consolidating on a single parsing mechanism (preferably serde) would reduce maintenance burden and clarify precedence between allowedNames and allowNames. The functional change itself looks consistent with the stated backward compatibility goal.

Additional notes (1)
  • Maintainability | crates/oxc_linter/src/rules/typescript/no_this_alias.rs:81-88
    from_configuration currently implements its own parsing for allowedNames/allowNames while the struct also has #[serde(alias = "allowNames")]. Maintaining both paths increases the chance they drift (e.g., future defaulting/validation changes may be applied in one place but not the other). Since the struct is already Deserialize, consider consolidating parsing through serde (or at least centralizing the key selection) so there’s only one source of truth for how config is interpreted.
Summary of changes

Summary

This PR updates the typescript/no-this-alias rule configuration to match the upstream typescript-eslint option name:

  • Renames the config field from allow_names to allowed_names.
  • Adds #[serde(alias = "allowNames")] so existing configs using the previous (typo’d) key continue to work.
  • Updates manual JSON config parsing to prefer allowedNames and fall back to allowNames.
  • Extends tests and snapshots to cover both keys and verifies that non-allowed names still fail.

Relevant file changes:

  • crates/oxc_linter/src/rules/typescript/no_this_alias.rs
  • crates/oxc_linter/src/snapshots/typescript_no_this_alias.snap

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Dec 14, 2025

CodSpeed Performance Report

Merging #16852 will not alter performance

Comparing fix-field-name (64c7ea7) with main (9c1be35)

Summary

✅ 4 untouched
⏩ 41 skipped1

Footnotes

  1. 41 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

…ript/no-this-alias` rule. (#16852)

This change corrects the configuration option name from `allowNames` to `allowedNames` in the `no-this-alias` rule of the linter. The previous name was seemingly a mistake, the original typescript-eslint rule uses allowedNames.

I've retained allowNames as an alias for backwards compatibility with existing configurations that set up their config based on the config docs we previously had.

See https://typescript-eslint.io/rules/no-this-alias/

Generated docs after this PR:

```md
## Configuration

This rule accepts a configuration object with the following properties:

### allowDestructuring

type: `boolean`

default: `true`

Whether to allow destructuring of `this` to local variables.

### allowedNames

type: `string[]`

default: `[]`

An array of variable names that are allowed to alias `this`.
```
@graphite-app graphite-app bot merged commit b16fe64 into main Dec 14, 2025
20 checks passed
@graphite-app graphite-app bot deleted the fix-field-name branch December 14, 2025 18:59
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 14, 2025
@connorshea connorshea review requested due to automatic review settings March 23, 2026 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants