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
* Update LintMessage type to reflect implementation
I made three changes to `LintMessage` and `SuppressedLintMessage`
1. Many places that create `LintMessage`s don't set `fatal`, so I made
it optional. This would be a breaking change if we made types part of
our exports, but in this case I believe it's updating JSDoc
documentation to reflect reality.
2. Added an optional `messageId` property that's set by reports from rules.
3. Added an optional, nullable `nodeType` property.
- Reports from rules set it to a value.
- `applyDirectives()` explicitly sets it to `null` for unused
disable directives.
- `Linter`'s `createLintingProblem()` explicitly sets it to `null`.
* Add missing LintResult type import
* Use LintMessage type
All of these previously referenced a `Problem` type that does not have a
definition.
* Replace ReportInfo type with LintMessage type
`ReportInfo` was defined within `report-translator.js` to be very
similar to `LintMessage`. It had one extra property, `source`, which
wasn't ever set, so it would've been removed anyway. In
`Linter.runRules()`, the return value from `reportTranslator()` gets
pushed into a `lintingProblems` array and returned, and the return type
annotation is `LintMessage[]`, which gives me confidence that
`ReportInfo` was intended to be the same type as `LintMessage`
elsewhere.
* Make ruleId required but nullable
Originally, we talked about the reverse - making `ruleId` optional but
non-nullable and relying on `report-translator.js`'s `createProblem()`
to normalize it. However, the `LintMessage` type would differ from
`createProblem()`'s return value only by `null` vs `undefined` for
`ruleId`. So instead, I made `ruleId` required but nullable and
explicitly set it to `null` in the few remaining places that didn't
already.
* Add missing null nodeTypes
`LintMessage.nodeType` is currently defined as required but nullable.
Actual implementations explicitly set it to `null` in a couple places
and omit it in several.
After discussion in #16968, we initially leaned toward making it
non-nullable but optional. I pursued that, but it resulted in slightly
more runtime code changes, including some branching in
`report-translator` to set it conditionally.
Instead, I'm presenting the opposite solution of updating the remaining
implementations to match the existing type definition by explicitly
setting `nodeType` to `null`.
* Update LintMessage docs
This updates existing documented properties to match the updated `LintMessage`
type and implementations.
`messageId`, `nodeType`, and `suppressions` remain undocumented.
Copy file name to clipboardExpand all lines: lib/linter/linter.js
+14-9Lines changed: 14 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -364,7 +364,7 @@ function extractDirectiveComment(value) {
364
364
* @param {ASTNode} ast The top node of the AST.
365
365
* @param {function(string): {create: Function}} ruleMapper A map from rule IDs to defined rules
366
366
* @param {string|null} warnInlineConfig If a string then it should warn directive comments as disabled. The string value is the config name what the setting came from.
* @property {Array<{desc?: string, messageId?: string, fix: Function}>} suggest Suggestion descriptions and functions to create a the associated fixes.
30
32
*/
31
33
32
-
/**
33
-
* Information about the report
34
-
* @typedef {Object} ReportInfo
35
-
* @property {string} ruleId The rule ID
36
-
* @property {(0|1|2)} severity Severity of the error
37
-
* @property {(string|undefined)} message The message
38
-
* @property {(string|undefined)} [messageId] The message ID
39
-
* @property {number} line The line number
40
-
* @property {number} column The column number
41
-
* @property {(number|undefined)} [endLine] The ending line number
42
-
* @property {(number|undefined)} [endColumn] The ending column number
43
-
* @property {(string|null)} nodeType Type of node
44
-
* @property {string} source Source text
45
-
* @property {({text: string, range: (number[]|null)}|null)} [fix] The fix object
46
-
* @property {Array<{text: string, range: (number[]|null)}|null>} [suggestions] Suggestion info
0 commit comments