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
feat: Pass --max-warnings value to formatters (#16348)
* feat: Pass --max-warnings value to formatters
Fixes#14881
* Make formatter docs wording consistent
Originally suggested by @fasttime in
#16348 (comment).
* Update LoadedFormatter and FormatterFunction typedefs
Originally suggested by @fasttime in
#16348 (comment).
Internally, I define two types, `MaxWarningsExceeded` and `ResultsMeta`,
that the updated `LoadedFormatter` and `FormatterFunction` types can
use. I'm then able to reuse the `ResultsMeta` type instead of the
generic `Object` type in `ESLint` and `FlatESLint`'s `format` wrapper
functions.
Externally in the Node.js API docs, I describe the new second argument
to `LoadedFormatter`'s `format` method inline rather than separately
documenting the new types.
While working on this, I noticed that `FlatESLint` is using the
pre-PR #15727 `Formatter` type rather than `LoadedFormatter` and
`FormatterFunction`. I'll fix that in a follow-up PR to keep this PR
scoped to passing `maxWarningsExceeded` info.
Copy file name to clipboardExpand all lines: docs/src/developer-guide/nodejs-api.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -410,8 +410,8 @@ This edit information means replacing the range of the `range` property by the `
410
410
411
411
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:
The method to convert the [LintResult] objects to text.`resultsMeta` is an object that will contain a `maxWarningsExceeded` object if `--max-warnings` was set and the number of warnings exceeded the limit. The `maxWarningsExceeded` object will contain two properties: `maxWarnings`, the value of the `--max-warnings` option, and `foundWarnings`, the number of lint warnings.
Copy file name to clipboardExpand all lines: docs/src/developer-guide/working-with-custom-formatters.md
+7-2Lines changed: 7 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -129,16 +129,21 @@ Each `message` object contains information about the ESLint rule that was trigge
129
129
130
130
## The `context` Argument
131
131
132
-
The formatter function receives an object as the second argument. The object has two properties:
132
+
The formatter function receives an object as the second argument. The object has the following properties:
133
133
134
134
*`cwd` ... The current working directory. This value comes from the `cwd` constructor option of the [ESLint](nodejs-api#-new-eslintoptions) class.
135
+
*`maxWarningsExceeded` (optional): If `--max-warnings` was set and the number of warnings exceeded the limit, this property's value will be an object containing two properties: `maxWarnings`, the value of the `--max-warnings` option, and `foundWarnings`, the number of lint warnings.
135
136
*`rulesMeta` ... The `meta` property values of rules. See the [Working with Rules](working-with-rules) page for more information about rules.
136
137
137
138
For example, here's what the object would look like if one rule, `no-extra-semi`, had been run:
138
139
139
140
```js
140
141
{
141
142
cwd:"/path/to/cwd",
143
+
maxWarningsExceeded: {
144
+
maxWarnings:5,
145
+
foundWarnings:6
146
+
},
142
147
rulesMeta: {
143
148
"no-extra-semi": {
144
149
type:"suggestion",
@@ -153,7 +158,7 @@ For example, here's what the object would look like if one rule, `no-extra-semi`
0 commit comments