You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0880666
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/src/integrate/nodejs-api.md
+5-12Lines changed: 5 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -559,41 +559,34 @@ The `LoadedFormatter` value is the object to convert the [LintResult] objects to
559
559
560
560
## loadESLint()
561
561
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:
563
563
564
564
```js
565
565
const { loadESLint } =require("eslint");
566
566
567
-
// loads the default ESLint that the CLI would use based on process.cwd()
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
+
577
572
You can then use the returned constructor to instantiate a new `ESLint` instance, like this:
578
573
579
574
```js
580
-
// loads the default ESLint that the CLI would use based on process.cwd()
581
575
constDefaultESLint=awaitloadESLint();
582
576
consteslint=newDefaultESLint();
583
577
```
584
578
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"`:
586
580
587
581
```js
588
-
// loads the default ESLint that the CLI would use based on process.cwd()
589
582
constDefaultESLint=awaitloadESLint();
590
583
591
584
if (DefaultESLint.configType==="flat") {
592
585
// do something specific to flat config
593
586
}
594
587
```
595
588
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.**
0 commit comments