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
docs: disambiguate types FormatterFunction and LoadedFormatter (#15727)
* chore: disambiguate types `FormatterFunction` and `LoadedFormatter`
Fixes#15654
* Code review update
* Remove redundant `LintResult` type import
* Remove note about `context` argument of `FormatterFunction` from JSDoc
* docs: Revert to using variable name `formatter` in code examples
@@ -287,8 +287,8 @@ This method loads a formatter. Formatters convert lint results to a human- or ma
287
287
288
288
#### Return Value
289
289
290
-
* (`Promise<Formatter>`)<br>
291
-
The promise that will be fulfilled with a [Formatter] object.
290
+
* (`Promise<LoadedFormatter>`)<br>
291
+
The promise that will be fulfilled with a [LoadedFormatter] object.
292
292
293
293
### ◆ ESLint.version
294
294
@@ -430,9 +430,9 @@ The `EditInfo` value is information to edit text. The `fix` and `suggestions` pr
430
430
431
431
This edit information means replacing the range of the `range` property by the `text` property value. It's like `sourceCodeText.slice(0, edit.range[0]) + edit.text + sourceCodeText.slice(edit.range[1])`. Therefore, it's an add if the `range[0]` and `range[1]` property values are the same value, and it's removal if the `text` property value is empty string.
432
432
433
-
### ◆ Formatter type
433
+
### ◆ LoadedFormatter type
434
434
435
-
The `Formatter` value is the object to convert the [LintResult] objects to text. The [eslint.loadFormatter()][eslint-loadformatter] method returns it. It has the following method:
435
+
The `LoadedFormatter` value is the object to convert the [LintResult] objects to text. The [eslint.loadFormatter()][eslint-loadformatter] method returns it. It has the following method:
Copy file name to clipboardExpand all lines: docs/developer-guide/working-with-custom-formatters.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
While ESLint has some built-in formatters available to format the linting results, it's also possible to create and distribute your own custom formatters. You can include custom formatters in your project directly or create an npm package to distribute them separately.
4
4
5
-
Each formatter is just a function that receives a `results` object and returns a string. For example, the following is how the `json` built-in formatter is implemented:
5
+
Each formatter is just a function that receives a `results` object and a `context` and returns a string. For example, the following is how the `json` built-in formatter is implemented:
While custom formatter do not receive arguments in addition to the results object, it is possible to pass additional data into formatters.
283
+
While formatter functions do not receive arguments in addition to the results object and the context, it is possible to pass additional data into custom formatters using the methods described below.
0 commit comments