Docs: Clarify how the config()
helper handles rule merging in flat config
#11220
Closed
2 tasks done
Labels
documentation
Documentation ("docs") that needs adding/updating
triage
Waiting for team members to take a look
Before You File a Documentation Request Please Confirm You Have Done The Following...
Suggested Changes
Here's my real-life config:
After setting it up, it turned out there's just one rule I'd like to override, so I turned my config into:
I expected this to simply merge with the existing rules, but it turned out it overwrote all the previously set rules, including
react-hooks/rules-of-hooks
andreact-refresh/only-export-components
.My first instinct was to manually re-add all the previously defined rules:
It worked, but the manual process didn't feel right or elegant, so I started fiddling around and figured out that I have to append the
rules
into the next array item, instead of adding it to the entry that containslanguageOptions
.I ended up with:
It was just a trial-and-error process that led me to that solution, but after figuring it out I still don't really understand why it worked. Why does having
rules
together withlanguageOptions
prevent merging, whereas a separate entry containing just therules
object is correctly merged?What I'm proposing is adding a very explicit explanation on how to add custom rule overrides in a safe way - so that preceding rules aren't overridden OR, and maybe it's a better option, clarify how the
tsEslint.config()
performs merging: what's being merged and what is not.Affected URL(s)
https://typescript-eslint.io/packages/typescript-eslint#config
Additional Info
No response
The text was updated successfully, but these errors were encountered: