Skip to content

Commit

Permalink
Make ruleId required but nullable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
btmills committed Apr 9, 2023
1 parent 0e12c67 commit 83eb749
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/cli-engine/cli-engine.js
Expand Up @@ -308,6 +308,7 @@ function createIgnoreResult(filePath, baseDir) {
filePath: path.resolve(filePath),
messages: [
{
ruleId: null,
fatal: false,
severity: 1,
message,
Expand Down
1 change: 1 addition & 0 deletions lib/eslint/eslint-helpers.js
Expand Up @@ -607,6 +607,7 @@ function createIgnoreResult(filePath, baseDir) {
filePath: path.resolve(filePath),
messages: [
{
ruleId: null,
fatal: false,
severity: 1,
message,
Expand Down
4 changes: 2 additions & 2 deletions lib/shared/types.js
Expand Up @@ -101,7 +101,7 @@ module.exports = {};
* @property {number} line The 1-based line number.
* @property {string} message The error message.
* @property {string} [messageId] The ID of the message in the rule's meta.
* @property {(string|null)} [nodeType] Type of node
* @property {(string|null)} nodeType Type of node
* @property {string|null} ruleId The ID of the rule which makes this message.
* @property {0|1|2} severity The severity of this message.
* @property {Array<{desc?: string, messageId?: string, fix: {range: [number, number], text: string}}>} [suggestions] Information for suggestions.
Expand All @@ -117,7 +117,7 @@ module.exports = {};
* @property {number|undefined} line The 1-based line number.
* @property {string} message The error message.
* @property {string} [messageId] The ID of the message in the rule's meta.
* @property {(string|null)} [nodeType] Type of node
* @property {(string|null)} nodeType Type of node
* @property {string|null} ruleId The ID of the rule which makes this message.
* @property {0|1|2} severity The severity of this message.
* @property {Array<{kind: string, justification: string}>} suppressions The suppression info.
Expand Down
1 change: 1 addition & 0 deletions tests/lib/eslint/flat-eslint.js
Expand Up @@ -5012,6 +5012,7 @@ describe("FlatESLint", () => {
fixableWarningCount: 0,
messages: [
{
ruleId: null,
fatal: false,
message: "File ignored by default. Use \"--ignore-pattern '!node_modules/*'\" to override.",
severity: 1,
Expand Down

0 comments on commit 83eb749

Please sign in to comment.