fix(linter): Fix incorrect allowNames config option name in typescript/no-this-alias rule.#16852
fix(linter): Fix incorrect allowNames config option name in typescript/no-this-alias rule.#16852graphite-app[bot] merged 1 commit intomainfrom
allowNames config option name in typescript/no-this-alias rule.#16852Conversation
Merge activity
|
There was a problem hiding this comment.
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_configurationcurrently implements its own parsing forallowedNames/allowNameswhile 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 alreadyDeserialize, 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_namestoallowed_names. - Adds
#[serde(alias = "allowNames")]so existing configs using the previous (typo’d) key continue to work. - Updates manual JSON config parsing to prefer
allowedNamesand fall back toallowNames. - 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.rscrates/oxc_linter/src/snapshots/typescript_no_this_alias.snap
CodSpeed Performance ReportMerging #16852 will not alter performanceComparing Summary
Footnotes
|
…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`. ```
64c7ea7 to
b16fe64
Compare
This change corrects the configuration option name from
allowNamestoallowedNamesin theno-this-aliasrule 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: