Skip to content

Commit 0880666

Browse files
authored
docs: update loadESLint() documentation for v10 (#21374)
* docs: update loadESLint() documentation for v10 * docs: fix formatting * chore: rerun Netlify
1 parent 449724e commit 0880666

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

‎docs/src/integrate/nodejs-api.md‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -559,41 +559,34 @@ The `LoadedFormatter` value is the object to convert the [LintResult] objects to
559559
560560
## loadESLint()
561561
562-
The `loadESLint()` function is used for integrations that wish to support different ESLint versions. This function returns the correct `ESLint` class implementation based on the arguments provided:
562+
The `loadESLint()` function is used for integrations that wish to support different ESLint versions. In ESLint v10.0.0 and later, it always returns the `ESLint` class, which uses the flat config system:
563563
564564
```js
565565
const { loadESLint } = require("eslint");
566566

567-
// loads the default ESLint that the CLI would use based on process.cwd()
568567
const DefaultESLint = await loadESLint();
569-
570-
// loads the flat config version specifically
571-
const FlatESLint = await loadESLint({ useFlatConfig: true });
572-
573-
// loads the legacy version specifically if possible, otherwise falls back to flat config version
574-
const LegacyESLint = await loadESLint({ useFlatConfig: false });
575568
```
576569
570+
In ESLint v9 and earlier, `loadESLint()` accepted a `useFlatConfig` option to choose between the flat config and eslintrc implementations. Because eslintrc support was removed in ESLint v10.0.0, this option is now ignored.
571+
577572
You can then use the returned constructor to instantiate a new `ESLint` instance, like this:
578573
579574
```js
580-
// loads the default ESLint that the CLI would use based on process.cwd()
581575
const DefaultESLint = await loadESLint();
582576
const eslint = new DefaultESLint();
583577
```
584578
585-
If you're ever unsure which config system the returned constructor uses, check the `configType` property, which is either `"flat"` or `"eslintrc"`:
579+
If your integration also supports earlier ESLint versions, check the `configType` property to determine which config system the returned constructor uses. In ESLint v10.0.0 and later, it is always `"flat"`, while earlier versions may return `"eslintrc"`:
586580
587581
```js
588-
// loads the default ESLint that the CLI would use based on process.cwd()
589582
const DefaultESLint = await loadESLint();
590583

591584
if (DefaultESLint.configType === "flat") {
592585
// do something specific to flat config
593586
}
594587
```
595588
596-
**If you don't need to support both the old and new configuration systems, then it's recommended to just use the `ESLint` constructor directly.**
589+
**If your integration only needs to support ESLint v10.0.0 and later, then it's recommended to just use the `ESLint` constructor directly.**
597590
598591
## SourceCode
599592

0 commit comments

Comments
 (0)