Skip to content

Commit 51b51f4

Browse files
docs: add a section on when to use extends vs cascading (#20268)
* docs: add section when to use extends vs cascading * apply suggestions * fix lint error * remove space
1 parent 61778f6 commit 51b51f4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/src/use/configure/configuration-files.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,27 @@ In this example, `exampleConfig` can be either an object or an array, and either
706706

707707
For more information on how to combine shareable configs with your preferences, please see [Combine Configs](combine-configs).
708708

709+
### When to Use Extends vs Cascading
710+
711+
When to use `Extends`:
712+
713+
- **For reusing configurations** - When you want to inherit and build upon existing configurations from plugins, shareable packages, or predefined configs.
714+
- **For plugin configuration** - When applying recommended or specific configurations from ESLint plugins (e.g., `example/recommended`).
715+
- **For shareable configurations** - When using npm packages that export configuration objects (e.g., `eslint-config-example`).
716+
- **For predefined configurations** - When using ESLint's built-in configurations like `js/recommended` or `js/all`.
717+
- **For modular configuration** - When you want to compose multiple configuration sources into a single configuration object.
718+
- **For maintaining consistency** - When you want to ensure consistent base rules across multiple configuration objects.
719+
- **For plugin integration** - When you need to apply configurations that come bundled with plugins.
720+
721+
When to use `Cascading`:
722+
723+
- **For file-specific rule** - When you need different rules for different file patterns or directories.
724+
- **For progressive configuration** - When you want to apply base rules to all files and then add/override rules for specific subsets.
725+
- **For environment-specific settings** - When test files, source files, and config files need different rule sets.
726+
- **For directory-based configuration** - When different project directories require different linting approaches.
727+
- **For rule severity adjustment** - When you want to change rule severity (`error`/`warn`/`off`) for specific file patterns.
728+
- **For language option variations** - When different files need different ECMAScript versions or parser options.
729+
709730
### Configuration Naming Conventions
710731

711732
The `name` property is optional, but it is recommended to provide a name for each configuration object, especially when you are creating shared configurations. The name is used in error messages and the config inspector to help identify which configuration object is being used.

0 commit comments

Comments
 (0)