-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Issue Description
The default options for the @typescript-eslint/consistent-type-assertions rule are:
defaultOptions: [
{
assertionStyle: 'as',
objectLiteralTypeAssertions: 'allow',
},
],If a user wishes to override just the objectLiteralTypeAssertions option to 'never', but retain the default assertionStyle option 'as', the expectation is that they could omit the assertionStyle option from their config, e.g.
"@typescript-eslint/consistent-type-assertions": [
"error",
{
objectLiteralTypeAssertions: 'never',
},
],Default rule options should be deeply merged with any user-supplied config, so the expected merged result would be:
{
assertionStyle: 'as',
objectLiteralTypeAssertions: 'never',
},However this results in the following error:
❯ eslint
Oops! Something went wrong! :(
ESLint: 9.16.0
Error: Key "rules": Key "@typescript-eslint/consistent-type-assertions":
Value {"objectLiteralTypeAssertions":"never"} should NOT have additional properties.
Unexpected property "objectLiteralTypeAssertions". Expected properties: "assertionStyle".
Value {"objectLiteralTypeAssertions":"never"} should have required property 'assertionStyle'.
Value {"objectLiteralTypeAssertions":"never"} should match exactly one schema in oneOf.
It would seem that the user-supplied config is completely replacing the default options instead of being merged?
Reproduction Repository Link
https://github.com/scottohara/ts-eslint-consistent-type-assertions
Repro Steps
- clone the repo
npm installeslint
Versions
| package | version |
|---|---|
typescript-eslint |
8.17.0 |
TypeScript |
5.7.2 |
ESLint |
9.16.0 |
node |
22.11.0 |
Metadata
Metadata
Assignees
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.